@@ -52,7 +52,7 @@ def parse_arguments():
5252 type = str ,
5353 nargs = "?" ,
5454 help = "The language to use, should be fr (French), en (English), es (Spanish), de (German), ar (Arabic), cn (Chinese), or hi (Hindi)" ,
55- default = "en"
55+ default = "en" ,
5656 )
5757 parser .add_argument (
5858 "-c" ,
@@ -289,7 +289,7 @@ def parse_arguments():
289289 type = str ,
290290 nargs = "?" ,
291291 help = "Define an image directory to use when background is set to image" ,
292- default = os .path .join (os .path .split (os .path .realpath (__file__ ))[0 ], "images" )
292+ default = os .path .join (os .path .split (os .path .realpath (__file__ ))[0 ], "images" ),
293293 )
294294 parser .add_argument (
295295 "-ca" ,
@@ -302,36 +302,14 @@ def parse_arguments():
302302 "-dt" , "--dict" , type = str , nargs = "?" , help = "Define the dictionary to be used"
303303 )
304304 parser .add_argument (
305- "-ws" , "--word_split" ,
305+ "-ws" ,
306+ "--word_split" ,
306307 action = "store_true" ,
307308 help = "Split on words instead of on characters (preserves ligatures, no character spacing)" ,
308309 default = False ,
309310 )
310311 return parser .parse_args ()
311312
312- def load_dict (lang ):
313- """
314- Read the dictionnary file and returns all words in it.
315- """
316-
317- lang_dict = []
318- with open (os .path .join ('dicts' , lang + '.txt' ), 'r' , encoding = "utf8" , errors = 'ignore' ) as d :
319- lang_dict = d .readlines ()
320- return lang_dict
321-
322- def load_fonts (lang ):
323- """
324- Load all fonts in the fonts directories
325- """
326-
327- if lang == 'ar' :
328- return [os .path .join ('fonts/ar' , font ) for font in os .listdir ('fonts/ar' )]
329- elif lang == 'cn' :
330- return [os .path .join ('fonts/cn' , font ) for font in os .listdir ('fonts/cn' )]
331- elif lang == 'hi' :
332- return [os .path .join ('fonts/hi' , font ) for font in os .listdir ('fonts/hi' )]
333- else :
334- return [os .path .join ('fonts/latin' , font ) for font in os .listdir ('fonts/latin' )]
335313
336314def main ():
337315 """
@@ -403,10 +381,14 @@ def main():
403381 args .length , args .random , args .count , lang_dict
404382 )
405383
406- if args .language == 'ar' :
384+ if args .language == "ar" :
407385 from arabic_reshaper import ArabicReshaper
386+
408387 arabic_reshaper = ArabicReshaper ()
409- strings = [' ' .join ([arabic_reshaper .reshape (w ) for w in s .split (' ' )[::- 1 ]]) for s in strings ]
388+ strings = [
389+ " " .join ([arabic_reshaper .reshape (w ) for w in s .split (" " )[::- 1 ]])
390+ for s in strings
391+ ]
410392 if args .case == "upper" :
411393 strings = [x .upper () for x in strings ]
412394 if args .case == "lower" :
0 commit comments