Skip to content

Commit

Permalink
Update formatting commands in package.json and pyproject.toml; refact…
Browse files Browse the repository at this point in the history
…or indentation in Python scripts for consistency
  • Loading branch information
mauro-balades committed Jan 12, 2025
1 parent 225ab67 commit 9775e1c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"update-ff": "python3 scripts/update_ff.py",
"update-ff:raw": "surfer update",
"update-newtab": "python3 scripts/update_newtab.py",
"pretty": "prettier . --write && autopep8 -r scripts/ --in-place",
"lint": "npx prettier . --check && autopep8 --diff -r scripts/",
"pretty": "prettier . --write && autopep8 -r --in-place scripts/ src/",
"lint": "npx prettier . --check && autopep8 --diff scripts/ src/",
"prepare": "husky"
},
"repository": {
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[tool.autopep8]
max_line_length = 120
ignore = "E501,W6" # or ["E501", "W6"]
recursive = true
aggressive = 3
indent_size = 2
1 change: 1 addition & 0 deletions scripts/check-rc-response.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ def main() -> int:
print(f"Current version: {current_version}, RC version: {rc_response}")
return 1


if __name__ == "__main__":
sys.exit(main())
60 changes: 30 additions & 30 deletions src/browser/base/content/zen-avatars/fetch-all-avatars.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,51 @@


def random_string(length):
return "".join(random.choices("abcdefghijklmnopqrstuvwxyz", k=length))
return "".join(random.choices("abcdefghijklmnopqrstuvwxyz", k=length))


def generate_list_names():
names = []
for i in range(1, 101):
names.append(random_string(random.randint(5, 10)))
return names
names = []
for i in range(1, 101):
names.append(random_string(random.randint(5, 10)))
return names


def write_jar_file(jar_file):
with open("jar.inc.mn", "w") as f:
f.write(jar_file)
with open("jar.inc.mn", "w") as f:
f.write(jar_file)


def fetch_all_avatars():
names = generate_list_names()
jar_file = ""
for theme in COLORS:
for [i, name] in enumerate(names):
url = URL.format(name, ",".join(COLORS[theme]))
response = requests.get(url)
with open(f"avatar-{i}-{theme}.svg", "w") as f:
f.write(response.text)
jar_file += JAR_ENTRY_TEMPLATE.format(f"avatar-{i}-{theme}.svg") + "\n"
print(
f"SUCCESS: Fetched 'avatar-{i}-{theme}.svg' for name '{name}' with theme '{theme}'"
)
write_jar_file(jar_file)
names = generate_list_names()
jar_file = ""
for theme in COLORS:
for [i, name] in enumerate(names):
url = URL.format(name, ",".join(COLORS[theme]))
response = requests.get(url)
with open(f"avatar-{i}-{theme}.svg", "w") as f:
f.write(response.text)
jar_file += JAR_ENTRY_TEMPLATE.format(f"avatar-{i}-{theme}.svg") + "\n"
print(
f"SUCCESS: Fetched 'avatar-{i}-{theme}.svg' for name '{name}' with theme '{theme}'"
)
write_jar_file(jar_file)


def clear_all_avatars():
for file in os.listdir():
if file.startswith("avatar-") and file.endswith(".svg"):
os.remove(file)
print(f"SUCCESS: Removed '{file}'")
for file in os.listdir():
if file.startswith("avatar-") and file.endswith(".svg"):
os.remove(file)
print(f"SUCCESS: Removed '{file}'")


def main():
if not os.getcwd().endswith("zen-avatars"):
print("ERROR: Please run this script from the 'zen-avatars' directory")
return
clear_all_avatars()
fetch_all_avatars()
if not os.getcwd().endswith("zen-avatars"):
print("ERROR: Please run this script from the 'zen-avatars' directory")
return
clear_all_avatars()
fetch_all_avatars()


if __name__ == "__main__":
main()
main()

0 comments on commit 9775e1c

Please sign in to comment.