Skip to content

Commit

Permalink
Multiple cleanups from neglect
Browse files Browse the repository at this point in the history
* Switched to setuptools vs pbr
* Switched to black off yapf
* Added hacking for extra lint
* Corrected docstrings
  • Loading branch information
retr0h committed Mar 14, 2020
1 parent 54f2a58 commit 2613c82
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 123 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
*.egg-info/
*.py[cod]
*.py[rcod]
.cache/
.coverage
.eggs/
.tox/
.venv/
build/
coverage.*
dist/
doc/build/
htmlcov/
pip-wheel-metadata/
2 changes: 2 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
3.7.6
3.6.7
14 changes: 2 additions & 12 deletions doc/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,12 @@ Tag the release and push to github.com
Upload to `PyPI`_
^^^^^^^^^^^^^^^^^

* Install `Twine`_ using `pip`.

.. code-block:: bash
$ pip install twine
* Upload to `PyPI`_.

.. code-block:: bash
$ cd /path/to/gilt
$ rm -rf build/ dist/
$ python setup.py sdist bdist_wheel
$ twine upload dist/*
$ rm -rf build/ dist/
$ tox -e build-dists
$ tox -e publish-dists
Post-release
------------
Expand All @@ -65,4 +56,3 @@ Roadmap

.. _`PyPI`: https://pypi.python.org/pypi/python-gilt
.. _`ISSUES`: https://github.com/metacloud/gilt/issues
.. _`Twine`: https://pypi.python.org/pypi/twine
10 changes: 5 additions & 5 deletions gilt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2016 Cisco Systems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -20,7 +18,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import pbr.version
try:
import pkg_resources

version_info = pbr.version.VersionInfo('python-gilt') # noqa
__version__ = version_info.release_string()
__version__ = pkg_resources.get_distribution('gilt').version
except Exception: # pragma: no cover
__version__ = 'unknown'
36 changes: 12 additions & 24 deletions gilt/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2016 Cisco Systems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -31,16 +29,15 @@


class ParseError(Exception):
""" Error raised when a config can't be loaded properly. """
"""Error raised when a config can't be loaded properly. """
pass


BASE_WORKING_DIR = os.environ.get('GILT_CACHE_DIRECTORY', '~/.gilt')


def config(filename):
"""
Construct `Config` object and return a list.
"""Construct `Config` object and return a list.
:parse filename: A string containing the path to YAML file.
:return: list
Expand All @@ -60,8 +57,7 @@ def config(filename):


def _get_files_config(src_dir, files_list):
"""
Construct `FileConfig` object and return a list.
"""Construct `FileConfig` object and return a list.
:param src_dir: A string containing the source directory.
:param files_list: A list of dicts containing the src/dst mapping of files
Expand All @@ -77,8 +73,7 @@ def _get_files_config(src_dir, files_list):


def _get_config_generator(filename):
"""
A generator which populates and return a dict.
"""A generator which populates and return a dict.
:parse filename: A string containing the path to YAML file.
:return: dict
Expand Down Expand Up @@ -106,8 +101,7 @@ def _get_config_generator(filename):


def _get_files_generator(src_dir, files_list):
"""
A generator which populates and return a dict.
"""A generator which populates and return a dict.
:param src_dir: A string containing the source directory.
:param files_list: A list of dicts containing the src/dst mapping of files
Expand All @@ -124,8 +118,7 @@ def _get_files_generator(src_dir, files_list):


def _get_config(filename):
"""
Parse the provided YAML file and return a dict.
"""Parse the provided YAML file and return a dict.
:parse filename: A string containing the path to YAML file.
:return: dict
Expand All @@ -143,9 +136,7 @@ def _get_config(filename):


def _get_dst_dir(dst_dir):
"""
Prefix the provided string with working directory and return a
str.
"""Prefix the provided string with working directory and return a str.
:param dst_dir: A string to be prefixed with the working dir.
:return: str
Expand All @@ -157,20 +148,19 @@ def _get_dst_dir(dst_dir):


def _get_lock_file(name):
""" Return the lock file for the given name. """
"""Return the lock file for the given name. """
return os.path.join(
_get_lock_dir(),
name, )


def _get_base_dir():
""" Return gilt's base working directory. """
"""Return gilt's base working directory. """
return os.path.expanduser(BASE_WORKING_DIR)


def _get_lock_dir():
"""
Construct gilt's lock directory and return a str.
"""Construct gilt's lock directory and return a str.
:return: str
"""
Expand All @@ -180,8 +170,7 @@ def _get_lock_dir():


def _get_clone_dir():
"""
Construct gilt's clone directory and return a str.
"""Construct gilt's clone directory and return a str.
:return: str
"""
Expand All @@ -191,8 +180,7 @@ def _get_clone_dir():


def _makedirs(path):
"""
Create a base directory of the provided path and return None.
"""Create a base directory of the provided path and return None.
:param path: A string containing a path to be deconstructed and basedir
created.
Expand Down
25 changes: 7 additions & 18 deletions gilt/git.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2016 Cisco Systems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -30,8 +28,7 @@


def clone(name, repository, destination, debug=False):
"""
Clone the specified repository into a temporary directory and return None.
"""Clone the specified repository into a temporary directory and return None.
:param name: A string containing the name of the repository being cloned.
:param repository: A string containing the repository to clone.
Expand All @@ -47,9 +44,7 @@ def clone(name, repository, destination, debug=False):


def extract(repository, destination, version, debug=False):
"""
Extract the specified repository/version into the given directory and
return None.
"""Extract the specified repository/version into the directory and return None.
:param repository: A string containing the path to the repository to be
extracted.
Expand All @@ -75,9 +70,7 @@ def extract(repository, destination, version, debug=False):


def overlay(repository, files, version, debug=False):
"""
Overlay files from the specified repository/version into the given
directory and return None.
"""Overlay files from repository/version into the directory and return None.
:param repository: A string containing the path to the repository to be
extracted.
Expand Down Expand Up @@ -107,8 +100,7 @@ def overlay(repository, files, version, debug=False):


def _get_version(version, debug=False):
"""
Handle switching to the specified version and return None.
"""Handle switching to the specified version and return None.
1. Fetch the origin.
2. Checkout the specified version.
Expand All @@ -134,8 +126,7 @@ def _get_version(version, debug=False):


def _has_commit(version, debug=False):
"""
Determine a version is a local git commit sha or not.
"""Determine a version is a local git commit sha or not.
:param version: A string containing the branch/tag/sha to be determined.
:param debug: An optional bool to toggle debug output.
Expand All @@ -152,8 +143,7 @@ def _has_commit(version, debug=False):


def _has_tag(version, debug=False):
"""
Determine a version is a local git tag name or not.
"""Determine a version is a local git tag name or not.
:param version: A string containing the branch/tag/sha to be determined.
:param debug: An optional bool to toggle debug output.
Expand All @@ -169,8 +159,7 @@ def _has_tag(version, debug=False):


def _has_branch(version, debug=False):
"""
Determine a version is a local git branch name or not.
"""Determine a version is a local git branch name or not.
:param version: A string containing the branch/tag/sha to be determined.
:param debug: An optional bool to toggle debug output.
Expand Down
8 changes: 3 additions & 5 deletions gilt/shell.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2016 Cisco Systems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -32,7 +30,7 @@


class NotFoundError(Exception):
""" Error raised when a config can not be found. """
"""Error raised when a config can not be found. """
pass


Expand All @@ -48,7 +46,7 @@ class NotFoundError(Exception):
@click.version_option(version=gilt.__version__)
@click.pass_context
def main(ctx, config, debug): # pragma: no cover
""" gilt - A GIT layering tool. """
"""gilt - A GIT layering tool. """
ctx.obj = {}
ctx.obj['args'] = {}
ctx.obj['args']['debug'] = debug
Expand All @@ -58,7 +56,7 @@ def main(ctx, config, debug): # pragma: no cover
@click.command()
@click.pass_context
def overlay(ctx): # pragma: no cover
""" Install gilt dependencies """
"""Install gilt dependencies """
args = ctx.obj.get('args')
filename = args.get('config')
debug = args.get('debug')
Expand Down
14 changes: 5 additions & 9 deletions gilt/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2016 Cisco Systems, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -34,18 +32,17 @@


def print_info(msg):
""" Print the given message to STDOUT. """
"""Print the given message to STDOUT. """
print(msg)


def print_warn(msg):
""" Print the given message to STDOUT in YELLOW. """
"""Print the given message to STDOUT in YELLOW. """
print('{}{}'.format(colorama.Fore.YELLOW, msg))


def run_command(cmd, debug=False):
"""
Execute the given command and return None.
"""Execute the given command and return None.
:param cmd: A `sh.Command` object to execute.
:param debug: An optional bool to toggle debug output.
Expand All @@ -72,7 +69,7 @@ def build_sh_cmd(cmd, cwd=None):

@contextlib.contextmanager
def saved_cwd():
""" Context manager to restore previous working directory. """
"""Context manager to restore previous working directory. """
saved = os.getcwd()
try:
yield
Expand All @@ -81,8 +78,7 @@ def saved_cwd():


def copy(src, dst):
"""
Handle the copying of a file or directory.
"""Handle the copying of a file or directory.
The destination basedir _must_ exist.
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build-system]
requires = [
'setuptools >= 41.0.0',
'setuptools_scm >= 1.15.0',
'setuptools_scm_git_archive >= 1.0',
'wheel',
]
build-backend = 'setuptools.build_meta'
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

Loading

0 comments on commit 2613c82

Please sign in to comment.