Skip to content

Commit

Permalink
fix: call _fetch_item from _process_image for easier override
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie Rymer committed Apr 22, 2024
1 parent 992e1c6 commit 7772c4c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/oscar/apps/catalogue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def handle(self, dirname):
for filename in filenames:
try:
lookup_value = self._get_lookup_value_from_filename(filename)
self._process_image(image_dir, filename, lookup_value)
self._process_image(image_dir, filename)

Check warning on line 42 in src/oscar/apps/catalogue/utils.py

View check run for this annotation

Codecov / codecov/patch

src/oscar/apps/catalogue/utils.py#L42

Added line #L42 was not covered by tests
stats["num_processed"] += 1
except Product.MultipleObjectsReturned:
self.logger.warning(
Expand Down Expand Up @@ -121,13 +121,12 @@ def _extract_images(self, dirname):
# unknown archive - perhaps this should be treated differently
return ""

def _process_image(self, dirname, filename, lookup_value):
def _process_image(self, dirname, filename):

Check warning on line 124 in src/oscar/apps/catalogue/utils.py

View check run for this annotation

Codecov / codecov/patch

src/oscar/apps/catalogue/utils.py#L124

Added line #L124 was not covered by tests
file_path = os.path.join(dirname, filename)
trial_image = Image.open(file_path)
trial_image.verify()

kwargs = {self._field: lookup_value}
item = Product._default_manager.get(**kwargs)
item = self._fetch_item(filename)

Check warning on line 129 in src/oscar/apps/catalogue/utils.py

View check run for this annotation

Codecov / codecov/patch

src/oscar/apps/catalogue/utils.py#L129

Added line #L129 was not covered by tests

new_data = open(file_path, "rb").read()
next_index = 0
Expand Down

0 comments on commit 7772c4c

Please sign in to comment.