3030from  isort  import  SortImports , __version__ 
3131from  isort .settings  import  DEFAULT_SECTIONS , default , from_path , should_skip 
3232
33- from  .pie_slice  import  * 
33+ from  .pie_slice  import  itemsview 
3434
3535
36- INTRO  =  """ 
37- /#######################################################################\\   
36+ INTRO  =  r """
37+ /#######################################################################\ 
3838
3939 `sMMy` 
4040 .yyyy- ` 
@@ -130,7 +130,7 @@ def run(self):
130130 if  incorrectly_sorted :
131131 wrong_sorted_files  =  True 
132132 except  IOError  as  e :
133-  print ("WARNING: Unable to parse file {0} due to {1}" .format (file_name , e ))
133+  print ("WARNING: Unable to parse file {0} due to {1}" .format (python_file , e ))
134134 if  wrong_sorted_files :
135135 exit (1 )
136136
@@ -164,37 +164,35 @@ def create_parser():
164164 help = 'Force sortImports to recognize a module as being part of the current python project.' )
165165 parser .add_argument ('--virtual-env' , dest = 'virtual_env' ,
166166 help = 'Virtual environment to use for determining whether a package is third-party' )
167-  parser .add_argument ('-m' , '--multi_line ' , dest = 'multi_line_output' , type = int , choices = [0 , 1 , 2 , 3 , 4 , 5 ],
167+  parser .add_argument ('-m' , '--multi-line ' , dest = 'multi_line_output' , type = int , choices = [0 , 1 , 2 , 3 , 4 , 5 ],
168168 help = 'Multi line output (0-grid, 1-vertical, 2-hanging, 3-vert-hanging, 4-vert-grid, ' 
169169 '5-vert-grid-grouped).' )
170170 parser .add_argument ('-i' , '--indent' , help = 'String to place for indents defaults to " " (4 spaces).' ,
171171 dest = 'indent' , type = str )
172-  parser .add_argument ('-a' , '--add_import ' , dest = 'add_imports' , action = 'append' ,
172+  parser .add_argument ('-a' , '--add-import ' , dest = 'add_imports' , action = 'append' ,
173173 help = 'Adds the specified import line to all files, ' 
174174 'automatically determining correct placement.' )
175-  parser .add_argument ('-af' , '--force_adds ' , dest = 'force_adds' , action = 'store_true' ,
175+  parser .add_argument ('-af' , '--force-adds ' , dest = 'force_adds' , action = 'store_true' ,
176176 help = 'Forces import adds even if the original file is empty.' )
177-  parser .add_argument ('-r' , '--remove_import ' , dest = 'remove_imports' , action = 'append' ,
177+  parser .add_argument ('-r' , '--remove-import ' , dest = 'remove_imports' , action = 'append' ,
178178 help = 'Removes the specified import from all files.' )
179-  parser .add_argument ('-ls' , '--length_sort ' , help = 'Sort imports by their string length.' ,
180-  dest = 'length_sort' , action = 'store_true' ,  default = False )
179+  parser .add_argument ('-ls' , '--length-sort ' , help = 'Sort imports by their string length.' ,
180+  dest = 'length_sort' , action = 'store_true' )
181181 parser .add_argument ('-d' , '--stdout' , help = 'Force resulting output to stdout, instead of in-place.' ,
182182 dest = 'write_to_stdout' , action = 'store_true' )
183-  parser .add_argument ('-c' , '--check-only' , action = 'store_true' , default = False ,  dest = "check" ,
183+  parser .add_argument ('-c' , '--check-only' , action = 'store_true' , dest = "check" ,
184184 help = 'Checks the file for unsorted / unformatted imports and prints them to the ' 
185185 'command line without modifying the file.' )
186-  parser .add_argument ('-ws' , '--enforce-white-space ' , action = 'store_true' , default = False ,  dest = "enforce_white_space " ,
187-  help = 'Tells isort to enforce white space difference  when --check-only is being used.' )
186+  parser .add_argument ('-ws' , '--ignore-whitespace ' , action = 'store_true' , dest = "ignore_whitespace " ,
187+  help = 'Tells isort to ignore whitespace differences  when --check-only is being used.' )
188188 parser .add_argument ('-sl' , '--force-single-line-imports' , dest = 'force_single_line' , action = 'store_true' ,
189189 help = 'Forces all from imports to appear on their own line' )
190-  parser .add_argument ('--force_single_line_imports' , dest = 'force_single_line' , action = 'store_true' ,
191-  help = argparse .SUPPRESS )
192190 parser .add_argument ('-ds' , '--no-sections' , help = 'Put all imports into the same section bucket' , dest = 'no_sections' ,
193191 action = 'store_true' )
194192 parser .add_argument ('-sd' , '--section-default' , dest = 'default_section' ,
195193 help = 'Sets the default section for imports (by default FIRSTPARTY) options: '  + 
196194 str (DEFAULT_SECTIONS ))
197-  parser .add_argument ('-df' , '--diff' , dest = 'show_diff' , default = False ,  action = 'store_true' ,
195+  parser .add_argument ('-df' , '--diff' , dest = 'show_diff' , action = 'store_true' ,
198196 help = "Prints a diff of all the changes isort would make to a file, instead of " 
199197 "changing it in place" )
200198 parser .add_argument ('-e' , '--balanced' , dest = 'balanced_wrapping' , action = 'store_true' ,
@@ -218,22 +216,25 @@ def create_parser():
218216 help = 'Shows verbose output, such as when files are skipped or when a check is successful.' )
219217 parser .add_argument ('-q' , '--quiet' , action = 'store_true' , dest = "quiet" ,
220218 help = 'Shows extra quiet output, only errors are outputted.' )
221-  parser .add_argument ('-sp' , '--settings-path' ,   dest = "settings_path" ,
219+  parser .add_argument ('-sp' , '--settings-path' , dest = "settings_path" ,
222220 help = 'Explicitly set the settings path instead of auto determining based on file location.' )
223221 parser .add_argument ('-ff' , '--from-first' , dest = 'from_first' ,
224222 help = "Switches the typical ordering preference, showing from imports first then straight ones." )
225223 parser .add_argument ('-wl' , '--wrap-length' , dest = 'wrap_length' ,
226224 help = "Specifies how long lines that are wrapped should be, if not set line_length is used." )
227-  parser .add_argument ('-fgw' , '--force-grid-wrap' , action = 'store_true' , dest = "force_grid_wrap" ,
228-  help = 'Force from imports to be grid wrapped regardless of line length' )
229-  parser .add_argument ('-fass' , '--force-alphabetical-sort-within-sections' , action = 'store_true' ,
225+  parser .add_argument ('-fgw' , '--force-grid-wrap' , nargs = '?' , const = 2 , type = int , dest = "force_grid_wrap" ,
226+  help = 'Force number of from imports (defaults to 2) to be grid wrapped regardless of line ' 
227+  'length' )
228+  parser .add_argument ('-fass' , '--force-alphabetical-sort-within-sections' , action = 'store_true' ,
230229 dest = "force_alphabetical_sort" , help = 'Force all imports to be sorted alphabetically within a ' 
231230 'section' )
232-  parser .add_argument ('-fas' , '--force-alphabetical-sort' ,   action = 'store_true' , dest = "force_alphabetical_sort" ,
231+  parser .add_argument ('-fas' , '--force-alphabetical-sort' , action = 'store_true' , dest = "force_alphabetical_sort" ,
233232 help = 'Force all imports to be sorted as a single section' )
234-  parser .add_argument ('-fss' , '--force-sort-within-sections' ,   action = 'store_true' , dest = "force_sort_within_sections" ,
233+  parser .add_argument ('-fss' , '--force-sort-within-sections' , action = 'store_true' , dest = "force_sort_within_sections" ,
235234 help = 'Force imports to be sorted by module, independent of import_type' )
236235 parser .add_argument ('-lbt' , '--lines-between-types' , dest = 'lines_between_types' , type = int )
236+  parser .add_argument ('-up' , '--use-parentheses' , dest = 'use_parentheses' , action = 'store_true' ,
237+  help = 'Use parenthesis for line continuation on lenght limit instead of slashes.' )
237238
238239 arguments  =  dict ((key , value ) for  (key , value ) in  itemsview (vars (parser .parse_args ())) if  value )
239240 if  'dont_order_by_type'  in  arguments :
@@ -267,7 +268,7 @@ def main():
267268 if  arguments .get ('recursive' , False ):
268269 file_names  =  iter_source_code (file_names , config , skipped )
269270 num_skipped  =  0 
270-  if  config . get ( 'verbose' ,  False )  or  config .get ('show_logo' , False ):
271+  if  config [ 'verbose' ]  or  config .get ('show_logo' , False ):
271272 print (INTRO )
272273 for  file_name  in  file_names :
273274 try :
0 commit comments