Move box generators into boxes.generators sub module
This commit is contained in:
parent
be6b02fe6f
commit
70bb1bf5af
|
@ -0,0 +1,24 @@
|
|||
|
||||
__all__ = [
|
||||
"box",
|
||||
"box2",
|
||||
"box3",
|
||||
"castle",
|
||||
"drillbox",
|
||||
"flexbox",
|
||||
"flexbox2",
|
||||
"flexbox3",
|
||||
"flextest",
|
||||
"folder",
|
||||
"lamp",
|
||||
"magazinefile",
|
||||
"silverwarebox",
|
||||
"trayinsert",
|
||||
"traylayout",
|
||||
"typetray",
|
||||
]
|
||||
|
||||
def getAllBoxGenerators():
|
||||
import importlib
|
||||
return {name: importlib.import_module("boxes.generators." + name)
|
||||
for name in __all__}
|
|
@ -5,7 +5,13 @@ import os
|
|||
import sys
|
||||
from pprint import pprint
|
||||
|
||||
import boxes
|
||||
try:
|
||||
import boxes
|
||||
except ImportError:
|
||||
sys.path.append(os.path.dirname(__file__) + "/..")
|
||||
import boxes
|
||||
|
||||
import boxes.generators
|
||||
|
||||
def printusage():
|
||||
print("""Usage:
|
||||
|
@ -15,14 +21,7 @@ boxes [NAME] [options]
|
|||
""")
|
||||
|
||||
def main():
|
||||
modules = {}
|
||||
for module in os.listdir(os.path.dirname(__file__)):
|
||||
if module in ('__init__.py', 'boxes.py', 'bserver.py') or module[-3:] != '.py':
|
||||
continue
|
||||
name = module[:-3]
|
||||
module = __import__(name, locals(), globals())
|
||||
modules[name] = module
|
||||
#pprint(modules)
|
||||
modules = boxes.generators.getAllBoxGenerators()
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
printusage()
|
||||
|
@ -35,5 +34,7 @@ def main():
|
|||
print("Available generators:")
|
||||
for name in sorted(modules):
|
||||
print(" * ", name)
|
||||
else:
|
||||
print("unknown sub command")
|
||||
|
||||
main()
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import boxes
|
||||
import sys
|
||||
import argparse
|
||||
import cgi
|
||||
|
@ -12,8 +11,16 @@ from wsgiref.util import setup_testing_defaults
|
|||
from wsgiref.simple_server import make_server
|
||||
import wsgiref.util
|
||||
|
||||
import box, box2, box3, drillbox, flexbox, flexbox2, flexbox3, flextest, folder
|
||||
import magazinefile, trayinsert, traylayout, typetray, silverwarebox
|
||||
try:
|
||||
import boxes.generators
|
||||
except ImportError:
|
||||
sys.path.append(os.path.dirname(__file__) + "/..")
|
||||
import boxes.generators
|
||||
|
||||
|
||||
from boxes.generators import box, box2, box3, drillbox
|
||||
from boxes.generators import flexbox, flexbox2, flexbox3, flextest, folder
|
||||
from boxes.generators import magazinefile, trayinsert, traylayout, typetray, silverwarebox
|
||||
|
||||
|
||||
class ArgumentParserError(Exception): pass
|
Loading…
Reference in New Issue