Skip to content

Commit

Permalink
changed directory names
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-fenton committed Nov 11, 2024
1 parent 578df7b commit 1b1933a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions i18nilize/src/internationalize/diffing_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
# Diffing Processor Class
class DiffingProcessor():
def __init__(self, curr_translations_dir):
self.old_translations_root_dir = "old_translations"
self.old_translation_files_dir = os.path.join(self.old_translations_root_dir, "translations")
self.metadata_file_dir = os.path.join(self.old_translations_root_dir, "metadata.json")
self.diff_state_root_dir = "diff_state"
self.diff_state_files_dir = os.path.join(self.diff_state_root_dir, "translations")
self.metadata_file_dir = os.path.join(self.diff_state_root_dir, "metadata.json")
self.curr_translation_files_dir = curr_translations_dir

"""
Initializes the old state of translations when package is first installed.
"""
def setup(self):
try:
os.mkdir(self.old_translations_root_dir)
os.mkdir(self.old_translation_files_dir)
os.mkdir(self.diff_state_root_dir)
os.mkdir(self.diff_state_files_dir)
with open(self.metadata_file_dir, "w") as outfile:
json.dump({}, outfile)

# sync folders
self.sync_translations()

# Compute all file hashes and store hashes in metadata
all_files = os.listdir(self.old_translation_files_dir)
all_file_hashes = compute_hashes(self.old_translation_files_dir)
all_files = os.listdir(self.diff_state_files_dir)
all_file_hashes = compute_hashes(self.diff_state_files_dir)
self.update_metadata(all_files, all_file_hashes)
except FileExistsError:
print(f"Old translations directory has already been created.")
Expand Down Expand Up @@ -74,7 +74,7 @@ def update_metadata(self, changed_files_list, hash_dict):
json.dump(hash_dict, outfile)

def sync_translations(self):
sync(self.curr_translation_files_dir, self.old_translation_files_dir, "sync", purge=True)
sync(self.curr_translation_files_dir, self.diff_state_files_dir, "sync", purge=True)


"""
Expand All @@ -99,4 +99,4 @@ def compute_hashes(directory):
file_hash = compute_hash(file_content)
hash_dict[file_name_no_ext] = file_hash

return hash_dict
return hash_dict

0 comments on commit 1b1933a

Please sign in to comment.