@@ -31,15 +31,15 @@ def is_unsupported_comparison(line):
3131
3232
3333def uncomment (line ):
34- if line .startswith ("#" ):
34+ if line .startswith ('#' ):
3535 return line [1 :]
36- if line .startswith ("//" ):
36+ if line .startswith ('//' ):
3737 return line [2 :]
3838 return line
3939
4040
4141def download_debian_db ():
42- urllib .request .urlretrieve (" https://osv-vulnerabilities.storage.googleapis.com/Debian/all.zip" , " debian-db.zip" )
42+ urllib .request .urlretrieve (' https://osv-vulnerabilities.storage.googleapis.com/Debian/all.zip' , ' debian-db.zip' )
4343
4444
4545def extract_packages_with_versions (osvs ):
@@ -75,17 +75,17 @@ def __init__(self, cache_path):
7575 def _load_cache (self ):
7676 if self .cache_path :
7777 self .cache_path .touch ()
78- with open (self .cache_path , "r" ) as f :
78+ with open (self .cache_path , 'r' ) as f :
7979 lines = f .readlines ()
8080
8181 for line in lines :
8282 line = line .strip ()
83- key , result = line .split ("," )
83+ key , result = line .split (',' )
8484
85- if result == " True" :
85+ if result == ' True' :
8686 self .cache [key ] = True
8787 continue
88- if result == " False" :
88+ if result == ' False' :
8989 self .cache [key ] = False
9090 continue
9191
@@ -95,15 +95,15 @@ def _save_to_cache(self, key, result):
9595 self .cache [key ] = result
9696 if self .cache_path :
9797 self .cache_path .touch ()
98- with open (self .cache_path , "a" ) as f :
99- f .write (f" { key } ,{ result } \n " )
98+ with open (self .cache_path , 'a' ) as f :
99+ f .write (f' { key } ,{ result } \n ' )
100100
101101 def compare (self , a , op , b ):
102- key = f" { a } { op } { b } "
102+ key = f' { a } { op } { b } '
103103 if key in self .cache :
104104 return self .cache [key ]
105105
106- cmd = [" dpkg" , " --compare-versions" , a , op , b ]
106+ cmd = [' dpkg' , ' --compare-versions' , a , op , b ]
107107 out = subprocess .run (cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
108108
109109 if out .stdout :
@@ -116,7 +116,7 @@ def compare(self, a, op, b):
116116 return r
117117
118118
119- debian_comparer = DebianVersionComparer (" /tmp/debian-versions-generator-cache.csv" )
119+ debian_comparer = DebianVersionComparer (' /tmp/debian-versions-generator-cache.csv' )
120120
121121
122122class DebianVersion :
@@ -144,39 +144,39 @@ def compare(v1, relate, v2):
144144 return ops [relate ](v1 , v2 )
145145
146146
147- def compare_versions (lines , select = " all" ):
147+ def compare_versions (lines , select = ' all' ):
148148 has_any_failed = False
149149
150150 for line in lines :
151151 line = line .strip ()
152152
153- if line == "" or line .startswith ('#' ) or line .startswith ('//' ):
153+ if line == '' or line .startswith ('#' ) or line .startswith ('//' ):
154154 maybe_unsupported = uncomment (line ).strip ()
155155
156156 if is_unsupported_comparison (maybe_unsupported ):
157- print (f" \033 [96mS\033 [0m: \033 [93m{ maybe_unsupported } \033 [0m" )
157+ print (f' \033 [96mS\033 [0m: \033 [93m{ maybe_unsupported } \033 [0m' )
158158 continue
159159
160- v1 , op , v2 = line .strip ().split (" " )
160+ v1 , op , v2 = line .strip ().split (' ' )
161161
162162 r = compare (DebianVersion (v1 ), op , DebianVersion (v2 ))
163163
164164 if not r :
165165 has_any_failed = r
166166
167- if select == " failures" and r :
167+ if select == ' failures' and r :
168168 continue
169169
170- if select == " successes" and not r :
170+ if select == ' successes' and not r :
171171 continue
172172
173173 color = '\033 [92m' if r else '\033 [91m'
174- rs = "T" if r else "F"
175- print (f" { color } { rs } \033 [0m: \033 [93m{ line } \033 [0m" )
174+ rs = 'T' if r else 'F'
175+ print (f' { color } { rs } \033 [0m: \033 [93m{ line } \033 [0m' )
176176 return has_any_failed
177177
178178
179- def compare_versions_in_file (filepath , select = " all" ):
179+ def compare_versions_in_file (filepath , select = ' all' ):
180180 with open (filepath ) as f :
181181 lines = f .readlines ()
182182 return compare_versions (lines , select )
@@ -188,10 +188,10 @@ def generate_version_compares(versions):
188188 if i == 0 :
189189 continue
190190
191- comparison = f" { versions [i - 1 ]} < { version } \n "
191+ comparison = f' { versions [i - 1 ]} < { version } \n '
192192
193193 if is_unsupported_comparison (comparison .strip ()):
194- comparison = "# " + comparison
194+ comparison = '# ' + comparison
195195 comparisons .append (comparison )
196196 return comparisons
197197
@@ -218,16 +218,16 @@ def fetch_packages_versions():
218218 return extract_packages_with_versions (osvs )
219219
220220
221- outfile = " pkg/semantic/fixtures/debian-versions-generated.txt"
221+ outfile = ' pkg/semantic/fixtures/debian-versions-generated.txt'
222222
223223packs = fetch_packages_versions ()
224- with open (outfile , "w" ) as f :
224+ with open (outfile , 'w' ) as f :
225225 f .writelines (generate_package_compares (packs ))
226- f .write (" \n " )
226+ f .write (' \n ' )
227227
228228# set this to either "failures" or "successes" to only have those comparison results
229229# printed; setting it to anything else will have all comparison results printed
230- show = os .environ .get (" VERSION_GENERATOR_PRINT" , " failures" )
230+ show = os .environ .get (' VERSION_GENERATOR_PRINT' , ' failures' )
231231
232232did_any_fail = compare_versions_in_file (outfile , show )
233233
0 commit comments