Renamed ConfigFactory -> Config

This commit is contained in:
Matthew Planchard 2018-07-18 19:36:52 -05:00
parent 915a64cc54
commit 26d35cd9e9
8 changed files with 24 additions and 25 deletions

@ -15,7 +15,7 @@ New Features
- Dockerfile, ``docker-compose`` example, and Docker Hub integration for
automatic builds.
- New ``config`` module with ``argparse``-based ``ConfigFactory`` class.
- New ``config`` module with ``argparse``-based ``Config`` class.
Essential for further improvements in pluggability!
- New ``pypiserver`` command interface (as opposed to ``pypi-server``),
@ -31,7 +31,7 @@ Deprecations
- The ``pypiserver.app()`` interface now takes a ``config`` object as its
primary argument. Configuration keyword arguments are deprecated and the
capacity to specify them will be removed in the next major release. Use
``pypiserver.config.ConfigFactory().from_kwargs()`` instead.
``pypiserver.config.Config().from_kwargs()`` instead.
Backwards Incompatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -44,17 +44,17 @@ Backwards Incompatible Changes
**Removed:**
- ``pypiserver.Config`` - use ``pypiserver.config.ConfigFactory`` instead.
- ``pypiserver.Config`` - use ``pypiserver.config.Config`` instead.
- ``pypiserver.default_config()`` - use
``pypiserver.config.ConfigFactory().get_default()`` instead.
``pypiserver.config.Config().get_default()`` instead.
- ``pypiserver.DEFAULT_SERVER`` - use
``pypiserver.config.ConfigFactory().get_default().server`` if this is for
``pypiserver.config.Config().get_default().server`` if this is for
some reason necessary
- ``pypiserver.__main__.usage()`` - use
``pyiserver.config.ConfigFactory().get_parser().print_help()``
``pyiserver.config.Config().get_parser().print_help()``
**Moved:**

@ -13,11 +13,10 @@ import warnings
import pypiserver
from pypiserver import bottle
from pypiserver.config import ConfigFactory
from pypiserver.config import Config
from pypiserver.const import PY2
log = logging.getLogger('pypiserver.main')
@ -102,7 +101,7 @@ def main(argv=None):
))
if PY2:
warnings.filterwarnings('default', category=DeprecationWarning)
config = ConfigFactory(
config = Config(
parser_type='pypi-server'
).get_parser().parse_args(args=argv)
_run_app_from_config(config)
@ -110,7 +109,7 @@ def main(argv=None):
def _new_main():
"""Run the new pypiserver command."""
_run_app_from_config(ConfigFactory().get_parsed())
_run_app_from_config(Config().get_parsed())
if __name__ == "__main__":

@ -60,7 +60,7 @@ def app(config=None, auther=None, **kwargs):
if kwargs:
warn(DeprecationWarning(
'Passing arbitrary keyword arguments to app() has been '
'deprecated. Please use config.ConfigFactory to generate '
'deprecated. Please use config.Config to generate '
'a config and pass it to this function.'
))
for key, value in kwargs:

@ -151,7 +151,7 @@ class _PypiserverParser(ArgumentParser):
return parsed
class ConfigFactory(object):
class Config(object):
"""Factory for pypiserver configs and parsers."""
def __init__(self, parser_cls=_PypiserverParser,

@ -3,7 +3,7 @@
import os
from ._app import app
from .config import str2bool, ConfigFactory
from .config import str2bool, Config
def _str_strip(string):
@ -46,7 +46,7 @@ def paste_app_factory(global_config, **local_conf):
return os.path.expanduser(root)
return root
c = ConfigFactory(
c = Config(
parser_type='pypi-server'
).get_parser().parse_args([])

@ -32,7 +32,7 @@ hp = HTMLParser()
@pytest.fixture
def app(tmpdir):
conf = config.ConfigFactory(
conf = config.Config(
parser_type='pypi-server'
).get_parser().parse_args(
['-a', '.', tmpdir.strpath]
@ -41,7 +41,7 @@ def app(tmpdir):
def app_from_args(args):
conf = config.ConfigFactory(
conf = config.Config(
parser_type='pypi-server'
).get_parser().parse_args(args)
return pypiserver.app(conf)

@ -105,7 +105,7 @@ class TestDeprecatedParser:
@pytest.fixture()
def parser(self):
"""Return a deprecated parser."""
return config.ConfigFactory(parser_type='pypi-server').get_parser()
return config.Config(parser_type='pypi-server').get_parser()
def test_version_exits(self, parser):
"""Test that asking for the version exits the program."""
@ -229,7 +229,7 @@ class TestDeprecatedParser:
'resource_filename',
Mock(side_effect=NotImplementedError)
)
assert config.ConfigFactory(
assert config.Config(
parser_type='pypi-server'
).get_parser().parse_args([]).welcome_file == const.STANDALONE_WELCOME
@ -326,7 +326,7 @@ class TestParser:
@pytest.fixture()
def parser(self):
"""Return a deprecated parser."""
return config.ConfigFactory().get_parser()
return config.Config().get_parser()
# **********************************************************************
# Root Command
@ -509,7 +509,7 @@ class TestParser:
'resource_filename',
Mock(side_effect=NotImplementedError)
)
assert config.ConfigFactory().get_parser().parse_args(
assert config.Config().get_parser().parse_args(
['run']
).welcome_file == const.STANDALONE_WELCOME
@ -610,7 +610,7 @@ class TestReadyMades(object):
def test_get_default(self):
"""Test getting the default config."""
conf = config.ConfigFactory().get_default()
conf = config.Config().get_default()
assert any(d in conf for d in vars(config._Defaults))
for default, value in vars(config._Defaults).items():
if default in conf:
@ -627,7 +627,7 @@ class TestReadyMades(object):
def test_get_default_specify_subcommand(self):
"""Test getting default args for a non-default subcommand."""
conf = config.ConfigFactory().get_default(subcommand='update')
conf = config.Config().get_default(subcommand='update')
exp_defaults = (
('execute', False),
('pre', False),
@ -643,12 +643,12 @@ class TestReadyMades(object):
'argv',
['pypiserver', 'run', '--interface', '1.2.3.4']
)
conf = config.ConfigFactory().get_parsed()
conf = config.Config().get_parsed()
assert conf.host == '1.2.3.4'
def test_from_kwargs(self):
"""Test getting a default config updated with provided kwargs."""
conf = config.ConfigFactory().from_kwargs(
conf = config.Config().from_kwargs(
port=9999,
foo='foo',
)

@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
def test_app_factory(monkeypatch, tmpdir):
"""Test creating an app."""
conf = pypiserver.config.ConfigFactory(
conf = pypiserver.config.Config(
parser_type='pypi-server'
).get_parser().parse_args([str(tmpdir)])
assert pypiserver.app(conf) is not pypiserver.app(conf)