Skip to content

Commit

Permalink
Merge pull request ESCOMP#11 from jedwards4b/poetry-refactor
Browse files Browse the repository at this point in the history
Poetry refactor
  • Loading branch information
jedwards4b authored Feb 3, 2024
2 parents 2a2ab65 + 4f3bb55 commit b8d5a03
Show file tree
Hide file tree
Showing 19 changed files with 319 additions and 189 deletions.
20 changes: 20 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
26 changes: 26 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "git-fleximod"
author = "Jim Edwards <[email protected]>"
release = "0.4.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["sphinx_argparse_cli"]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "alabaster"
html_static_path = ["_static"]
24 changes: 24 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. git-fleximod documentation master file, created by
sphinx-quickstart on Sat Feb 3 12:02:22 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to git-fleximod's documentation!
========================================

.. toctree::
:maxdepth: 2
:caption: Contents:
.. module:: sphinxcontrib.autoprogram
.. sphinx_argparse_cli::
:module: classes.cli
:func: get_parser
:prog: git-fleximod


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[tool.poetry]
name = "git-fleximod"
version = "0.3.0"
description = "Extended support for git-submodule and git-sparse-checkout"
authors = ["Jim Edwards <[email protected]>"]
maintainers = ["Jim Edwards <[email protected]>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/jedwards4b/git-fleximod"
keywords = ["git", "submodule", "sparse-checkout"]
packages = [
{ include = "src/git-fleximod" },
{ include = "src/classes/*.py" },
{ include = "License" },
{ include = "tests" },
{ include = "doc/*.rst" },
{ include = "doc/Makefile" },
{ include = "doc/make.bat" },
{ include = "doc/conf.py" },
]

[tool.poetry.dependencies]
python = "^3.8"
GitPython = "^3.1.0"

[tools.poetry.urls]
"Bug Tracker" = "https://github.com/jedwards4b/git-fleximod/issues"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

55 changes: 0 additions & 55 deletions setup.py

This file was deleted.

File renamed without changes.
Empty file added src/classes/__init__.py
Empty file.
120 changes: 120 additions & 0 deletions src/classes/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
from pathlib import Path
import argparse

__version__ = "0.3.0"


def find_root_dir(filename=".git"):
d = Path.cwd()
root = Path(d.root)
while d != root:
attempt = d / filename
if attempt.is_dir():
return attempt
d = d.parent
return None


def get_parser():
description = """
%(prog)s manages checking out groups of gitsubmodules with addtional support for Earth System Models
"""
parser = argparse.ArgumentParser(
description=description, formatter_class=argparse.RawDescriptionHelpFormatter
)

#
# user options
#
choices = ["update", "checkout", "status", "test"]
parser.add_argument(
"action",
choices=choices,
default="checkout",
help=f"Subcommand of git-fleximod, choices are {choices[:-1]}",
)

parser.add_argument(
"components",
nargs="*",
help="Specific component(s) to checkout. By default, "
"all required submodules are checked out.",
)

parser.add_argument(
"-C",
"--path",
default=find_root_dir(),
help="Toplevel repository directory. Defaults to top git directory relative to current.",
)

parser.add_argument(
"-g",
"--gitmodules",
nargs="?",
default=".gitmodules",
help="The submodule description filename. " "Default: %(default)s.",
)

parser.add_argument(
"-x",
"--exclude",
nargs="*",
help="Component(s) listed in the gitmodules file which should be ignored.",
)
parser.add_argument(
"-f",
"--force",
action="store_true",
default=False,
help="Override cautions and update or checkout over locally modified repository.",
)

parser.add_argument(
"-o",
"--optional",
action="store_true",
default=False,
help="By default only the required submodules "
"are checked out. This flag will also checkout the "
"optional submodules relative to the toplevel directory.",
)

parser.add_argument(
"-v",
"--verbose",
action="count",
default=0,
help="Output additional information to "
"the screen and log file. This flag can be "
"used up to two times, increasing the "
"verbosity level each time.",
)

parser.add_argument(
"-V",
"--version",
action="version",
version=f"%(prog)s {__version__}",
help="Print version and exit.",
)

#
# developer options
#
parser.add_argument(
"--backtrace",
action="store_true",
help="DEVELOPER: show exception backtraces as extra " "debugging output",
)

parser.add_argument(
"-d",
"--debug",
action="store_true",
default=False,
help="DEVELOPER: output additional debugging "
"information to the screen and log file.",
)

return parser
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from fleximod import utils
from classes import utils


class GitInterface:
Expand Down
2 changes: 1 addition & 1 deletion src/fleximod/gitmodules.py → src/classes/gitmodules.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
from configparser import ConfigParser
from fleximod.lstripreader import LstripReader
from classes.lstripreader import LstripReader


class GitModules(ConfigParser):
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/fleximod/version.py

This file was deleted.

Loading

0 comments on commit b8d5a03

Please sign in to comment.