mirror of
https://github.com/frappe/bench.git
synced 2024-11-13 16:56:33 +00:00
refactor(minor): Use more readable alternatives
This commit is contained in:
parent
a84239d6ab
commit
af46fedc28
@ -1,4 +1,5 @@
|
||||
# imports - standard imports
|
||||
import contextlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
@ -99,12 +100,10 @@ def _generate_dev_deps_pattern(pyproject_path):
|
||||
requirements_pattern = ""
|
||||
pyroject_config = loads(open(pyproject_path).read())
|
||||
|
||||
try:
|
||||
with contextlib.suppress(KeyError):
|
||||
for pkg, version in pyroject_config["tool"]["bench"]["dev-dependencies"].items():
|
||||
op = "==" if "=" not in version else ""
|
||||
requirements_pattern += f"{pkg}{op}{version} "
|
||||
except KeyError:
|
||||
pass
|
||||
return requirements_pattern
|
||||
|
||||
|
||||
@ -222,9 +221,8 @@ def migrate_env(python, backup=False):
|
||||
|
||||
|
||||
def validate_upgrade(from_ver, to_ver, bench_path="."):
|
||||
if to_ver >= 6:
|
||||
if not which("npm") and not (which("node") or which("nodejs")):
|
||||
raise Exception("Please install nodejs and npm")
|
||||
if to_ver >= 6 and not which("npm") and not which("node") and not which("nodejs"):
|
||||
raise Exception("Please install nodejs and npm")
|
||||
|
||||
|
||||
def post_upgrade(from_ver, to_ver, bench_path="."):
|
||||
|
@ -54,7 +54,7 @@ class Rendering:
|
||||
return
|
||||
|
||||
_prefix = click.style("⏼", fg="bright_yellow")
|
||||
_hierarchy = " " if not self.is_parent else ""
|
||||
_hierarchy = "" if self.is_parent else " "
|
||||
self._title = self.title.format(**self.kw)
|
||||
click.secho(f"{_hierarchy}{_prefix} {self._title}")
|
||||
|
||||
@ -83,7 +83,7 @@ class Rendering:
|
||||
if l["message"] == self._title:
|
||||
l["prefix"] = self._prefix
|
||||
l["message"] = self._success
|
||||
_hierarchy = " " if not l["is_parent"] else ""
|
||||
_hierarchy = "" if l.get("is_parent") else " "
|
||||
click.secho(f'{_hierarchy}{l["prefix"]} {l["message"]}', fg=l["color"])
|
||||
|
||||
|
||||
|
@ -113,10 +113,7 @@ def setup_sudoers(user):
|
||||
if not os.path.exists("/etc/sudoers.d"):
|
||||
os.makedirs("/etc/sudoers.d")
|
||||
|
||||
set_permissions = False
|
||||
if not os.path.exists("/etc/sudoers"):
|
||||
set_permissions = True
|
||||
|
||||
set_permissions = not os.path.exists("/etc/sudoers")
|
||||
with open("/etc/sudoers", "a") as f:
|
||||
f.write("\n#includedir /etc/sudoers.d\n")
|
||||
|
||||
@ -142,11 +139,7 @@ def setup_sudoers(user):
|
||||
|
||||
|
||||
def start(no_dev=False, concurrency=None, procfile=None, no_prefix=False, procman=None):
|
||||
if procman:
|
||||
program = which(procman)
|
||||
else:
|
||||
program = get_process_manager()
|
||||
|
||||
program = which(procman) if procman else get_process_manager()
|
||||
if not program:
|
||||
raise Exception("No process manager found")
|
||||
|
||||
|
@ -43,7 +43,7 @@ def update_translations(app, lang):
|
||||
import requests
|
||||
|
||||
translations_dir = os.path.join("apps", app, app, "translations")
|
||||
csv_file = os.path.join(translations_dir, lang + ".csv")
|
||||
csv_file = os.path.join(translations_dir, f"{lang}.csv")
|
||||
url = f"https://translate.erpnext.com/files/{app}-{lang}.csv"
|
||||
r = requests.get(url, stream=True)
|
||||
r.raise_for_status()
|
||||
|
Loading…
Reference in New Issue
Block a user