Showing 1 changed files with 18 additions and 12 deletions
+18 -12
compare
... ...
@@ -40,6 +40,18 @@ def initialize():
40 40
             raise argparse.ArgumentTypeError("{} n'est pas compris entre 0 et 100 inclus".format(n))
41 41
         return n
42 42
 
43
+    def parse_input_files(input_file, source_files):
44
+        if isinstance(input_file, list):
45
+            for f in input_file:
46
+                parse_input_files(f, source_files)
47
+        else:
48
+            if os.path.isfile(input_file):
49
+                source_files[input_file] = 1
50
+            elif os.path.isdir(input_file):
51
+                for root, dirs, files in os.walk(input_file):
52
+                    for f in files:
53
+                        parse_input_files(os.path.join(root, f), source_files)
54
+
43 55
     parser = argparse.ArgumentParser(__file__)
44 56
     parser.add_argument("-i ", "--source-file",
45 57
             action   = 'append',
... ...
@@ -83,18 +95,12 @@ def initialize():
83 95
             )
84 96
 
85 97
     args = parser.parse_args()
86
-  
87
-    sources_files = {}
88
-    for input_file in args.source_file:
89
-        if os.path.isfile(input_file[0]):
90
-            sources_files[input_file[0]] = 1
91
-        elif os.path.isdir(input_file[0]):
92
-            for root, dirs, files in os.walk(input_file[0]):
93
-                for file in files:
94
-                    if os.path.isfile(os.path.join(root, file)):
95
-                        sources_files[os.path.join(root, file)] = 1
96
-
97
-    return list(sources_files.keys()), args
98
+
99
+    source_files = {}
100
+    for f in args.source_file:
101
+        parse_input_files(f, source_files)
102
+
103
+    return list(source_files.keys()), args
98 104
   
99 105
 def prime(i, primes):
100 106
     for prime in primes: