Skip to content

Commit

Permalink
add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
elvira-cheng committed Sep 19, 2024
1 parent 876acd2 commit 0a948f1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions metadata_updater/metadata_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def get_metadata(layer, dir, overwrite):
try:
layer.metadata.get_xml(file_destination)
return file_destination
except:
print("No Metadata Found for: ", layer)
except Exception as e:
logger.error(f"No Metadata Found for: {layer}. Error: {e}")


def update_metadata(dest_file, mapping):
Expand All @@ -156,7 +156,7 @@ def update_metadata(dest_file, mapping):
Note. back up taken of the original file
"""

with fileinput.FileInput(dest_file, inplace=True, encoding='utf-8') as file:
with fileinput.FileInput(dest_file, inplace=True) as file:
for line in file:
if mapping['ignore_case']:
line = re.sub(mapping['search'], mapping['replace'], line.rstrip(), flags=re.IGNORECASE)
Expand Down Expand Up @@ -343,8 +343,8 @@ def file_has_text(search_text, ignore_case, file):
if match:
return True
return False
except:
print("No file found")
except FileNotFoundError as e:
logger.error(f"File not found: {file}. Error: {e}")

def create_backup(file, overwrite=False):
"""
Expand Down

0 comments on commit 0a948f1

Please sign in to comment.