Skip to content

Commit

Permalink
this wont fix the api but might fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
HoodieRocks committed Jan 5, 2024
1 parent d14096b commit ac09c08
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F", "PERF", "RUF", "B", "N", "PTH", "TCH", "UP"]
select = ["E", "F", "PERF", "RUF", "B", "N", "PTH", "TCH", "UP", "FURB", "ERA"]
ignore = ["E501", "E722"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
Expand Down
7 changes: 3 additions & 4 deletions utilities/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ def upload_file(file: str, file_name: str, uploader: str, is_icon: bool = False)
decoded = base64.b64decode(file.split(",")[1].encode("unicode_escape"))
path = Path(config.DATA + "tempfile")

path.touch()

if path.stat().st_size > 255999:
if len(decoded) > 255999:
return "File too big."


path.touch()
path.write_bytes(decoded)

if is_icon:
Expand Down
20 changes: 0 additions & 20 deletions utilities/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,6 @@ def send_notif(conn: Connection, title: str, msg: str, receiver: int):
)


# Custom sorting function for semver
def semver_key(version: str) -> tuple[int, int, int]:
# Replace 'x' in the version with a high number for comparison
version = version.replace("x", "999999")
# Use regex to match major, minor, and patch numbers
match = re.match(r"(\d+)(?:\.(\d+))?(?:\.(\d+))?", version)

if match:
# If there is a match, extract major, minor, and patch numbers
groups = map(int, match.groups())
return (
groups[0],
groups[1] if len(groups) >= 2 else 0,
groups[2] if len(groups) == 3 else 0,
)
else:
# If no match is found, return a tuple of zeros
return 0, 0, 0


if __name__ == "__main__":
weblogs.approval(
"Silabear",
Expand Down

0 comments on commit ac09c08

Please sign in to comment.