3232 logger .setLevel (logging .DEBUG )
3333
3434# Suffix added to extracted target_dir paths
35- EXTRACT_SUFFIX = ' -extract'
35+ EXTRACT_SUFFIX = " -extract"
3636
3737# high level archive "kinds"
3838docs = 1
4444special_package = 7
4545
4646kind_labels = {
47- 1 : ' docs' ,
48- 2 : ' regular' ,
49- 3 : ' regular_nested' ,
50- 4 : ' package' ,
51- 5 : ' file_system' ,
52- 6 : ' patches' ,
53- 7 : ' special_package' ,
47+ 1 : " docs" ,
48+ 2 : " regular" ,
49+ 3 : " regular_nested" ,
50+ 4 : " package" ,
51+ 5 : " file_system" ,
52+ 6 : " patches" ,
53+ 7 : " special_package" ,
5454}
5555
5656# note: we do not include special_package in all_kinds by default
7272
7373# map user-visible extract types to tuples of "kinds"
7474extract_types = {
75- ' default' : default_kinds ,
76- ' all' : all_kinds ,
77- ' package' : (package ,),
78- ' filesystem' : (file_system ,),
79- ' doc' : (docs ,),
80- ' patch' : (patches ,),
81- ' special_package' : (special_package ,),
75+ " default" : default_kinds ,
76+ " all" : all_kinds ,
77+ " package" : (package ,),
78+ " filesystem" : (file_system ,),
79+ " doc" : (docs ,),
80+ " patch" : (patches ,),
81+ " special_package" : (special_package ,),
8282}
8383
8484
8585def is_extraction_path (path ):
8686 """
8787 Return True is the path points to an extraction path.
8888 """
89- return path and path .rstrip (' \\ /' ).endswith (EXTRACT_SUFFIX )
89+ return path and path .rstrip (" \\ /" ).endswith (EXTRACT_SUFFIX )
9090
9191
9292def is_extracted (location ):
@@ -101,14 +101,14 @@ def get_extraction_path(path):
101101 """
102102 Return a path where to extract.
103103 """
104- return path .rstrip (' \\ /' ) + EXTRACT_SUFFIX
104+ return path .rstrip (" \\ /" ) + EXTRACT_SUFFIX
105105
106106
107107def remove_archive_suffix (path ):
108108 """
109109 Remove all the extracted suffix from a path.
110110 """
111- return re .sub (EXTRACT_SUFFIX , '' , path )
111+ return re .sub (EXTRACT_SUFFIX , "" , path )
112112
113113
114114def remove_backslashes_and_dotdots (directory ):
@@ -119,13 +119,13 @@ def remove_backslashes_and_dotdots(directory):
119119 errors = []
120120 for top , _ , files in os .walk (directory ):
121121 for filename in files :
122- if not (' \\ ' in filename or '..' in filename ):
122+ if not (" \\ " in filename or ".." in filename ):
123123 continue
124124 try :
125- new_path = as_posixpath (filename ).strip ('/' )
126- new_path = posixpath .normpath (new_path ).replace ('..' , '/' ).strip ('/' )
125+ new_path = as_posixpath (filename ).strip ("/" )
126+ new_path = posixpath .normpath (new_path ).replace (".." , "/" ).strip ("/" )
127127 new_path = posixpath .normpath (new_path )
128- segments = new_path .split ('/' )
128+ segments = new_path .split ("/" )
129129 directory = join (top , * segments [:- 1 ])
130130 create_dir (directory )
131131 shutil .move (join (top , filename ), join (top , * segments ))
@@ -149,7 +149,7 @@ def new_name(location, is_dir=False):
149149 the extension unchanged.
150150 """
151151 assert location
152- location = location .rstrip (' \\ /' )
152+ location = location .rstrip (" \\ /" )
153153 assert location
154154
155155 parent = parent_directory (location )
@@ -160,8 +160,8 @@ def new_name(location, is_dir=False):
160160 filename = file_name (location )
161161
162162 # corner case
163- if filename in ('.' , '..' ):
164- filename = '_'
163+ if filename in ("." , ".." ):
164+ filename = "_"
165165
166166 # if unique, return this
167167 if filename .lower () not in siblings_lower :
@@ -171,19 +171,19 @@ def new_name(location, is_dir=False):
171171 if is_dir :
172172 # directories do not have an "extension"
173173 base_name = filename
174- ext = ''
174+ ext = ""
175175 else :
176- base_name , dot , ext = filename .partition ('.' )
176+ base_name , dot , ext = filename .partition ("." )
177177 if dot :
178- ext = f' .{ ext } '
178+ ext = f" .{ ext } "
179179 else :
180180 base_name = filename
181- ext = ''
181+ ext = ""
182182
183183 # find a unique filename, adding a counter int to the base_name
184184 counter = 1
185185 while 1 :
186- filename = f' { base_name } _{ counter } { ext } '
186+ filename = f" { base_name } _{ counter } { ext } "
187187 if filename .lower () not in siblings_lower :
188188 break
189189 counter += 1
0 commit comments