Skip to content

Commit

Permalink
Fixes #107: bug in init if no explicit --name is specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
hartym committed Mar 20, 2019
1 parent 2968033 commit 9681447
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 51 deletions.
16 changes: 14 additions & 2 deletions docs/_templates/alabaster/support.py
@@ -1,8 +1,20 @@
# flake8: noqa

from pygments.style import Style
from pygments.token import (Comment, Error, Generic, Keyword, Literal, Name, Number, Operator, Other, Punctuation,
String, Whitespace)
from pygments.token import (
Comment,
Error,
Generic,
Keyword,
Literal,
Name,
Number,
Operator,
Other,
Punctuation,
String,
Whitespace,
)


# Originally based on FlaskyStyle which was based on 'tango'.
Expand Down
2 changes: 1 addition & 1 deletion medikit/commands/init.py
Expand Up @@ -44,7 +44,7 @@ def handle(config_filename, **options):
# - ...
with _change_working_directory(config_dirname):
dispatcher = LoggingDispatcher()
initializer = ProjectInitializer(dispatcher, options)
initializer = ProjectInitializer(dispatcher, options, target=config_dirname)
initializer.execute()
from medikit.commands import UpdateCommand

Expand Down
23 changes: 15 additions & 8 deletions medikit/feature/__init__.py
Expand Up @@ -113,23 +113,30 @@ def get_config(self, event, feature=None):


class ProjectInitializer(Feature):
def __init__(self, dispatcher, options):
def __init__(self, dispatcher, options, target=None):
super().__init__(dispatcher)
self.options = options
self.target = target

def execute(self):
context = {}
context = {"name": ""}

if self.options.get("name"):
if not is_identifier(self.options["name"]):
raise RuntimeError("Invalid package name {!r}.".format(self.options["name"]))
raise RuntimeError(
"Invalid package name {!r}. Please only use valid python identifiers.".format(self.options["name"])
)
context["name"] = self.options["name"]
logging.info("name = %s", context["name"])
else:
elif self.target:
context["name"] = os.path.basename(self.target)

while not is_identifier(context["name"]):
context["name"] = input("Name: ")
while not is_identifier(context["name"]):
logging.error("Invalid name. Please only use valid python identifiers.")
context["name"] = input("Name: ")
logging.error(
"Invalid package name {!r}. Please only use valid python identifiers.".format(context["name"])
)

logging.info("name = %s", context["name"])

if self.options.get("description"):
context["description"] = self.options["description"]
Expand Down
88 changes: 48 additions & 40 deletions setup.py
Expand Up @@ -20,70 +20,78 @@ def execfile(fname, globs, locs=None):

# Get the long description from the README file
try:
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()
except:
long_description = ''
long_description = ""

# Get the classifiers from the classifiers file
tolines = lambda c: list(filter(None, map(lambda s: s.strip(), c.split('\n'))))
tolines = lambda c: list(filter(None, map(lambda s: s.strip(), c.split("\n"))))
try:
with open(path.join(here, 'classifiers.txt'), encoding='utf-8') as f:
with open(path.join(here, "classifiers.txt"), encoding="utf-8") as f:
classifiers = tolines(f.read())
except:
classifiers = []

version_ns = {}
try:
execfile(path.join(here, 'medikit/_version.py'), version_ns)
execfile(path.join(here, "medikit/_version.py"), version_ns)
except EnvironmentError:
version = 'dev'
version = "dev"
else:
version = version_ns.get('__version__', 'dev')
version = version_ns.get("__version__", "dev")

setup(
author='Romain Dorgueil',
author_email='romain@dorgueil.net',
description='Opinionated python 3.5+ project management.',
license='Apache License, Version 2.0',
name='medikit',
python_requires='>=3.5',
author="Romain Dorgueil",
author_email="romain@dorgueil.net",
description="Opinionated python 3.5+ project management.",
license="Apache License, Version 2.0",
name="medikit",
python_requires=">=3.5",
version=version,
long_description=long_description,
classifiers=classifiers,
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
packages=find_packages(exclude=["ez_setup", "example", "test"]),
include_package_data=True,
install_requires=[
'git-semver ~= 0.2.3', 'jinja2 ~= 2.9', 'mondrian ~= 0.7',
'packaging ~= 19.0', 'pip-tools ~= 3.0', 'stevedore ~= 1.28',
'whistle ~= 1.0', 'yapf ~= 0.20'
"git-semver ~= 0.2.3",
"jinja2 ~= 2.9",
"mondrian ~= 0.7",
"packaging ~= 19.0",
"pip-tools ~= 3.0",
"stevedore ~= 1.28",
"whistle ~= 1.0",
"yapf ~= 0.20",
],
extras_require={
'dev': [
'coverage ~= 4.4', 'isort', 'pytest ~= 3.4', 'pytest-cov ~= 2.5',
'releases >= 1.6, < 1.7', 'sphinx ~= 1.7', 'sphinx-sitemap ~= 1.0'
"dev": [
"coverage ~= 4.4",
"isort",
"pytest ~= 3.4",
"pytest-cov ~= 2.5",
"releases >= 1.6, < 1.7",
"sphinx ~= 1.7",
"sphinx-sitemap ~= 1.0",
]
},
entry_points={
'console_scripts': ['medikit=medikit.__main__:main'],
'medikit.feature': [
'django = medikit.feature.django:DjangoFeature',
'docker = medikit.feature.docker:DockerFeature',
'format = medikit.feature.format:FormatFeature',
'git = medikit.feature.git:GitFeature',
'kube = medikit.feature.kube:KubeFeature',
'make = medikit.feature.make:MakeFeature',
'nodejs = medikit.feature.nodejs:NodeJSFeature',
'pylint = medikit.feature.pylint:PylintFeature',
'pytest = medikit.feature.pytest:PytestFeature',
'python = medikit.feature.python:PythonFeature',
'sphinx = medikit.feature.sphinx:SphinxFeature',
'webpack = medikit.feature.webpack:WebpackFeature',
'yapf = medikit.feature.yapf:YapfFeature'
]
"console_scripts": ["medikit=medikit.__main__:main"],
"medikit.feature": [
"django = medikit.feature.django:DjangoFeature",
"docker = medikit.feature.docker:DockerFeature",
"format = medikit.feature.format:FormatFeature",
"git = medikit.feature.git:GitFeature",
"kube = medikit.feature.kube:KubeFeature",
"make = medikit.feature.make:MakeFeature",
"nodejs = medikit.feature.nodejs:NodeJSFeature",
"pylint = medikit.feature.pylint:PylintFeature",
"pytest = medikit.feature.pytest:PytestFeature",
"python = medikit.feature.python:PythonFeature",
"sphinx = medikit.feature.sphinx:SphinxFeature",
"webpack = medikit.feature.webpack:WebpackFeature",
"yapf = medikit.feature.yapf:YapfFeature",
],
},
url='https://python-medikit.github.io/',
download_url=
'https://github.com/python-medikit/medikit/archive/{version}.tar.gz'.
format(version=version),
url="https://python-medikit.github.io/",
download_url="https://github.com/python-medikit/medikit/archive/{version}.tar.gz".format(version=version),
)

0 comments on commit 9681447

Please sign in to comment.