Skip to content

Commit

Permalink
refactor: Remove unused imports in load_toponyms.py
Browse files Browse the repository at this point in the history
This commit removes an unused import statement in the `load_toponyms.py` file. The import for `django.core.exceptions.ObjectDoesNotExist` is no longer needed and can be safely removed.

This change improves code cleanliness and removes unnecessary dependencies.
  • Loading branch information
hepplerj committed May 29, 2024
1 parent b317042 commit 3170545
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions manuscript/management/commands/load_toponyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

import numpy as np
import pandas as pd
from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand
from django.db import IntegrityError, transaction

from manuscript.models import Folio, Location, LocationAlias, SingleManuscript
from manuscript.models import Location, LocationAlias

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -52,18 +51,6 @@ def process_field(self, row, field_name, index, is_bool=False):
self.handle_error(index, e, row, field_name, row.get(field_name))
raise e

# def fetch_manuscript(self, siglum):
# try:
# return SingleManuscript.objects.get(siglum=siglum)
# except ObjectDoesNotExist as exc:
# raise ValueError(f"Manuscript with siglum '{siglum}' does not exist.") from exc

# def fetch_folio(self, folio_number, manuscript):
# try:
# return Folio.objects.get(folio_number=folio_number, manuscript=manuscript)
# except ObjectDoesNotExist as exc:
# raise ValueError(f"Folio with folio number '{folio_number}' does not exist.") from exc

def create_location(self, placename_id, country, description):
try:
location, created = Location.objects.get_or_create(
Expand Down Expand Up @@ -127,7 +114,6 @@ def load_data(self, filepath: str, sheet_name: str):
for sheet_name, df in dfs.items():
for index, row in df.iterrows():
placename_id = self.process_field(row, "place_id", index)
label = self.process_field(row, "label", index) # alias
histeng_name = self.process_field(row, "histeng_name", index)
description = self.process_field(row, "comments", index)

Expand All @@ -138,11 +124,5 @@ def load_data(self, filepath: str, sheet_name: str):
"Error creating location: %s", traceback.format_exc()
)

# if placename_from_mss is not None:
# try:
# location = Location.objects.get(placename_id=placename_id)
# self.create_location_alias(location, placename_from_mss)
# except ObjectDoesNotExist:
# logger.error("Error creating location alias: %s", traceback.format_exc())
except Exception as e:
raise e

0 comments on commit 3170545

Please sign in to comment.