Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: call _fetch_item from _process_image for easier override #4280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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 @@
# 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