diff --git a/.github/workflows/mepo.yaml b/.github/workflows/mepo.yaml index 4e7710c2..50206b9d 100644 --- a/.github/workflows/mepo.yaml +++ b/.github/workflows/mepo.yaml @@ -27,5 +27,5 @@ jobs: timeout-minutes: 5 - name: Run unit tests - run: python3 mepo.d/utest/test_mepo_commands.py -v + run: python3 tests/test_mepo_commands.py -v timeout-minutes: 5 diff --git a/.gitignore b/.gitignore index 2f836aac..3ce728f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ *~ *.pyc +*.egg-info +dist +venv \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b26be00..844940d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `pyproject.toml` to aid with `pip` installation. + ### Changed -### Removed +- Converted `mepo` to a Python project via the following renaming + -- `mepo.d` -> `src/mepo` + -- `mepo.d/utest` -> `tests` + -- `doc` --> `docs` +- Helper script `mepo`, used for development, moved to the `bin` directory. ## [1.52.0] - 2024-01-10 diff --git a/bin/mepo b/bin/mepo new file mode 100755 index 00000000..9037d7de --- /dev/null +++ b/bin/mepo @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import os +import sys +import traceback + +# Version check +if sys.version_info < (3, 9, 0): + sys.exit('ERROR: Python version needs to be >= 3.6.0') + +# Add direactory containing mepo to path +SRC_D = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'src') +sys.path.insert(0, SRC_D) + +if __name__ == '__main__': + from mepo.main import main + main() diff --git a/doc/.gitignore b/docs/.gitignore similarity index 100% rename from doc/.gitignore rename to docs/.gitignore diff --git a/doc/make_md_docs.py b/docs/make_md_docs.py similarity index 88% rename from doc/make_md_docs.py rename to docs/make_md_docs.py index c8a19619..07ba6d08 100644 --- a/doc/make_md_docs.py +++ b/docs/make_md_docs.py @@ -13,12 +13,12 @@ doc_dir_path = os.path.dirname(os.path.realpath(__file__)) # Then we need to get to the mepo/mepo.d/command directory. First the "main" dir main_dir_path = os.path.dirname(doc_dir_path) -# Now add 'mepo.d' -mepod_dir_path = os.path.join(main_dir_path,'mepo.d') +# Now add 'src/mepo' +mepod_dir_path = os.path.join(main_dir_path, 'src', 'mepo') # And then 'command' -command_dir_path = os.path.join(mepod_dir_path,'command') +command_dir_path = os.path.join(mepod_dir_path, 'command') -mepo_command_path = os.path.join(main_dir_path,'mepo') +mepo_command_path = os.path.join(main_dir_path, 'bin', 'mepo') def get_command_list(directory): # Walk the tree @@ -50,12 +50,12 @@ def get_command_list(directory): return sorted(all_useful_commands) def create_markdown_from_usage(command, mdFile): - cmd = [mepo_command_path,command,'--help'] + cmd = [mepo_command_path, command, '--help'] # Some commands have spaces, so we need to break it up again cmd = ' '.join(cmd).split() - result = sp.run(cmd,capture_output=True,universal_newlines=True,env={'COLUMNS':'256'}) + result = sp.run(cmd, capture_output=True, universal_newlines=True, env={'COLUMNS':'256'}) output = result.stdout output_list = output.split("\n") @@ -84,7 +84,7 @@ def create_markdown_from_usage(command, mdFile): if __name__ == "__main__": - doc_file='Mepo-Commands.md' + doc_file = 'Mepo-Commands.md' mdFile = MdUtils(file_name=doc_file) mdFile.new_header(level=1, title="Overview") @@ -99,4 +99,3 @@ def create_markdown_from_usage(command, mdFile): mdFile.new_table_of_contents(table_title='Table of Contents', depth=2) mdFile.create_md_file() print(f'Generated {doc_file}.') - diff --git a/mepo b/mepo deleted file mode 100755 index c53176fe..00000000 --- a/mepo +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import traceback - -# Version check -if sys.version_info < (3, 6, 0): - sys.exit('ERROR: Python version needs to be >= 3.6.0') - -# Add mepo.d to path -MEPO_D = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mepo.d') -sys.path.insert(0, MEPO_D) - -if __name__ == '__main__': - from main import main - main() diff --git a/mepo.d/command/branch/branch.py b/mepo.d/command/branch/branch.py deleted file mode 100644 index 06b3ec11..00000000 --- a/mepo.d/command/branch/branch.py +++ /dev/null @@ -1,15 +0,0 @@ -import subprocess as sp - -from state.state import MepoState - -from command.branch.list import list -from command.branch.create import create -from command.branch.delete import delete - -def run(args): - d = { - 'list': list, - 'create': create, - 'delete': delete, - } - d[args.mepo_branch_cmd].run(args) diff --git a/mepo.d/command/config/config.py b/mepo.d/command/config/config.py deleted file mode 100644 index 689ccaa4..00000000 --- a/mepo.d/command/config/config.py +++ /dev/null @@ -1,17 +0,0 @@ -import subprocess as sp - -from state.state import MepoState - -from command.config.get import get -from command.config.set import set -from command.config.delete import delete -from command.config.print import print - -def run(args): - d = { - 'get': get, - 'set': set, - 'delete': delete, - 'print': print - } - d[args.mepo_config_cmd].run(args) diff --git a/mepo.d/command/stash/stash.py b/mepo.d/command/stash/stash.py deleted file mode 100644 index 05d65754..00000000 --- a/mepo.d/command/stash/stash.py +++ /dev/null @@ -1,19 +0,0 @@ -import subprocess as sp - -from state.state import MepoState - -from command.stash.list import list -from command.stash.pop import pop -from command.stash.apply import apply -from command.stash.push import push -from command.stash.show import show - -def run(args): - d = { - 'list': list, - 'pop': pop, - 'apply': apply, - 'push': push, - 'show': show, - } - d[args.mepo_stash_cmd].run(args) diff --git a/mepo.d/command/tag/tag.py b/mepo.d/command/tag/tag.py deleted file mode 100644 index 7158f1b0..00000000 --- a/mepo.d/command/tag/tag.py +++ /dev/null @@ -1,17 +0,0 @@ -import subprocess as sp - -from state.state import MepoState - -from command.tag.list import list -from command.tag.create import create -from command.tag.delete import delete -from command.tag.push import push - -def run(args): - d = { - 'list': list, - 'create': create, - 'delete': delete, - 'push': push - } - d[args.mepo_tag_cmd].run(args) diff --git a/mepo.d/main.py b/mepo.d/main.py deleted file mode 100644 index 620c7e57..00000000 --- a/mepo.d/main.py +++ /dev/null @@ -1,6 +0,0 @@ -from cmdline.parser import MepoArgParser -from command import command - -def main(): - args = MepoArgParser().parse() - command.run(args) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..0379e921 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "mepo" +version = "v2.0.0" +authors = [ + {name = "GMAO SI Team", email = "siteam@gmao.gsfc.nasa.gov"}, +] +description = "Tool to manage (m)ultiple r(epo)sitories" +requires-python = ">= 3.9" +license = {file = "LICENSE"} +readme = "README.md" +dependencies = [ + "pyyaml>=6.0.1", +] + +[project.urls] +Homepage = "https://github.com/GEOS-ESM/mepo" + +[project.scripts] +mepo = "mepo.main:main" + +[tool.setuptools] +include-package-data = true diff --git a/mepo.d/cmdline/branch_parser.py b/src/mepo/cmdline/branch_parser.py similarity index 100% rename from mepo.d/cmdline/branch_parser.py rename to src/mepo/cmdline/branch_parser.py diff --git a/mepo.d/cmdline/config_parser.py b/src/mepo/cmdline/config_parser.py similarity index 100% rename from mepo.d/cmdline/config_parser.py rename to src/mepo/cmdline/config_parser.py diff --git a/mepo.d/cmdline/parser.py b/src/mepo/cmdline/parser.py similarity index 98% rename from mepo.d/cmdline/parser.py rename to src/mepo/cmdline/parser.py index 34f9045e..237cc04b 100644 --- a/mepo.d/cmdline/parser.py +++ b/src/mepo/cmdline/parser.py @@ -1,10 +1,10 @@ import argparse -from cmdline.branch_parser import MepoBranchArgParser -from cmdline.stash_parser import MepoStashArgParser -from cmdline.tag_parser import MepoTagArgParser -from cmdline.config_parser import MepoConfigArgParser -from utilities import mepoconfig +from mepo.cmdline.branch_parser import MepoBranchArgParser +from mepo.cmdline.stash_parser import MepoStashArgParser +from mepo.cmdline.tag_parser import MepoTagArgParser +from mepo.cmdline.config_parser import MepoConfigArgParser +from mepo.utilities import mepoconfig class MepoArgParser(object): diff --git a/mepo.d/cmdline/stash_parser.py b/src/mepo/cmdline/stash_parser.py similarity index 100% rename from mepo.d/cmdline/stash_parser.py rename to src/mepo/cmdline/stash_parser.py diff --git a/mepo.d/cmdline/tag_parser.py b/src/mepo/cmdline/tag_parser.py similarity index 100% rename from mepo.d/cmdline/tag_parser.py rename to src/mepo/cmdline/tag_parser.py diff --git a/src/mepo/command/branch/branch.py b/src/mepo/command/branch/branch.py new file mode 100644 index 00000000..961465c5 --- /dev/null +++ b/src/mepo/command/branch/branch.py @@ -0,0 +1,15 @@ +import subprocess as sp + +from mepo.state.state import MepoState + +from mepo.command.branch.list import list +from mepo.command.branch.create import create +from mepo.command.branch.delete import delete + +def run(args): + d = { + 'list': list, + 'create': create, + 'delete': delete, + } + d[args.mepo_branch_cmd].run(args) diff --git a/mepo.d/command/branch/create/create.py b/src/mepo/command/branch/create/create.py similarity index 75% rename from mepo.d/command/branch/create/create.py rename to src/mepo/command/branch/create/create.py index d6772a6d..ba17415b 100644 --- a/mepo.d/command/branch/create/create.py +++ b/src/mepo/command/branch/create/create.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/branch/delete/delete.py b/src/mepo/command/branch/delete/delete.py similarity index 75% rename from mepo.d/command/branch/delete/delete.py rename to src/mepo/command/branch/delete/delete.py index 3206b3de..dc60bc92 100644 --- a/mepo.d/command/branch/delete/delete.py +++ b/src/mepo/command/branch/delete/delete.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/branch/list/list.py b/src/mepo/command/branch/list/list.py similarity index 86% rename from mepo.d/command/branch/list/list.py rename to src/mepo/command/branch/list/list.py index 71740248..16ce794d 100644 --- a/mepo.d/command/branch/list/list.py +++ b/src/mepo/command/branch/list/list.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/changed-files/changed-files.py b/src/mepo/command/changed-files/changed-files.py similarity index 85% rename from mepo.d/command/changed-files/changed-files.py rename to src/mepo/command/changed-files/changed-files.py index c2a1e2a9..4ae24ae2 100644 --- a/mepo.d/command/changed-files/changed-files.py +++ b/src/mepo/command/changed-files/changed-files.py @@ -1,11 +1,12 @@ -from state.state import MepoState -from utilities import colors -from utilities import verify -from utilities.version import version_to_string, sanitize_version_string -from repository.git import GitRepository -from shutil import get_terminal_size -from state.component import MepoVersion import os +from shutil import get_terminal_size + +from mepo.state.state import MepoState +from mepo.state.component import MepoVersion +from mepo.utilities import colors +from mepo.utilities import verify +from mepo.utilities.version import version_to_string, sanitize_version_string +from mepo.repository.git import GitRepository VER_LEN = 30 diff --git a/mepo.d/command/checkout-if-exists/checkout-if-exists.py b/src/mepo/command/checkout-if-exists/checkout-if-exists.py similarity index 84% rename from mepo.d/command/checkout-if-exists/checkout-if-exists.py rename to src/mepo/command/checkout-if-exists/checkout-if-exists.py index 528afb19..dfea26c2 100644 --- a/mepo.d/command/checkout-if-exists/checkout-if-exists.py +++ b/src/mepo/command/checkout-if-exists/checkout-if-exists.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from utilities import colors +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.utilities import colors def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/checkout/checkout.py b/src/mepo/command/checkout/checkout.py similarity index 88% rename from mepo.d/command/checkout/checkout.py rename to src/mepo/command/checkout/checkout.py index 0e18eb46..6e16ba1b 100644 --- a/mepo.d/command/checkout/checkout.py +++ b/src/mepo/command/checkout/checkout.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from utilities import colors +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.utilities import colors def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/clone/clone.py b/src/mepo/command/clone/clone.py similarity index 94% rename from mepo.d/command/clone/clone.py rename to src/mepo/command/clone/clone.py index 448e2849..5f0033a4 100644 --- a/mepo.d/command/clone/clone.py +++ b/src/mepo/command/clone/clone.py @@ -1,13 +1,13 @@ -from state.state import MepoState, StateDoesNotExistError -from repository.git import GitRepository -from command.init import init as mepo_init -from utilities import shellcmd, colors, mepoconfig -from urllib.parse import urlparse - import os import pathlib import shutil import shlex +from urllib.parse import urlparse + +from mepo.state.state import MepoState, StateDoesNotExistError +from mepo.repository.git import GitRepository +from mepo.command.init import init as mepo_init +from mepo.utilities import shellcmd, colors, mepoconfig def run(args): diff --git a/mepo.d/command/command.py b/src/mepo/command/command.py similarity index 69% rename from mepo.d/command/command.py rename to src/mepo/command/command.py index 221c9261..8a6a509a 100644 --- a/mepo.d/command/command.py +++ b/src/mepo/command/command.py @@ -1,11 +1,11 @@ from importlib import import_module -from utilities import mepoconfig +from mepo.utilities import mepoconfig def run(args): mepo_cmd = mepoconfig.get_alias_command(args.mepo_cmd) # Load the module containing the 'run' method of specified mepo command - cmd_module = import_module('command.{}.{}'.format(mepo_cmd, mepo_cmd)) + cmd_module = import_module('mepo.command.{}.{}'.format(mepo_cmd, mepo_cmd)) # Execute 'run' method of the specified mepo command cmd_module.run(args) diff --git a/mepo.d/command/commit/commit.py b/src/mepo/command/commit/commit.py similarity index 91% rename from mepo.d/command/commit/commit.py rename to src/mepo/command/commit/commit.py index 7b2ac349..f91c1277 100644 --- a/mepo.d/command/commit/commit.py +++ b/src/mepo/command/commit/commit.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from command.stage.stage import stage_files +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.command.stage.stage import stage_files # Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 import os, tempfile, subprocess diff --git a/mepo.d/command/compare/compare.py b/src/mepo/command/compare/compare.py similarity index 94% rename from mepo.d/command/compare/compare.py rename to src/mepo/command/compare/compare.py index 9f78165c..f16348af 100644 --- a/mepo.d/command/compare/compare.py +++ b/src/mepo/command/compare/compare.py @@ -1,9 +1,10 @@ -from state.state import MepoState -from utilities import colors -from utilities.version import version_to_string, sanitize_version_string -from repository.git import GitRepository from shutil import get_terminal_size +from mepo.state.state import MepoState +from mepo.utilities import colors +from mepo.utilities.version import version_to_string, sanitize_version_string +from mepo.repository.git import GitRepository + VER_LEN = 30 def run(args): diff --git a/src/mepo/command/config/config.py b/src/mepo/command/config/config.py new file mode 100644 index 00000000..211b7dad --- /dev/null +++ b/src/mepo/command/config/config.py @@ -0,0 +1,17 @@ +import subprocess as sp + +from mepo.state.state import MepoState + +from mepo.command.config.get import get +from mepo.command.config.set import set +from mepo.command.config.delete import delete +from mepo.command.config.print import print + +def run(args): + d = { + 'get': get, + 'set': set, + 'delete': delete, + 'print': print + } + d[args.mepo_config_cmd].run(args) diff --git a/mepo.d/command/config/delete/delete.py b/src/mepo/command/config/delete/delete.py similarity index 78% rename from mepo.d/command/config/delete/delete.py rename to src/mepo/command/config/delete/delete.py index dbf58dad..b7b85b29 100644 --- a/mepo.d/command/config/delete/delete.py +++ b/src/mepo/command/config/delete/delete.py @@ -1,4 +1,4 @@ -from utilities import mepoconfig +from mepo.utilities import mepoconfig def run(args): section, option = mepoconfig.split_entry(args.entry) diff --git a/mepo.d/command/config/get/get.py b/src/mepo/command/config/get/get.py similarity index 92% rename from mepo.d/command/config/get/get.py rename to src/mepo/command/config/get/get.py index 6ca83465..e88d1456 100644 --- a/mepo.d/command/config/get/get.py +++ b/src/mepo/command/config/get/get.py @@ -1,4 +1,4 @@ -from utilities import mepoconfig +from mepo.utilities import mepoconfig def run(args): section, option = mepoconfig.split_entry(args.entry) diff --git a/mepo.d/command/config/print/print.py b/src/mepo/command/config/print/print.py similarity index 50% rename from mepo.d/command/config/print/print.py rename to src/mepo/command/config/print/print.py index 16d85c62..1a612c3f 100644 --- a/mepo.d/command/config/print/print.py +++ b/src/mepo/command/config/print/print.py @@ -1,4 +1,4 @@ -from utilities import mepoconfig +from mepo.utilities import mepoconfig def run(args): mepoconfig.print() diff --git a/mepo.d/command/config/set/set.py b/src/mepo/command/config/set/set.py similarity index 81% rename from mepo.d/command/config/set/set.py rename to src/mepo/command/config/set/set.py index 6ac0a4c2..80d9079c 100644 --- a/mepo.d/command/config/set/set.py +++ b/src/mepo/command/config/set/set.py @@ -1,4 +1,4 @@ -from utilities import mepoconfig +from mepo.utilities import mepoconfig def run(args): section, option = mepoconfig.split_entry(args.entry) diff --git a/mepo.d/command/develop/develop.py b/src/mepo/command/develop/develop.py similarity index 81% rename from mepo.d/command/develop/develop.py rename to src/mepo/command/develop/develop.py index 8c2aa923..aec6f28c 100644 --- a/mepo.d/command/develop/develop.py +++ b/src/mepo/command/develop/develop.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from utilities import colors +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.utilities import colors def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/diff/diff.py b/src/mepo/command/diff/diff.py similarity index 94% rename from mepo.d/command/diff/diff.py rename to src/mepo/command/diff/diff.py index 8353196b..6afcd409 100644 --- a/mepo.d/command/diff/diff.py +++ b/src/mepo/command/diff/diff.py @@ -3,12 +3,12 @@ import multiprocessing as mp import os -from state.state import MepoState -from repository.git import GitRepository -from utilities import verify - from shutil import get_terminal_size +from mepo.state.state import MepoState +from mepo.repository.git import GitRepository +from mepo.utilities import verify + def run(args): foundDiff = False diff --git a/mepo.d/command/fetch/fetch.py b/src/mepo/command/fetch/fetch.py similarity index 79% rename from mepo.d/command/fetch/fetch.py rename to src/mepo/command/fetch/fetch.py index cddbbcb9..299db8c2 100644 --- a/mepo.d/command/fetch/fetch.py +++ b/src/mepo/command/fetch/fetch.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from utilities import colors +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.utilities import colors def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/init/init.py b/src/mepo/command/init/init.py similarity index 89% rename from mepo.d/command/init/init.py rename to src/mepo/command/init/init.py index c868f082..b4ef2126 100644 --- a/mepo.d/command/init/init.py +++ b/src/mepo/command/init/init.py @@ -1,5 +1,5 @@ -from state.state import MepoState -from utilities import mepoconfig +from mepo.state.state import MepoState +from mepo.utilities import mepoconfig def run(args): if args.style: diff --git a/mepo.d/command/list/list.py b/src/mepo/command/list/list.py similarity index 76% rename from mepo.d/command/list/list.py rename to src/mepo/command/list/list.py index d60e932d..25a8e4d1 100644 --- a/mepo.d/command/list/list.py +++ b/src/mepo/command/list/list.py @@ -1,4 +1,4 @@ -from state.state import MepoState +from mepo.state.state import MepoState def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/pull-all/pull-all.py b/src/mepo/command/pull-all/pull-all.py similarity index 80% rename from mepo.d/command/pull-all/pull-all.py rename to src/mepo/command/pull-all/pull-all.py index c902b56f..a47bf691 100644 --- a/mepo.d/command/pull-all/pull-all.py +++ b/src/mepo/command/pull-all/pull-all.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from repository.git import GitRepository -from state.component import MepoVersion -from utilities import colors +from mepo.state.state import MepoState +from mepo.repository.git import GitRepository +from mepo.state.component import MepoVersion +from mepo.utilities import colors def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/pull/pull.py b/src/mepo/command/pull/pull.py similarity index 77% rename from mepo.d/command/pull/pull.py rename to src/mepo/command/pull/pull.py index 92aa0bf2..f934e80b 100644 --- a/mepo.d/command/pull/pull.py +++ b/src/mepo/command/pull/pull.py @@ -1,8 +1,8 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from state.component import MepoVersion -from utilities import colors +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.state.component import MepoVersion +from mepo.utilities import colors def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/push/push.py b/src/mepo/command/push/push.py similarity index 75% rename from mepo.d/command/push/push.py rename to src/mepo/command/push/push.py index adcf2aea..3b7d27a7 100644 --- a/mepo.d/command/push/push.py +++ b/src/mepo/command/push/push.py @@ -1,6 +1,6 @@ -from utilities import verify -from state.state import MepoState -from repository.git import GitRepository +from mepo.utilities import verify +from mepo.state.state import MepoState +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/reset/reset.py b/src/mepo/command/reset/reset.py similarity index 95% rename from mepo.d/command/reset/reset.py rename to src/mepo/command/reset/reset.py index 41cf79ef..7ea0104a 100644 --- a/mepo.d/command/reset/reset.py +++ b/src/mepo/command/reset/reset.py @@ -1,10 +1,10 @@ import os import shutil -from state.state import MepoState -from state.exceptions import NotInRootDirError +from mepo.state.state import MepoState +from mepo.state.exceptions import NotInRootDirError -from command.clone import clone as mepo_clone +from mepo.command.clone import clone as mepo_clone # This command will "reset" the mepo clone. This will delete all # the subrepos, remove the .mepo directory, and then re-clone all the diff --git a/mepo.d/command/restore-state/restore-state.py b/src/mepo/command/restore-state/restore-state.py similarity index 85% rename from mepo.d/command/restore-state/restore-state.py rename to src/mepo/command/restore-state/restore-state.py index 38a124bf..b713bf37 100644 --- a/mepo.d/command/restore-state/restore-state.py +++ b/src/mepo/command/restore-state/restore-state.py @@ -3,10 +3,10 @@ import multiprocessing as mp import atexit -from state.state import MepoState -from repository.git import GitRepository -from utilities.version import version_to_string -from utilities import colors +from mepo.state.state import MepoState +from mepo.repository.git import GitRepository +from mepo.utilities.version import version_to_string +from mepo.utilities import colors def run(args): print('Checking status...'); sys.stdout.flush() diff --git a/mepo.d/command/save/save.py b/src/mepo/command/save/save.py similarity index 91% rename from mepo.d/command/save/save.py rename to src/mepo/command/save/save.py index 336b3f79..44f3edfb 100644 --- a/mepo.d/command/save/save.py +++ b/src/mepo/command/save/save.py @@ -1,8 +1,8 @@ -from state.state import MepoState -from state.component import MepoVersion -from repository.git import GitRepository -from config.config_file import ConfigFile -from utilities.version import sanitize_version_string +from mepo.state.state import MepoState +from mepo.state.component import MepoVersion +from mepo.repository.git import GitRepository +from mepo.config.config_file import ConfigFile +from mepo.utilities.version import sanitize_version_string import os diff --git a/mepo.d/command/stage/stage.py b/src/mepo/command/stage/stage.py similarity index 82% rename from mepo.d/command/stage/stage.py rename to src/mepo/command/stage/stage.py index ea93d9a7..5f7d3d7b 100644 --- a/mepo.d/command/stage/stage.py +++ b/src/mepo/command/stage/stage.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository -from state.component import MepoVersion +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository +from mepo.state.component import MepoVersion def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/stash/apply/apply.py b/src/mepo/command/stash/apply/apply.py similarity index 73% rename from mepo.d/command/stash/apply/apply.py rename to src/mepo/command/stash/apply/apply.py index 04f7e374..564b0340 100644 --- a/mepo.d/command/stash/apply/apply.py +++ b/src/mepo/command/stash/apply/apply.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/stash/list/list.py b/src/mepo/command/stash/list/list.py similarity index 83% rename from mepo.d/command/stash/list/list.py rename to src/mepo/command/stash/list/list.py index 62eb0d90..d7f0510b 100644 --- a/mepo.d/command/stash/list/list.py +++ b/src/mepo/command/stash/list/list.py @@ -1,5 +1,5 @@ -from state.state import MepoState -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/stash/pop/pop.py b/src/mepo/command/stash/pop/pop.py similarity index 73% rename from mepo.d/command/stash/pop/pop.py rename to src/mepo/command/stash/pop/pop.py index 12f79daf..ff9a2fc8 100644 --- a/mepo.d/command/stash/pop/pop.py +++ b/src/mepo/command/stash/pop/pop.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/stash/push/push.py b/src/mepo/command/stash/push/push.py similarity index 73% rename from mepo.d/command/stash/push/push.py rename to src/mepo/command/stash/push/push.py index 276a95e2..e806e0be 100644 --- a/mepo.d/command/stash/push/push.py +++ b/src/mepo/command/stash/push/push.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/stash/show/show.py b/src/mepo/command/stash/show/show.py similarity index 73% rename from mepo.d/command/stash/show/show.py rename to src/mepo/command/stash/show/show.py index 69f37664..fda6ee32 100644 --- a/mepo.d/command/stash/show/show.py +++ b/src/mepo/command/stash/show/show.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/src/mepo/command/stash/stash.py b/src/mepo/command/stash/stash.py new file mode 100644 index 00000000..fe0ef3eb --- /dev/null +++ b/src/mepo/command/stash/stash.py @@ -0,0 +1,19 @@ +import subprocess as sp + +from mepo.state.state import MepoState + +from mepo.command.stash.list import list +from mepo.command.stash.pop import pop +from mepo.command.stash.apply import apply +from mepo.command.stash.push import push +from mepo.command.stash.show import show + +def run(args): + d = { + 'list': list, + 'pop': pop, + 'apply': apply, + 'push': push, + 'show': show, + } + d[args.mepo_stash_cmd].run(args) diff --git a/mepo.d/command/status/status.py b/src/mepo/command/status/status.py similarity index 91% rename from mepo.d/command/status/status.py rename to src/mepo/command/status/status.py index 91720592..9f7bc912 100644 --- a/mepo.d/command/status/status.py +++ b/src/mepo/command/status/status.py @@ -2,14 +2,14 @@ import time import multiprocessing as mp import atexit - -from state.state import MepoState -from repository.git import GitRepository -from utilities.version import version_to_string, sanitize_version_string -from utilities import colors, shellcmd -from command.whereis.whereis import _get_relative_path import shlex +from mepo.state.state import MepoState +from mepo.repository.git import GitRepository +from mepo.utilities.version import version_to_string, sanitize_version_string +from mepo.utilities import colors, shellcmd +from mepo.command.whereis.whereis import _get_relative_path + def run(args): print('Checking status...'); sys.stdout.flush() allcomps = MepoState.read_state() diff --git a/mepo.d/command/tag/create/create.py b/src/mepo/command/tag/create/create.py similarity index 94% rename from mepo.d/command/tag/create/create.py rename to src/mepo/command/tag/create/create.py index cc765d47..aca4e3cf 100644 --- a/mepo.d/command/tag/create/create.py +++ b/src/mepo/command/tag/create/create.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository # Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 import os, tempfile, subprocess diff --git a/mepo.d/command/tag/delete/delete.py b/src/mepo/command/tag/delete/delete.py similarity index 83% rename from mepo.d/command/tag/delete/delete.py rename to src/mepo/command/tag/delete/delete.py index f063e6a6..8998f4c3 100644 --- a/mepo.d/command/tag/delete/delete.py +++ b/src/mepo/command/tag/delete/delete.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/tag/list/list.py b/src/mepo/command/tag/list/list.py similarity index 86% rename from mepo.d/command/tag/list/list.py rename to src/mepo/command/tag/list/list.py index c04c3257..a7c2a985 100644 --- a/mepo.d/command/tag/list/list.py +++ b/src/mepo/command/tag/list/list.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/tag/push/push.py b/src/mepo/command/tag/push/push.py similarity index 86% rename from mepo.d/command/tag/push/push.py rename to src/mepo/command/tag/push/push.py index 975c2e1d..e428ed1b 100644 --- a/mepo.d/command/tag/push/push.py +++ b/src/mepo/command/tag/push/push.py @@ -1,6 +1,6 @@ -from state.state import MepoState -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/src/mepo/command/tag/tag.py b/src/mepo/command/tag/tag.py new file mode 100644 index 00000000..9b02fe89 --- /dev/null +++ b/src/mepo/command/tag/tag.py @@ -0,0 +1,17 @@ +import subprocess as sp + +from mepo.state.state import MepoState + +from mepo.command.tag.list import list +from mepo.command.tag.create import create +from mepo.command.tag.delete import delete +from mepo.command.tag.push import push + +def run(args): + d = { + 'list': list, + 'create': create, + 'delete': delete, + 'push': push + } + d[args.mepo_tag_cmd].run(args) diff --git a/mepo.d/command/unstage/unstage.py b/src/mepo/command/unstage/unstage.py similarity index 80% rename from mepo.d/command/unstage/unstage.py rename to src/mepo/command/unstage/unstage.py index 76e726b5..d0f9600b 100644 --- a/mepo.d/command/unstage/unstage.py +++ b/src/mepo/command/unstage/unstage.py @@ -1,7 +1,7 @@ -from state.state import MepoState -from utilities import shellcmd -from utilities import verify -from repository.git import GitRepository +from mepo.state.state import MepoState +from mepo.utilities import shellcmd +from mepo.utilities import verify +from mepo.repository.git import GitRepository def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/command/whereis/whereis.py b/src/mepo/command/whereis/whereis.py similarity index 96% rename from mepo.d/command/whereis/whereis.py rename to src/mepo/command/whereis/whereis.py index df6c0430..c5da6099 100644 --- a/mepo.d/command/whereis/whereis.py +++ b/src/mepo/command/whereis/whereis.py @@ -1,7 +1,7 @@ import os -from state.state import MepoState -from utilities import verify +from mepo.state.state import MepoState +from mepo.utilities import verify def run(args): allcomps = MepoState.read_state() diff --git a/mepo.d/config/config_file.py b/src/mepo/config/config_file.py similarity index 96% rename from mepo.d/config/config_file.py rename to src/mepo/config/config_file.py index c72ee3ad..b4c10896 100644 --- a/mepo.d/config/config_file.py +++ b/src/mepo/config/config_file.py @@ -1,7 +1,7 @@ import pathlib import yaml -from state.exceptions import SuffixNotRecognizedError +from mepo.state.exceptions import SuffixNotRecognizedError # From https://github.com/yaml/pyyaml/issues/127#issuecomment-525800484 class AddBlankLinesDumper(yaml.SafeDumper): diff --git a/src/mepo/main.py b/src/mepo/main.py new file mode 100644 index 00000000..30a31351 --- /dev/null +++ b/src/mepo/main.py @@ -0,0 +1,6 @@ +from mepo.cmdline.parser import MepoArgParser +from mepo.command import command + +def main(): + args = MepoArgParser().parse() + command.run(args) diff --git a/mepo.d/repository/git.py b/src/mepo/repository/git.py similarity index 99% rename from mepo.d/repository/git.py rename to src/mepo/repository/git.py index b54b54b9..e3a566af 100644 --- a/mepo.d/repository/git.py +++ b/src/mepo/repository/git.py @@ -3,11 +3,12 @@ import subprocess import shlex -from state.state import MepoState -from utilities import shellcmd -from utilities import colors from urllib.parse import urljoin -from state.exceptions import RepoAlreadyClonedError + +from mepo.state.state import MepoState +from mepo.utilities import shellcmd +from mepo.utilities import colors +from mepo.state.exceptions import RepoAlreadyClonedError class GitRepository(object): """ diff --git a/mepo.d/state/component.py b/src/mepo/state/component.py similarity index 98% rename from mepo.d/state/component.py rename to src/mepo/state/component.py index e121075f..5d79f395 100644 --- a/mepo.d/state/component.py +++ b/src/mepo/state/component.py @@ -1,9 +1,11 @@ import os import shlex import textwrap + from collections import namedtuple -from utilities.version import MepoVersion -from utilities import shellcmd, mepoconfig + +from mepo.utilities.version import MepoVersion +from mepo.utilities import shellcmd, mepoconfig from urllib.parse import urlparse # This will be used to store the "final nodes" from each subrepo diff --git a/mepo.d/state/exceptions.py b/src/mepo/state/exceptions.py similarity index 100% rename from mepo.d/state/exceptions.py rename to src/mepo/state/exceptions.py diff --git a/mepo.d/state/state.py b/src/mepo/state/state.py similarity index 93% rename from mepo.d/state/state.py rename to src/mepo/state/state.py index 45ced347..24be3511 100644 --- a/mepo.d/state/state.py +++ b/src/mepo/state/state.py @@ -4,11 +4,12 @@ import glob import pickle -from config.config_file import ConfigFile -from state.component import MepoComponent -from utilities import shellcmd from pathlib import Path -from state.exceptions import StateDoesNotExistError, StateAlreadyInitializedError + +from mepo.config.config_file import ConfigFile +from mepo.state.component import MepoComponent +from mepo.utilities import shellcmd +from mepo.state.exceptions import StateDoesNotExistError, StateAlreadyInitializedError class MepoState(object): diff --git a/mepo.d/utilities/colors.py b/src/mepo/utilities/colors.py similarity index 100% rename from mepo.d/utilities/colors.py rename to src/mepo/utilities/colors.py diff --git a/mepo.d/utilities/mepoconfig.py b/src/mepo/utilities/mepoconfig.py similarity index 100% rename from mepo.d/utilities/mepoconfig.py rename to src/mepo/utilities/mepoconfig.py diff --git a/mepo.d/utilities/shellcmd.py b/src/mepo/utilities/shellcmd.py similarity index 100% rename from mepo.d/utilities/shellcmd.py rename to src/mepo/utilities/shellcmd.py diff --git a/mepo.d/utilities/verify.py b/src/mepo/utilities/verify.py similarity index 100% rename from mepo.d/utilities/verify.py rename to src/mepo/utilities/verify.py diff --git a/mepo.d/utilities/version.py b/src/mepo/utilities/version.py similarity index 100% rename from mepo.d/utilities/version.py rename to src/mepo/utilities/version.py diff --git a/mepo.d/utest/input/args.py b/tests/input/args.py similarity index 100% rename from mepo.d/utest/input/args.py rename to tests/input/args.py diff --git a/mepo.d/utest/input/components.yaml b/tests/input/components.yaml similarity index 100% rename from mepo.d/utest/input/components.yaml rename to tests/input/components.yaml diff --git a/mepo.d/utest/output/compare_brief_output.txt b/tests/output/compare_brief_output.txt similarity index 100% rename from mepo.d/utest/output/compare_brief_output.txt rename to tests/output/compare_brief_output.txt diff --git a/mepo.d/utest/output/compare_full_output.txt b/tests/output/compare_full_output.txt similarity index 100% rename from mepo.d/utest/output/compare_full_output.txt rename to tests/output/compare_full_output.txt diff --git a/mepo.d/utest/output/list_output.txt b/tests/output/list_output.txt similarity index 100% rename from mepo.d/utest/output/list_output.txt rename to tests/output/list_output.txt diff --git a/mepo.d/utest/output/status_output.txt b/tests/output/status_output.txt similarity index 100% rename from mepo.d/utest/output/status_output.txt rename to tests/output/status_output.txt diff --git a/mepo.d/utest/test_mepo_commands.py b/tests/test_mepo_commands.py similarity index 89% rename from mepo.d/utest/test_mepo_commands.py rename to tests/test_mepo_commands.py index c1fc5a64..dbdd88ef 100644 --- a/mepo.d/utest/test_mepo_commands.py +++ b/tests/test_mepo_commands.py @@ -1,7 +1,7 @@ import os import sys THIS_DIR = os.path.dirname(os.path.realpath(__file__)) -sys.path.insert(0, os.path.join(THIS_DIR, '..')) +sys.path.insert(0, os.path.join(THIS_DIR, '..', 'src')) import shutil import shlex import unittest @@ -10,12 +10,12 @@ from input import args -from command.init import init as mepo_init -from command.clone import clone as mepo_clone -from command.list import list as mepo_list -from command.status import status as mepo_status -from command.compare import compare as mepo_compare -from command.develop import develop as mepo_develop +from mepo.command.init import init as mepo_init +from mepo.command.clone import clone as mepo_clone +from mepo.command.list import list as mepo_list +from mepo.command.status import status as mepo_status +from mepo.command.compare import compare as mepo_compare +from mepo.command.develop import develop as mepo_develop class TestMepoCommands(unittest.TestCase):