Lint code

This commit is contained in:
Rotzbua 2023-04-27 23:45:06 +02:00 committed by Florian Festi
parent 86a8bf481d
commit 8a62293a47
5 changed files with 61 additions and 45 deletions

View File

@ -27,6 +27,7 @@ except ImportError:
import boxes.generators
# __version__ = get_distribution('boxes').version
@ -45,9 +46,11 @@ def main():
name = name[12:]
run_generator(name, sys.argv[2:])
def print_usage():
print(__doc__)
def list_grouped_generators():
print('Available generators:')
for group in generator_groups():
@ -59,12 +62,14 @@ def list_grouped_generators():
for box in group.generators:
print(' * {} - {}'.format(box.__name__, box.__doc__ or ''))
def get_translation():
try:
return gettext.translation('boxes.py', localedir='locale')
except OSError:
return gettext.translation('boxes.py', fallback=True)
def run_generator(name, args):
generators = generators_by_name()
lower_name = name.lower()

View File

@ -25,6 +25,7 @@ except ImportError:
sys.path.append(os.path.dirname(__file__) + "/..")
import boxes.generators
class Boxes2INX:
def __init__(self) -> None:
self.boxes = {b.__name__: b() for b in boxes.generators.getAllBoxGenerators().values() if b.webinterface}
@ -145,6 +146,7 @@ class Boxes2INX:
continue
self.writeINX(name, box, path)
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: boxes2inkscape TARGETPATH")

View File

@ -27,6 +27,7 @@ except ImportError:
import boxes.generators
from boxes import edges, lids
class DefaultParams(boxes.Boxes):
def __init__(self) -> None:
@ -41,6 +42,7 @@ class DefaultParams(boxes.Boxes):
self.addSettingsArgs(edges.FlexSettings)
self.addSettingsArgs(lids.LidSettings)
class Boxes2pot:
def __init__(self) -> None:
self.messages: list[Any] = []
@ -135,6 +137,7 @@ msgstr ""
f.write(' "%s"\n' % m.replace('"', '\\"'))
f.write('msgstr ""\n')
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: boxes2pot TARGETPATH")

View File

@ -19,6 +19,7 @@ from lxml import etree
import tempfile
from shlex import quote
class boxesPyWrapper(inkex.GenerateExtension):
def add_arguments(self, pars):
@ -72,5 +73,6 @@ class boxesPyWrapper(inkex.GenerateExtension):
group.append(element)
return group
if __name__ == '__main__':
boxesPyWrapper().run()

View File

@ -81,6 +81,7 @@ class FileChecker(threading.Thread):
def stop(self) -> None:
self._stopped = True
def filter_url(url, non_default_args):
if len(url) == 0:
return ''
@ -102,6 +103,7 @@ def filter_url(url, non_default_args):
else:
return f"{base}"
class ArgumentParserError(Exception): pass
@ -671,6 +673,7 @@ class BServer:
os.remove(box.output)
return (l for l in result)
def get_qrcode(url, format):
if url is None:
url = "no url"
@ -679,6 +682,7 @@ def get_qrcode(url, format):
img.save(image_bytes, format=format)
return image_bytes.getvalue()
if __name__ == "__main__":
parser = argparse.ArgumentParser()