Skip to content

Commit

Permalink
Merge branch 'release-0.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
sinoroc committed Jan 9, 2020
2 parents da6e695 + ebe2438 commit 5c14c00
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 75 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

.. Keep the current version number on line number 5
0.0.4
=====

20120-01-09

* Rewrite naming scheme for output files


0.0.3
=====

2019-09-30

* Add support for `tools_directory` setting
* Add support for ``tools_directory`` setting

* Use operating system's standard value for default location of the
configuration file
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ check:

.PHONY: lint
lint:
python3 -m pytest --codestyle --pylint -m 'codestyle or pylint'
python3 -m pytest --pycodestyle --pylint -m 'pycodestyle or pylint'


.PHONY: pycodestyle
pycodestyle:
python3 -m pytest --codestyle -m codestyle
python3 -m pytest --pycodestyle -m pycodestyle


.PHONY: pylint
Expand All @@ -65,7 +65,7 @@ pytest:

.PHONY: review
review: check
python3 -m pytest --codestyle --pylint
python3 -m pytest --pycodestyle --pylint


.PHONY: clean
Expand Down
97 changes: 85 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,19 @@ current working directory.
.. code::
[toolmaker.tool.defaults]
output_file_win = ${output_file}.pyz
tools_directory = ~/bin/.toolmaker
tools_directory = ~/.local/bin/.toolmaker
[toolmaker.tool.zapp:deptree.zapp]
[toolmaker.tool.zapp:deptree]
entry_point = deptree.cli:main
output_file = deptree
requirements =
deptree
[toolmaker.tool.pex:http.pex]
[toolmaker.tool.pex:http]
entry_point = http.server
output_file = http
requirements =
[toolmaker.tool.shiv:shiv.shiv]
[toolmaker.tool.shiv:shiv]
entry_point = shiv.cli:main
output_file = shiv
requirements =
shiv
Expand All @@ -67,11 +63,88 @@ The action can be specified on the command line. Either one of:
The default action when no flag is specified is to build the tools.


Tips
----
Configuration
=============

Place tools in current directory
--------------------------------

.. code::
[toolmaker.tool.defaults]
tools_directory =
tool_directory =
[toolmaker.tool.zapp:foo]
# ./foo
[toolmaker.tool.zapp:bar]
# ./bar
Place tools in specific directory
---------------------------------

.. code::
[toolmaker.tool.defaults]
tools_directory = /somewhere
tool_directory =
[toolmaker.tool.zapp:foo]
# /somewhere/foo
[toolmaker.tool.zapp:bar]
# /somewhere/bar
Place tools in subdirectories
-----------------------------

.. code::
[toolmaker.tool.defaults]
tools_directory = /somewhere
[toolmaker.tool.zapp:foo0]
# /somewhere/foo0/foo0
[toolmaker.tool.zapp:foo1]
tool_directory = foo0
# /somewhere/foo0/foo1
[toolmaker.tool.zapp:foo2]
# /somewhere/foo2/foo2
[toolmaker.tool.zapp:foo3]
tool_file = foo0
# /somewhere/foo3/foo0
Example to use with GNU stow
----------------------------

To use in combination with `GNU Stow`_:

.. code::
[toolmaker.tool.defaults]
tools_directory = ~/.local/bin/.toolmaker
[toolmaker.tool.zapp:foo0]
# ~/.local/bin/.toolmaker/foo0/foo0
[toolmaker.tool.zapp:foo1]
tool_directory = foo0
# ~/.local/bin/.toolmaker/foo0/foo1
[toolmaker.tool.zapp:foo2]
# ~/.local/bin/.toolmaker/foo2/foo2
[toolmaker.tool.zapp:foo3]
tool_file = foo0
# ~/.local/bin/.toolmaker/foo3/foo0
Place in a subdirectory of a directory that is available on your ``PATH``
(typically your ``~/bin`` directory) and use in combination with `GNU Stow`_.
Details
Expand Down
11 changes: 4 additions & 7 deletions example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@


[toolmaker.tool.defaults]
output_file_win = ${output_file}.pyz
tools_directory =

[toolmaker.tool.zapp:deptree.zapp]
[toolmaker.tool.zapp:deptree]
entry_point = deptree.cli:main
output_file = deptree
requirements =
deptree

[toolmaker.tool.pex:http.pex]
[toolmaker.tool.pex:http]
entry_point = http.server
output_file = http
requirements =

[toolmaker.tool.shiv:shiv.shiv]
[toolmaker.tool.shiv:shiv]
entry_point = shiv.cli:main
output_file = shiv
requirements =
shiv

Expand Down
10 changes: 6 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ author = sinoroc
author_email = [email protected]
description = toolmaker application
license = Apache-2.0
license_file = LICENSE.txt
long_description = file: README.rst
long_description_content_type = text/x-rst
project_urls =
GitLab = https://gitlab.com/sinoroc/toolmaker
GitHub = https://github.com/sinoroc/toolmaker
url = https://pypi.org/project/toolmaker/


[options]
install_requires =
importlib_metadata
pex[cachecontrol, requests]
importlib-metadata
pex
shiv
zapp
package_dir =
Expand All @@ -39,8 +43,6 @@ package =
wheel
zapp
test =
astroid<2.3
pylint<2.4
pytest
pytest-pycodestyle
pytest-pylint
Expand Down
50 changes: 21 additions & 29 deletions src/toolmaker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@


import argparse
import configparser
import logging

from . import _meta
from . import core
Expand Down Expand Up @@ -56,41 +54,35 @@ def _create_args_parser(default_config_path, tools_names=None):
def main():
""" CLI main function
"""
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

default_config_path = core.get_default_config_file_path()

args_parser = _create_args_parser(default_config_path)
args = args_parser.parse_args()

raw_config = None
config = None
if args.config:
logger.info("Reading configuration from file '%s'", args.config)
raw_config = configparser.ConfigParser(
default_section='{}.tool.defaults'.format(_meta.PROJECT_NAME),
interpolation=configparser.ExtendedInterpolation(),
)
try:
raw_config.read_file(args.config)
except configparser.Error as config_error:
config = core.parse_config(args.config)
except core.ConfigurationFileError as config_error:
args_parser.error(config_error)
config = core.parse_config(raw_config)

tools_names = list(config['tools'].keys())
if not args.all:
args_parser = _create_args_parser(default_config_path, tools_names)
args = args_parser.parse_args()

if args.tools:
tools_names = args.tools

if args.delete:
core.delete(config, tools_names)
elif args.rebuild:
core.build(config, tools_names, force=True)
else:
core.build(config, tools_names)
else:
tools_names = list(config['tools'].keys())
if not args.all:
args_parser = _create_args_parser(
default_config_path,
tools_names,
)
args = args_parser.parse_args()

if args.tools:
tools_names = args.tools

if args.delete:
core.delete(config, tools_names)
elif args.rebuild:
core.build(config, tools_names, force=True)
else:
core.build(config, tools_names)


# EOF
Loading

0 comments on commit 5c14c00

Please sign in to comment.