Skip to content

Commit

Permalink
minor code syntax cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem committed Jan 5, 2025
1 parent 50855aa commit 161a4e9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
4 changes: 1 addition & 3 deletions gridsplitter/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@


from PIL import Image
from PIL import ImageChops
from PIL import ImageFilter
from PIL import ImageDraw
from PIL import ImageOps
from math import hypot
Expand Down Expand Up @@ -199,7 +197,7 @@ def FindRow(dots, tlDotIndex, rowNum):

# Keep track of the bottom-left point of the first quad so we can return it later
blPoint = None
if len(quadIndices) > 1 and quadIndices[1] != None:
if len(quadIndices) > 1 and quadIndices[1] is not None:
blPoint = quadIndices[1]

# Start looking for more of 'em
Expand Down
6 changes: 2 additions & 4 deletions waznexserver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, upload_dt, filename):
self.level = IMAGELEVEL_NOTHING

def __repr__(self):
return '<id:{} filename:{} status:{} level:{}>'.format(self.id, self.filename, self.status, self.level)
return f'<id:{self.id} filename:{self.filename} status:{self.status} level:{self.level}>'

def get_thumbnail_path(self):
return os.path.join(app.config['THUMBNAIL_FOLDER'], self.filename)
Expand Down Expand Up @@ -101,6 +101,4 @@ def __init__(self, grid_item, filename, col, row):
self.row = row

def __repr__(self):
return '<id:{} part_of:{} filename: {} col:{} row:{}>'.format(
self.id, self.grid_item, self.filename, self.col, self.row
)
return f'<id:{self.id} part_of:{self.grid_item} filename: {self.filename} col:{self.col} row:{self.row}>'
3 changes: 1 addition & 2 deletions waznexserver/process_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import shutil
import subprocess
import sys
import traceback

from PIL import Image
Expand Down Expand Up @@ -32,7 +31,7 @@ def run_basic_transforms(grid_image):
thumb.save(grid_image.get_thumbnail_path(), "JPEG")

except Exception:
print("Error while performing basic transforms on {}".format(grid_image.filename))
print(f"Error while performing basic transforms on {grid_image.filename}")
traceback.print_exc()
return False

Expand Down
5 changes: 1 addition & 4 deletions waznexserver/waznexserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ def upload_file():
upload_ts = datetime.datetime.utcnow()
filename_name, filename_ext = os.path.splitext(f.filename)
clean_filename = filename_name.replace('.', '') + filename_ext
filename = ('%sF%s') % (
upload_ts.strftime(app.config['FILE_NAME_DT_FORMAT']),
secure_filename(clean_filename),
)
filename = upload_ts.strftime(app.config["FILE_NAME_DT_FORMAT"]) + 'F' + secure_filename(clean_filename)
f.save(os.path.join(app.config['IMAGE_FOLDER'], filename))
# Initialize GridItem and add it to the list
grid_item = models.GridItem(upload_ts, filename)
Expand Down

0 comments on commit 161a4e9

Please sign in to comment.