Skip to content

Commit a2867a9

Browse files
committed
Remove progressbar dependency
1 parent 8e3ee5b commit a2867a9

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
runs-on: ubuntu-latest
6565
steps:
6666
- name: Install gettext
67-
run: sudo apt-get install gettext -y
67+
run: sudo apt install gettext -y
6868
- uses: actions/setup-python@v2.2.1
6969
- run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
7070
- uses: actions/checkout@v2.3.4
@@ -89,16 +89,20 @@ jobs:
8989
- "2.2"
9090
- "3.1"
9191
- "3.2rc1"
92+
extra:
93+
- ""
94+
- "progressbar"
9295
steps:
9396
- name: Set up Python ${{ matrix.python-version }}
9497
uses: actions/setup-python@v2.2.1
9598
with:
9699
python-version: ${{ matrix.python-version }}
100+
- run: sudo apt install gettext -y
97101
- uses: actions/checkout@v2.3.4
98-
- name: Install dependencies
99-
run: |
100-
python -m pip install --upgrade pip setuptools codecov
101-
pip install django~=${{ matrix.django-version }}
102+
- run: python -m pip install --upgrade pip setuptools codecov wheel
103+
- run: python -m pip install .[${{ matrix.extra }}]
104+
if: ${{ matrix.extra }}
105+
- run: python -m pip install django~=${{ matrix.django-version }}
102106
- name: Test with pytest
103107
run: python setup.py test
104108
- run: codecov

setup.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ packages = stdimage
3636
install_requires =
3737
Django>=2.2
3838
pillow>=2.5
39-
progressbar2>=3.0.0
39+
4040
setup_requires =
4141
setuptools_scm
4242
pytest-runner
@@ -52,6 +52,9 @@ tests_require =
5252
exclude =
5353
tests
5454

55+
[options.extras_require]
56+
progressbar = progressbar2>=3.0.0
57+
5558
[bdist_wheel]
5659
universal = 1
5760

stdimage/management/commands/rendervariations.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import progressbar
21
from django.apps import apps
32
from django.core.files.storage import get_storage_class
43
from django.core.management import BaseCommand, CommandError
@@ -59,8 +58,7 @@ def handle(self, *args, **options):
5958

6059
self.render(field, images, count, replace, ignore_missing, do_render)
6160

62-
@staticmethod
63-
def render(field, images, count, replace, ignore_missing, do_render):
61+
def render(self, field, images, count, replace, ignore_missing, do_render):
6462
kwargs_list = (
6563
dict(
6664
file_name=file_name,
@@ -73,20 +71,26 @@ def render(field, images, count, replace, ignore_missing, do_render):
7371
)
7472
for file_name in images
7573
)
76-
with progressbar.ProgressBar(
77-
max_value=count,
78-
widgets=(
79-
progressbar.RotatingMarker(),
80-
" | ",
81-
progressbar.AdaptiveETA(),
82-
" | ",
83-
progressbar.Percentage(),
84-
" ",
85-
progressbar.Bar(),
86-
),
87-
) as bar:
88-
for _ in map(render_field_variations, kwargs_list):
89-
bar += 1
74+
try:
75+
import progressbar
76+
except ImportError:
77+
for file_name in map(render_field_variations, kwargs_list):
78+
self.stdout.write(f"Processing: {file_name}", self.style.NOTICE)
79+
else:
80+
with progressbar.ProgressBar(
81+
max_value=count,
82+
widgets=(
83+
progressbar.RotatingMarker(),
84+
" | ",
85+
progressbar.AdaptiveETA(),
86+
" | ",
87+
progressbar.Percentage(),
88+
" ",
89+
progressbar.Bar(),
90+
),
91+
) as bar:
92+
for _ in map(render_field_variations, kwargs_list):
93+
bar += 1
9094

9195

9296
def render_field_variations(kwargs):
@@ -101,7 +105,9 @@ def render_field_variations(kwargs):
101105
render_variations(**kwargs)
102106
except FileNotFoundError as e:
103107
if not ignore_missing:
108+
print(ignore_missing)
104109
raise CommandError(
105110
"Source file was not found, terminating. "
106111
"Use -i/--ignore-missing to skip this error."
107112
) from e
113+
return kwargs["file_name"]

0 commit comments

Comments
 (0)