diff --git a/news/cmds_to_cmds.rst b/news/cmds_to_cmds.rst new file mode 100644 index 000000000..e917a94a4 --- /dev/null +++ b/news/cmds_to_cmds.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* lists of commands now imported from commands.py + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/regolith/commands.py b/regolith/commands.py index 3ff636983..8374b89fd 100644 --- a/regolith/commands.py +++ b/regolith/commands.py @@ -12,6 +12,8 @@ from regolith.helper import HELPERS, helpr, UPDATER_HELPERS, FAST_UPDATER_WHITELIST from regolith.runcontrol import RunControl from regolith.tools import string_types +from regolith import storage + email = emailer @@ -21,6 +23,8 @@ INGEST_COLL_LU = {".bib": "citations"} + + def add_cmd(rc): """Adds documents to a collection in a database.""" db = rc.client[rc.db] @@ -264,3 +268,25 @@ def validate(rc): # # sys.exit(f"Validation failed on some records\n {cap}") sys.exit(f"Validation failed on some records") + +DISCONNECTED_COMMANDS = { + "rc": lambda rc: print(rc._pformat()), + "deploy": deploy, + "store": storage.main, + "json-to-yaml": json_to_yaml, + "yaml-to-json": yaml_to_json, +} + +CONNECTED_COMMANDS = { + "add": add_cmd, + "ingest": ingest, + "app": app, + "grade": grade, + "build": build, + "email": email, + "classlist": classlist, + "validate": validate, + "helper": helper, + "fs-to-mongo": fs_to_mongo, + "mongo-to-fs": mongo_to_fs +} diff --git a/regolith/helper_gui_main.py b/regolith/helper_gui_main.py index 949549022..0a7b7b5fa 100644 --- a/regolith/helper_gui_main.py +++ b/regolith/helper_gui_main.py @@ -12,20 +12,10 @@ from regolith.runcontrol import DEFAULT_RC, load_rcfile, filter_databases from regolith.schemas import SCHEMAS from regolith.tools import update_schemas +from regolith.commands import CONNECTED_COMMANDS + from gooey import Gooey, GooeyParser -CONNECTED_COMMANDS = { - "add": commands.add_cmd, - "ingest": commands.ingest, - "app": commands.app, - "grade": commands.grade, - "build": commands.build, - "email": commands.email, - "classlist": commands.classlist, - "validate": commands.validate, - "helper": commands.helper, - "fs-to-mongo": commands.fs_to_mongo -} NEED_RC = set(CONNECTED_COMMANDS.keys()) NEED_RC |= {"rc", "deploy", "store"} diff --git a/regolith/main.py b/regolith/main.py index 2cde84cec..d77578650 100644 --- a/regolith/main.py +++ b/regolith/main.py @@ -8,7 +8,6 @@ from regolith.database import connect from regolith import commands -from regolith import storage from regolith.builder import BUILDERS from regolith.commands import INGEST_COLL_LU from regolith.helper import HELPERS @@ -16,28 +15,7 @@ from regolith.schemas import SCHEMAS from regolith.tools import update_schemas from regolith import __version__ - -DISCONNECTED_COMMANDS = { - "rc": lambda rc: print(rc._pformat()), - "deploy": commands.deploy, - "store": storage.main, - "json-to-yaml": commands.json_to_yaml, - "yaml-to-json": commands.yaml_to_json, -} - -CONNECTED_COMMANDS = { - "add": commands.add_cmd, - "ingest": commands.ingest, - "app": commands.app, - "grade": commands.grade, - "build": commands.build, - "email": commands.email, - "classlist": commands.classlist, - "validate": commands.validate, - "helper": commands.helper, - "fs-to-mongo": commands.fs_to_mongo, - "mongo-to-fs": commands.mongo_to_fs -} +from regolith.commands import DISCONNECTED_COMMANDS, CONNECTED_COMMANDS NEED_RC = set(CONNECTED_COMMANDS.keys()) NEED_RC |= {"rc", "deploy", "store"} diff --git a/regolith/schemas.py b/regolith/schemas.py index 7cd1123e0..c53ee2805 100644 --- a/regolith/schemas.py +++ b/regolith/schemas.py @@ -6,6 +6,7 @@ from .sorters import POSITION_LEVELS + SORTED_POSITION = sorted(POSITION_LEVELS.keys(), key=POSITION_LEVELS.get) ACTIVITIES_TYPES = ["teaching", "research"]