-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
there is now a new type of result, duplicate files these are files that already exist in the destination folder and are not imported if not importing duplicates I have thoroughly verified that my changes do not cause any other part of the code to break or act in an unexpected manner. I have also removed some code that could never get used: elodie/localstorage.py: checksum() could never return None, code was not accessible due to earlier return because of this: elodie/filesystem.py: process_checksum() did not need to check if checksum was None after calculating it this is what allowed my new code to use None as a flag meaning that the file being imported and skipped is a duplicate file
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,24 @@ def __init__(self): | |
self.success = 0 | ||
self.error = 0 | ||
self.error_items = [] | ||
self.duplicate = 0 | ||
self.duplicate_items = [] | ||
|
||
def append(self, row): | ||
id, status = row | ||
|
||
if status: | ||
# status can only be True, False, or None | ||
if status is True: | ||
self.success += 1 | ||
elif status is None: # status is only ever None if file checksum matched an existing file checksum and is therefore a duplicate file | ||
This comment has been minimized.
Sorry, something went wrong.
D3Zyre
Author
Owner
|
||
self.duplicate += 1 | ||
self.duplicate_items.append(id) | ||
else: | ||
self.error += 1 | ||
self.error_items.append(id) | ||
|
||
def write(self): | ||
print("\n") | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if self.error > 0: | ||
error_headers = ["File"] | ||
error_result = [] | ||
|
@@ -29,10 +36,21 @@ def write(self): | |
print(tabulate(error_result, headers=error_headers)) | ||
print("\n") | ||
|
||
if self.duplicate > 0: | ||
This comment has been minimized.
Sorry, something went wrong.
D3Zyre
Author
Owner
|
||
duplicate_headers = ["File"] | ||
duplicate_result = [] | ||
for id in self.duplicate_items: | ||
duplicate_result.append([id]) | ||
|
||
print("****** DUPLICATE (NOT IMPORTED) DETAILS ******") | ||
print(tabulate(duplicate_result, headers=duplicate_headers)) | ||
print("\n") | ||
|
||
headers = ["Metric", "Count"] | ||
result = [ | ||
["Success", self.success], | ||
["Error", self.error], | ||
["Duplicate, not imported", self.duplicate] | ||
This comment has been minimized.
Sorry, something went wrong.
D3Zyre
Author
Owner
|
||
] | ||
|
||
print("****** SUMMARY ******") | ||
|
checksum, obtained from Db.checksum(), could never be None, hence no need to check for this