2424 mp = multiprocessing
2525 del multiprocessing
2626
27- # backport compatibility
28- if sys .version_info [:2 ] < (3 , 5 ):
29- import pathlib2 as pathlib
30- else :
31- import pathlib
32-
3327# version string
34- __version__ = '0.5.2 '
28+ __version__ = '0.5.3 '
3529
3630# macros
3731__cwd__ = os .getcwd ()
@@ -61,7 +55,7 @@ def get_parser():
6155 default = __f2format_version__ , choices = PARSO_VERSION ,
6256 help = 'convert against Python version (%s)' % __f2format_version__ )
6357
64- parser .add_argument ('file' , nargs = '* ' , metavar = 'SOURCE' , default = __cwd__ ,
58+ parser .add_argument ('file' , nargs = '+ ' , metavar = 'SOURCE' , default = __cwd__ ,
6559 help = 'python source files and folders to be converted (%s)' % __cwd__ )
6660
6761 return parser
@@ -99,15 +93,15 @@ def rename(path):
9993
10094 # make archive directory
10195 if archive :
102- pathlib . Path (ARCHIVE ). mkdir ( parents = True , exist_ok = True )
96+ os . makedirs (ARCHIVE , exist_ok = True )
10397
10498 # fetch file list
10599 filelist = list ()
106100 for path in sys .argv [1 :]:
107101 if os .path .isfile (path ):
108102 if archive :
109103 dest = rename (path )
110- pathlib . Path ( dest ). parent . mkdir ( parents = True , exist_ok = True )
104+ os . makedirs ( os . path . dirname ( dest ) , exist_ok = True )
111105 shutil .copy (path , dest )
112106 filelist .append (path )
113107 if os .path .isdir (path ):
@@ -117,14 +111,14 @@ def rename(path):
117111
118112 # check if file is Python source code
119113 def ispy (file ): return (os .path .isfile (file ) and (os .path .splitext (file )[1 ] in ('.py' , '.pyw' )))
120- filelist = set (filter (ispy , filelist ))
114+ filelist = sorted (filter (ispy , filelist ))
121115
122116 # if no file supplied
123117 if len (filelist ) == 0 :
124118 parser .error ('argument PATH: no valid source file found' )
125119
126120 # process files
127- if mp is None :
121+ if mp is None or CPU_CNT <= 1 :
128122 [f2format (filename ) for filename in filelist ]
129123 else :
130124 mp .Pool (processes = CPU_CNT ).map (f2format , filelist )
0 commit comments