Skip to content

Commit

Permalink
Improve battery calculation script further
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Oct 14, 2024
1 parent 619c9de commit 94b8ad7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ def process_zip(zip_file_path):
with zipfile.ZipFile(zip_file_path, 'r') as zip_file:
sorted_files = []
for file_name in zip_file.namelist():
if file_name == "Dictionary.json":
sorted_files.append(("Dictionary-1.json", file_name))
elif re.match(r'Dictionary-(\d+)\.json', file_name):
sorted_files.append((file_name, file_name))
sorted_files.sort(key=lambda x: int(re.search(r'Dictionary-(\d+)\.json', x[0]).group(1)))
if re.match(r'^[^/]+-(\d+)\.json$', file_name):
sorted_files.append((re.search(r'^[^/]+-(\d+)\.json$', file_name).group(1), file_name))
elif re.match(r'^[^/]+\.json$', file_name):
sorted_files.append(("1", file_name))
sorted_files.sort(key=lambda x: int(x[0]))
print(sorted_files)
for _, file_name in sorted_files:
logger.debug(f"Parsing file: {file_name}")
with zip_file.open(file_name) as json_file:
Expand Down

0 comments on commit 94b8ad7

Please sign in to comment.