Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -91,34 +91,16 @@ def download_gitlab_repo():
|
|
91 |
print("Upload complete")
|
92 |
|
93 |
def get_all_files_in_folder(temp_dir, partial_paths):
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
for dir_name in dirs:
|
101 |
-
dir_path = os.path.join(root, dir_name)
|
102 |
-
subordinate_dirs.append(dir_path)
|
103 |
-
|
104 |
-
# Print all subordinate directory paths
|
105 |
-
for path in subordinate_dirs:
|
106 |
-
print(path)
|
107 |
-
|
108 |
-
|
109 |
-
print("inside the get all files in folder method")
|
110 |
-
all_files = []
|
111 |
-
|
112 |
-
for partial_path in partial_paths:
|
113 |
-
print("inner method of get all files in folder")
|
114 |
-
target_dir = os.path.join(temp_dir, partial_path)
|
115 |
-
print(target_dir)
|
116 |
-
|
117 |
-
for root, dirs, files in os.walk(target_dir):
|
118 |
-
print(f"Files in current directory ({root}): {files}")
|
119 |
-
for file in files:
|
120 |
-
print(f"Processing file: {file}")
|
121 |
-
all_files.append(os.path.join(root, file))
|
122 |
|
123 |
return all_files
|
124 |
|
@@ -159,9 +141,17 @@ def process_directory(directory, partial_paths=None, file_paths=None):
|
|
159 |
print(f"Extracted {zip_file_path} to {tmpdirname}")
|
160 |
|
161 |
files = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
if partial_paths:
|
163 |
print("Go in partial_paths")
|
164 |
-
|
|
|
165 |
else:
|
166 |
print("wtf")
|
167 |
for root, _, files_list in os.walk(tmpdirname):
|
|
|
91 |
print("Upload complete")
|
92 |
|
93 |
def get_all_files_in_folder(temp_dir, partial_paths):
|
94 |
+
|
95 |
+
print("inner method of get all files in folder")
|
96 |
+
target_dir = os.path.join(temp_dir, partial_path)
|
97 |
+
print(target_dir)
|
98 |
|
99 |
+
for root, dirs, files in os.walk(target_dir):
|
100 |
+
print(f"Files in current directory ({root}): {files}")
|
101 |
+
for file in files:
|
102 |
+
print(f"Processing file: {file}")
|
103 |
+
all_files.append(os.path.join(root, file))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
return all_files
|
106 |
|
|
|
141 |
print(f"Extracted {zip_file_path} to {tmpdirname}")
|
142 |
|
143 |
files = []
|
144 |
+
|
145 |
+
unzipped_root = os.listdir(tmpdirname)
|
146 |
+
if len(unzipped_root) == 1 and os.path.isdir(os.path.join(tmpdirname, unzipped_root[0])):
|
147 |
+
tmpsubdirpath= os.path.join(tmpdirname, unzipped_root[0])
|
148 |
+
else:
|
149 |
+
tmpsubdirpath = tmpdirname
|
150 |
+
|
151 |
if partial_paths:
|
152 |
print("Go in partial_paths")
|
153 |
+
for path in partial_paths:
|
154 |
+
files += get_all_files_in_folder(tmpsubdirpath, partial_paths)
|
155 |
else:
|
156 |
print("wtf")
|
157 |
for root, _, files_list in os.walk(tmpdirname):
|