Flake8
This commit is contained in:
committed by
Sébastien Corbin
parent
63c3d7d2dc
commit
382c824cca
16
.github/workflows/actions.yml
vendored
16
.github/workflows/actions.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
- '2.2'
|
- '2.2'
|
||||||
- '3.2'
|
- '3.2'
|
||||||
- '4.0'
|
- '4.0'
|
||||||
python_version:
|
python-version:
|
||||||
- 3.6
|
- 3.6
|
||||||
- 3.7
|
- 3.7
|
||||||
- 3.8
|
- 3.8
|
||||||
@@ -19,13 +19,13 @@ jobs:
|
|||||||
- "3.10"
|
- "3.10"
|
||||||
exclude:
|
exclude:
|
||||||
- django_version: '2.2'
|
- django_version: '2.2'
|
||||||
python_version: '3.10'
|
python-version: '3.10'
|
||||||
|
|
||||||
- django_version: '4.0'
|
- django_version: '4.0'
|
||||||
python_version: '3.6'
|
python-version: '3.6'
|
||||||
|
|
||||||
- django_version: '4.0'
|
- django_version: '4.0'
|
||||||
python_version: '3.7'
|
python-version: '3.7'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -33,17 +33,17 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python_version: ${{ matrix.python_version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Cache pip
|
- name: Cache pip
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
# This path is specific to Ubuntu
|
# This path is specific to Ubuntu
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip-${{ matrix.python_version }}-${{ matrix.django_version }}
|
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.django_version }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -58,7 +58,7 @@ jobs:
|
|||||||
- name: Test Django
|
- name: Test Django
|
||||||
run: |
|
run: |
|
||||||
python -W error::DeprecationWarning -W error::PendingDeprecationWarning \
|
python -W error::DeprecationWarning -W error::PendingDeprecationWarning \
|
||||||
-m coverage run runtests.py
|
-m coverage run ./runtests.py
|
||||||
|
|
||||||
- name: Coverage
|
- name: Coverage
|
||||||
if: ${{ success() }}
|
if: ${{ success() }}
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ def draw_signature(data, as_file=False):
|
|||||||
`data` can be a json object (list in fact) or a json string
|
`data` can be a json object (list in fact) or a json string
|
||||||
if `as_file` is True, a temp file is returned instead of Image instance
|
if `as_file` is True, a temp file is returned instead of Image instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _remove_empty_pts(pt):
|
def _remove_empty_pts(pt):
|
||||||
return {'x': list(filter(lambda n: n is not None, pt['x'])), 'y': list(filter(lambda n: n is not None, pt['y']))}
|
return {
|
||||||
|
'x': list(filter(lambda n: n is not None, pt['x'])),
|
||||||
|
'y': list(filter(lambda n: n is not None, pt['y']))
|
||||||
|
}
|
||||||
|
|
||||||
if type(data) is str:
|
if type(data) is str:
|
||||||
drawing = json.loads(data, object_hook=_remove_empty_pts)
|
drawing = json.loads(data, object_hook=_remove_empty_pts)
|
||||||
@@ -29,13 +33,13 @@ def draw_signature(data, as_file=False):
|
|||||||
height = int(round(max(chain(*[d['y'] for d in drawing])))) + 10
|
height = int(round(max(chain(*[d['y'] for d in drawing])))) + 10
|
||||||
|
|
||||||
# Draw image
|
# Draw image
|
||||||
im = Image.new("RGBA", (width*AA, height*AA))
|
im = Image.new("RGBA", (width * AA, height * AA))
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
for line in drawing:
|
for line in drawing:
|
||||||
len_line = len(line['x'])
|
len_line = len(line['x'])
|
||||||
points = [(line['x'][i]*AA, line['y'][i]*AA)
|
points = [(line['x'][i] * AA, line['y'][i] * AA)
|
||||||
for i in range(0, len_line)]
|
for i in range(0, len_line)]
|
||||||
draw.line(points, fill="#000", width=2*AA)
|
draw.line(points, fill="#000", width=2 * AA)
|
||||||
im = ImageOps.expand(im)
|
im = ImageOps.expand(im)
|
||||||
# Smart crop
|
# Smart crop
|
||||||
bbox = im.getbbox()
|
bbox = im.getbbox()
|
||||||
|
|||||||
Reference in New Issue
Block a user