mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 08:29:17 +02:00
Blacked the code
This commit is contained in:
parent
b6fc0051fa
commit
62ca3bd736
279 changed files with 8861 additions and 9527 deletions
|
@ -4,17 +4,20 @@ from funkwhale_api.common import scripts
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Run a specific script from funkwhale_api/common/scripts/'
|
||||
help = "Run a specific script from funkwhale_api/common/scripts/"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('script_name', nargs='?', type=str)
|
||||
parser.add_argument("script_name", nargs="?", type=str)
|
||||
parser.add_argument(
|
||||
'--noinput', '--no-input', action='store_false', dest='interactive',
|
||||
"--noinput",
|
||||
"--no-input",
|
||||
action="store_false",
|
||||
dest="interactive",
|
||||
help="Do NOT prompt the user for input of any kind.",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
name = options['script_name']
|
||||
name = options["script_name"]
|
||||
if not name:
|
||||
self.show_help()
|
||||
|
||||
|
@ -23,44 +26,44 @@ class Command(BaseCommand):
|
|||
script = available_scripts[name]
|
||||
except KeyError:
|
||||
raise CommandError(
|
||||
'{} is not a valid script. Run python manage.py script for a '
|
||||
'list of available scripts'.format(name))
|
||||
"{} is not a valid script. Run python manage.py script for a "
|
||||
"list of available scripts".format(name)
|
||||
)
|
||||
|
||||
self.stdout.write('')
|
||||
if options['interactive']:
|
||||
self.stdout.write("")
|
||||
if options["interactive"]:
|
||||
message = (
|
||||
'Are you sure you want to execute the script {}?\n\n'
|
||||
"Are you sure you want to execute the script {}?\n\n"
|
||||
"Type 'yes' to continue, or 'no' to cancel: "
|
||||
).format(name)
|
||||
if input(''.join(message)) != 'yes':
|
||||
if input("".join(message)) != "yes":
|
||||
raise CommandError("Script cancelled.")
|
||||
script['entrypoint'](self, **options)
|
||||
script["entrypoint"](self, **options)
|
||||
|
||||
def show_help(self):
|
||||
indentation = 4
|
||||
self.stdout.write('')
|
||||
self.stdout.write('Available scripts:')
|
||||
self.stdout.write('Launch with: python manage.py <script_name>')
|
||||
self.stdout.write("")
|
||||
self.stdout.write("Available scripts:")
|
||||
self.stdout.write("Launch with: python manage.py <script_name>")
|
||||
available_scripts = self.get_scripts()
|
||||
for name, script in sorted(available_scripts.items()):
|
||||
self.stdout.write('')
|
||||
self.stdout.write("")
|
||||
self.stdout.write(self.style.SUCCESS(name))
|
||||
self.stdout.write('')
|
||||
for line in script['help'].splitlines():
|
||||
self.stdout.write(' {}'.format(line))
|
||||
self.stdout.write('')
|
||||
self.stdout.write("")
|
||||
for line in script["help"].splitlines():
|
||||
self.stdout.write(" {}".format(line))
|
||||
self.stdout.write("")
|
||||
|
||||
def get_scripts(self):
|
||||
available_scripts = [
|
||||
k for k in sorted(scripts.__dict__.keys())
|
||||
if not k.startswith('__')
|
||||
k for k in sorted(scripts.__dict__.keys()) if not k.startswith("__")
|
||||
]
|
||||
data = {}
|
||||
for name in available_scripts:
|
||||
module = getattr(scripts, name)
|
||||
data[name] = {
|
||||
'name': name,
|
||||
'help': module.__doc__.strip(),
|
||||
'entrypoint': module.main
|
||||
"name": name,
|
||||
"help": module.__doc__.strip(),
|
||||
"entrypoint": module.main,
|
||||
}
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue