Skip to content

Commit

Permalink
lint: fix line size
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhrajitPrusty committed Oct 28, 2023
1 parent c1237ce commit 2a05e2a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
12 changes: 9 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@


def allowed_file(filename):
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
return (
"." in filename
and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
)


@app.route("/", methods=["GET"])
Expand Down Expand Up @@ -203,7 +206,8 @@ def pic():
else:
scale = 1
img = og_img.resize(
(width // scale, height // scale), resample=Image.BICUBIC
(width // scale, height // scale),
resample=Image.BICUBIC,
)
width = img.width
height = img.height
Expand Down Expand Up @@ -242,7 +246,9 @@ def pic():
# print(fpath)
img.save(fpath)
imgurl = url_for("static", filename="images/" + fname)
return render_template("download.html", context=imgurl, home="pic")
return render_template(
"download.html", context=imgurl, home="pic"
)
else:
error = "Invalid input, try again"
return render_template("error.html", context=error)
Expand Down
3 changes: 2 additions & 1 deletion tools/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def genSmartPoints(image):

# get a n/5 number of points rather than all of the points
sample = np.random.choice(
len(edges_data), len(edges_data) // 5 if len(edges_data) / 5 < 50000 else 50000
len(edges_data),
len(edges_data) // 5 if len(edges_data) / 5 < 50000 else 50000,
)
edges_data = [edges_data[x] for x in sample]

Expand Down
25 changes: 20 additions & 5 deletions tools/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def drawSlants(side, gradient=False, invert=False):


def genPoly(width, height, img, points, wshift, hshift, outl=None, pic=False):
baseImg = Image.new("RGB", (width + (wshift * 2), height + (hshift * 2)), "#000000")
baseImg = Image.new(
"RGB", (width + (wshift * 2), height + (hshift * 2)), "#000000"
)

baseImg.paste(img, box=(wshift, hshift))
bw = baseImg.width
Expand Down Expand Up @@ -163,7 +165,12 @@ def genSquares(width, height, img, outl=None, pic=False, per=1):

for i in range(hboxes):
for j in range(wboxes):
points = [(x, y), (x, y + inc), (x + inc, y + inc), (x + inc, y)] # squares
points = [
(x, y),
(x, y + inc),
(x + inc, y + inc),
(x + inc, y),
] # squares

a, b = (x + x + inc) // 2, (y + y + inc) // 2 # to get pixel data
try: # adj to not overflow
Expand Down Expand Up @@ -224,7 +231,10 @@ def genHexagon(width, height, img, outl=None, pic=False, per=1):
for i in range(-1, hboxes + 1):
for j in range(-1, wboxes + 2):
points = [
((x + radius * math.sin(k * ang)), (y + radius * math.cos(k * ang)))
(
(x + radius * math.sin(k * ang)),
(y + radius * math.cos(k * ang)),
)
for k in range(6)
]

Expand Down Expand Up @@ -288,7 +298,10 @@ def genIsometric(width, height, img, outl=None, pic=False, per=1):
for i in range(-1, hboxes + 1):
for j in range(wboxes + 2):
points = [
((x + radius * math.sin(k * ang)), (y + radius * math.cos(k * ang)))
(
(x + radius * math.sin(k * ang)),
(y + radius * math.cos(k * ang)),
)
for k in range(6)
]
# to store the vertices of the individual equilateral triangles
Expand Down Expand Up @@ -316,7 +329,9 @@ def genIsometric(width, height, img, outl=None, pic=False, per=1):
if outl:
for k in range(6):
# draw 6 triangles that form a hexagon
draw.polygon((triangle_points[k]), fill=c[k], outline=outl)
draw.polygon(
(triangle_points[k]), fill=c[k], outline=outl
)
else:
for k in range(6):
# draw 6 triangles that form a hexagon
Expand Down
8 changes: 6 additions & 2 deletions tools/wallpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def disown(cmd):
disown(
[
"awesome-client",
"require('gears').wallpaper.maximized('" + image_path + "')",
"require('gears').wallpaper.maximized('"
+ image_path
+ "')",
]
)
else:
Expand All @@ -124,7 +126,9 @@ def disown(cmd):
return msg, False
elif "darwin" in host:
db_file = "Library/Application Support/Dock/desktoppicture.db"
db_path = os.path.join(os.getenv("HOME", os.getenv("USERPROFILE")), db_file)
db_path = os.path.join(
os.getenv("HOME", os.getenv("USERPROFILE")), db_file
)
img_dir, _ = os.path.split(image_path)
sql = "delete from data; "
sql += 'insert into data values("%s"); ' % img_dir
Expand Down
20 changes: 15 additions & 5 deletions wallgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def cli():
@click.option(
"--only-color", "-oc", is_flag=True, help="Generate just a gradient image"
)
@click.option("--use-nn", "-un", is_flag=True, help="Use NbyNGradient function")
@click.option(
"--use-nn", "-un", is_flag=True, help="Use NbyNGradient function"
)
@click.option(
"--swirl",
"-sw",
Expand Down Expand Up @@ -171,7 +173,9 @@ def poly(

if swirl:
if only_color:
img = img.resize((side // scale, side // scale), resample=Image.BICUBIC)
img = img.resize(
(side // scale, side // scale), resample=Image.BICUBIC
)
img = swirl_image(img, swirl)

if not only_color:
Expand All @@ -195,7 +199,9 @@ def poly(

print("\r", end="")
print("Making final tweaks", end="")
img = img.resize((side // scale, side // scale), resample=Image.BICUBIC)
img = img.resize(
(side // scale, side // scale), resample=Image.BICUBIC
)

if show:
img.show()
Expand Down Expand Up @@ -265,7 +271,9 @@ def poly(
metavar="/path/to/output_file",
help="Rename the output file",
)
@click.option("--use-nn", "-un", is_flag=True, help="Use NbyNGradient function")
@click.option(
"--use-nn", "-un", is_flag=True, help="Use NbyNGradient function"
)
@click.option(
"--swirl",
"-sw",
Expand Down Expand Up @@ -614,7 +622,9 @@ def pic_poly(image, points, show, outline, name, smart, set_wall):
metavar="#HEXCODE",
help="Outline the shapes",
)
@click.option("--name", "-n", metavar="/path/to/output_file", help="Rename the output")
@click.option(
"--name", "-n", metavar="/path/to/output_file", help="Rename the output"
)
@click.option(
"--set-wall",
"-w",
Expand Down

0 comments on commit 2a05e2a

Please sign in to comment.