Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mepo3 - hierarchical mepo #274

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2450ba9
Maybe we don't need the MepoState dependency
pchakraborty Mar 28, 2024
ddd9860
Merge remote-tracking branch 'origin/develop' into feature/pchakrab/h…
pchakraborty Mar 28, 2024
82aa552
Towards hierarchical mepo
pchakraborty Mar 28, 2024
df2cb07
Renamed __recursive_clone__ -> __recursive_clone
pchakraborty Mar 29, 2024
6d04470
Added argument 'partial' to the recursive cloning routine
pchakraborty Mar 30, 2024
cca5030
Tests work with hierarchical cloning
pchakraborty Mar 30, 2024
84089e7
Towards a more standard Python module
pchakraborty Apr 3, 2024
c9941f0
Some more renaming: command/commit/commit.py -> command/commit.py
pchakraborty Apr 4, 2024
131f67c
Using Python3's relative import
pchakraborty Apr 4, 2024
4157b17
Some more renaming, e.g command/config/config.py -> command/config.py
pchakraborty Apr 4, 2024
42e3d33
Last round of renaming, e.g. save/save.py -> save.py
pchakraborty Apr 4, 2024
5a7eef1
Renamed config/config_file.py -> registry.py
pchakraborty Apr 4, 2024
43c20f2
Using Python3's relative import
pchakraborty Apr 4, 2024
e9144fe
Using Python3's relative import
pchakraborty Apr 4, 2024
22a64c6
Removed utilities/__init__.py
pchakraborty Apr 4, 2024
239ba1f
Fixed tests
pchakraborty Apr 4, 2024
5668fa7
Updated required Python version in README.md
pchakraborty Apr 4, 2024
af8ea63
Renamed main.py as __main__.py, and related changes
pchakraborty Apr 4, 2024
0264e98
Moved state/exceptions.py to utilities
pchakraborty Apr 4, 2024
27ca42f
Renamed repository/git.py -> git.py, and associated changes
pchakraborty Apr 4, 2024
d91e884
Moved state.py and component.py one level up, and associated changes
pchakraborty Apr 4, 2024
c16bbec
Fixed tests
pchakraborty Apr 5, 2024
3c19f0e
Fixed the helper script
pchakraborty Apr 5, 2024
8c9a8a9
Fixed doc generation
pchakraborty Apr 5, 2024
fd9921c
Switched from https to ssh for git cloning
pchakraborty Apr 5, 2024
4324e08
Back to https but with correct address this time
pchakraborty Apr 5, 2024
7d71a03
Updated stored test outputs
pchakraborty Apr 8, 2024
eb24932
Renamed top level script as mepo3
pchakraborty Apr 8, 2024
412d4e1
Completed mepo to mepo3 conversion
pchakraborty Apr 9, 2024
df051fe
In code, use mepo state dir as specified my MepoState, instead of ha…
pchakraborty Apr 9, 2024
d43e45b
scripts now use mepo3
pchakraborty Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mepo [![Actions Status](https://github.com/pchakraborty/mepo/workflows/Unit%20testing%20of%20mepo/badge.svg)](https://github.com/pchakraborty/mepo/actions) [![DOI](https://zenodo.org/badge/215067850.svg)](https://zenodo.org/badge/latestdoi/215067850)

`mepo` is a tool, written in Python3 (3.6.0+), to manage (m)ultiple git r(epo)sitories, by attempting to create an illusion of a 'single repository' for multi-repository projects. Please see the [Wiki](../../wiki) for examples of `mepo` workflows.
`mepo` is a tool, written in Python3 (3.9.0+), to manage (m)ultiple git r(epo)sitories, by attempting to create an illusion of a 'single repository' for multi-repository projects. Please see the [Wiki](../../wiki) for examples of `mepo` workflows.

## Commands

Expand Down
2 changes: 1 addition & 1 deletion bin/mepo → bin/mepo3
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ 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
from mepo3.__main__ import main
main()
72 changes: 40 additions & 32 deletions docs/make_md_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import io
import glob
from mdutils.mdutils import MdUtils
import subprocess as sp

Expand All @@ -13,69 +14,75 @@
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 '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')
# Now add "src/mepo"
mepod_dir_path = os.path.join(main_dir_path, "src", "mepo3")
# And then "command"
command_dir_path = os.path.join(mepod_dir_path, "command")

mepo_command_path = os.path.join(main_dir_path, 'bin', 'mepo')
mepo_command_path = os.path.join(main_dir_path, "bin", "mepo3")

def get_command_list(directory):
# Walk the tree
roots = [x[0] for x in os.walk(directory)]
# # Walk the tree
# roots = [x[0] for x in os.walk(directory)]

# Now remove "." from the list
roots = roots[1:]
# # Now remove "." from the list
# roots = roots[1:]
# print(f"roots: {roots}")

# Just get the relative paths
rel_roots = [os.path.relpath(x,directory) for x in roots]
# # Just get the relative paths
# rel_roots = [os.path.relpath(x,directory) for x in roots]
# print(f"rel roots: {rel_roots}")

# Now exclude __pycache__
command_dirs = [x for x in rel_roots if '__pycache__' not in x]
# # Now exclude __pycache__
# command_dirs = [x for x in rel_roots if "__pycache__" not in x]
# print(f"command dirs: {command_dirs}")

# Convert slashes to spaces
all_commands = [x.replace('/',' ') for x in command_dirs]

# Now let's find the commands that have subcommands
## First we get commands with spaces
commands_with_spaces = [x for x in all_commands if ' ' in x]
## Now let's just get the first elements
temp = [x.split()[0] for x in commands_with_spaces]
## Get the uniques
commands_with_subcommands = list(set(temp))
all_commands_py = glob.glob(os.path.join(directory, "*.py"))
all_commands = [os.path.basename(x).replace(".py", "") for x in all_commands_py]
all_commands.remove("command") # manually remove

# Now let"s find the commands that have subcommands
## First we get commands with underscore
commands_with_underscore = [x for x in all_commands if "_" in x]
commands_with_subcommands = [x.replace("_", " ") for x in commands_with_underscore]

# Now remove those from our list
all_useful_commands = [x for x in all_commands if x not in commands_with_subcommands]
all_useful_commands = [x for x in all_commands if x not in commands_with_underscore]
all_useful_commands += commands_with_subcommands

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()
cmd = " ".join(cmd).split()
print(f"command: {cmd}")

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
print(f"output: {output}")

output_list = output.split("\n")
print(f"output list: {output_list}")

# Command summary
summary = output_list[2]
mdFile.write(summary)

# Usage
usage = output_list[0]
usage = usage.replace('usage: ','')
usage = usage.replace("usage: ","")
mdFile.new_header(level=3, title="Usage")
mdFile.insert_code(usage)

positional_arguments = output.partition('positional arguments:\n')[2].partition('\n\n')[0]
positional_arguments = output.partition("positional arguments:\n")[2].partition("\n\n")[0]
if positional_arguments:
mdFile.new_header(level=3, title="Positional Arguments")
mdFile.insert_code(positional_arguments)

optional_arguments = output.partition('optional arguments:\n')[2].partition('\n\n')[0]
optional_arguments = output.partition("optional arguments:\n")[2].partition("\n\n")[0]
# Remove extra blank lines
optional_arguments = os.linesep.join([s for s in optional_arguments.splitlines() if s])
if optional_arguments:
Expand All @@ -84,18 +91,19 @@ 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")
mdFile.new_paragraph(preamble)

mdFile.new_header(level=1, title="Commands")
command_list = get_command_list(command_dir_path)
print(f"command_list: {command_list}")
for command in command_list:
mdFile.new_header(level=2, title=command)
create_markdown_from_usage(command,mdFile)

mdFile.new_table_of_contents(table_title='Table of Contents', depth=2)
mdFile.new_table_of_contents(table_title="Table of Contents", depth=2)
mdFile.create_md_file()
print(f'Generated {doc_file}.')
print(f"Generated {doc_file}.")
4 changes: 2 additions & 2 deletions etc/mepo-cd.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function mepo-cd () {
return 0
fi
if [ "$#" -eq 0 ]; then
output=$(mepo whereis _root)
output=$(mepo3 whereis _root)
else
output=$(mepo whereis -i $1)
output=$(mepo3 whereis -i $1)
fi
if [ $? -eq 0 ]; then
cd $output
Expand Down
2 changes: 1 addition & 1 deletion etc/mepo-cd.csh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
alias mepo-cd 'cd `mepo whereis -i \!:1`'
alias mepo-cd 'cd `mepo3 whereis -i \!:1`'
4 changes: 2 additions & 2 deletions etc/mepo-cd.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function mepo-cd () {
return 0
fi
if (( $# == 0 )); then
output=$(mepo whereis _root)
output=$(mepo3 whereis _root)
else
output=$(mepo whereis -i $1)
output=$(mepo3 whereis -i $1)
fi
if [ $? -eq 0 ]; then
cd $output
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "mepo"
version = "v2.0.0"
name = "mepo3"
version = "v1.68.0"
authors = [
{name = "GMAO SI Team", email = "[email protected]"},
]
Expand All @@ -20,7 +20,7 @@ dependencies = [
Homepage = "https://github.com/GEOS-ESM/mepo"

[project.scripts]
mepo = "mepo.main:main"
mepo3 = "mepo3.__main__:main"

[tool.setuptools]
include-package-data = true
15 changes: 0 additions & 15 deletions src/mepo/command/branch/branch.py

This file was deleted.

17 changes: 0 additions & 17 deletions src/mepo/command/config/config.py

This file was deleted.

22 changes: 0 additions & 22 deletions src/mepo/command/init/init.py

This file was deleted.

19 changes: 0 additions & 19 deletions src/mepo/command/stash/stash.py

This file was deleted.

17 changes: 0 additions & 17 deletions src/mepo/command/tag/tag.py

This file was deleted.

6 changes: 0 additions & 6 deletions src/mepo/main.py

This file was deleted.

Empty file added src/mepo3/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions src/mepo3/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .cmdline.parser import MepoArgParser
from .command import command


def main():
args = MepoArgParser().parse()
command.run(args)


if __name__ == "__main__":
main()
Loading
Loading