bupa1018 commited on
Commit
60cbd15
·
1 Parent(s): 99633b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -91,30 +91,32 @@ def download_gitlab_repo():
91
  print("Upload complete")
92
 
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  def process_directory(directory):
95
  all_texts = []
96
  file_references = []
97
 
98
- zip_files = [file for file in os.listdir(directory) if file.endswith('.zip')]
99
-
100
- if not zip_files:
101
- print("No zip files found in the directory.")
102
- else:
103
- for zip_filename in zip_files:
104
- zip_file_path = os.path.join(directory, zip_filename)
105
-
106
- # Create a temporary directory for each zip file
107
- with tempfile.TemporaryDirectory() as tmpdirname:
108
- # Unzip the file into the temporary directory
109
- with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
110
- zip_ref.extractall(tmpdirname)
111
-
112
- # Process the temporary directory
113
- temp_texts, temp_references = process_directory(tmpdirname)
114
- all_texts.extend(temp_texts)
115
- file_references.extend(temp_references)
116
 
117
- for root, _, files in os.walk(directory):
118
  for file in files:
119
  file_path = os.path.join(root, file)
120
  file_ext = os.path.splitext(file_path)[1]
 
91
  print("Upload complete")
92
 
93
 
94
+ def extract_single_zip_file(directory):
95
+ zip_file = [file for file in os.listdir(directory) if file.endswith('.zip')]
96
+
97
+ if not zip_file:
98
+ print("No zip file found in the directory.")
99
+ else:
100
+ zip_filename = zip_file # Get the only zip file
101
+ zip_file_path = os.path.join(directory, zip_file)
102
+
103
+ # Create a temporary directory for the zip file
104
+ with tempfile.TemporaryDirectory() as tmpdirname:
105
+ # Unzip the file into the temporary directory
106
+ with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
107
+ zip_ref.extractall(tmpdirname)
108
+ print(f"Extracted {zip_filename} to {tmpdirname}")
109
+ return tmpdirname
110
+
111
+
112
+
113
  def process_directory(directory):
114
  all_texts = []
115
  file_references = []
116
 
117
+ directory_path = extract_single_zip_file(directory)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
+ for root, _, files in os.walk(directory_path):
120
  for file in files:
121
  file_path = os.path.join(root, file)
122
  file_ext = os.path.splitext(file_path)[1]