Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Commit

Permalink
global: package structure update
Browse files Browse the repository at this point in the history
* Fixes doctests.  (closes #21)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
  • Loading branch information
jirikuncar committed Jul 7, 2016
1 parent 14731f5 commit 699f8fd
Show file tree
Hide file tree
Showing 40 changed files with 146 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
source = flask_registry
source = flask_registry
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ coverage.xml
*.pot

# Sphinx documentation
docs/_build/
docs/_build/
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2015, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand All @@ -12,14 +12,12 @@ language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"

install:
- pip install --upgrade pip
- pip install pytest pytest-pep8 pytest-cov pytest-cache
- pip install coveralls sphinx
- pip install .
- pip install .[all]

script:
- sphinx-build -qnNW docs docs/_build/html
Expand Down
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Version 0.2.0 (released 2014-06-27)

Version 0.1
-----------
- Initial public release
- Initial public release
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Flask-Registry is free software; you can redistribute it and/or modify
it under the terms of the Revised BSD License quoted below.

Copyright (C) 2013, 2014, 2015 CERN.
Copyright (C) 2013, 2014, 2016 CERN.

All rights reserved.

Expand Down
9 changes: 6 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
# file for more details.

include *.rst
include .coveragerc .gitmodules run-tests.sh
include LICENSE AUTHORS CHANGES README.rst
include .coveragerc run-tests.sh
include docs/*.rst docs/*.py docs/Makefile
include pytest.ini
include tests/*.py
include tests/resources/testresource.cfg
recursive-include docs/_themes *.py *.css *.css_t *.conf *.html README
include tox.ini
recursive-include docs/_templates *.html
recursive-include docs/_themes *.py *.css *.css_t *.conf *.html README
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down
2 changes: 1 addition & 1 deletion docs/_templates/sidebarintro.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ <h3>Useful Links</h3>
</ul>

<a href="http://github.com/inveniosoftware/flask-registry"><img style="position: fixed; top: 0; right: 0; border: 0;"
src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.. _changes:

.. include:: ../CHANGES
.. include:: ../CHANGES
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
# file for more details.

import sys
import os
import re
import sys

sys.path.append(os.path.abspath('_themes'))
sys.path.append(os.path.abspath(os.path.join('..', 'tests')))


# If extensions (or modules to document with autodoc) are in another directory,
Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Flask application factory to create and easily extensible application.
Following is a small example how a Flask application can be assemble from
reusable packages that each provides configuration, extensions and blueprints:

.. literalinclude:: ../tests/example_app.py
.. literalinclude:: ../tests/registry_module/example_app.py

Save this in a file named ``app.py`` next to the ``tests`` folder in the
Flask-Registry distribution and run it using your Python interpreter.
Expand All @@ -52,7 +52,7 @@ Flask-Registry distribution and run it using your Python interpreter.
Hello from Flask-Registry

The blueprint is loaded from ``tests.views`` and only works if the extension
``tests.mockext`` and the configuration in ``tests.config`` has been loaded.
``registry_module.mockext`` and the configuration in ``registry_module.config`` has been loaded.

See :ref:`application-discovery` for full explanation on what is
happening in the example.
2 changes: 1 addition & 1 deletion flask_registry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down
2 changes: 1 addition & 1 deletion flask_registry/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down
2 changes: 1 addition & 1 deletion flask_registry/registries/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down
42 changes: 21 additions & 21 deletions flask_registry/registries/appdiscovery.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2015, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
# file for more details.

"""
Application discovery registries.
"""Application discovery registries.
They provide discovery functionality useful for dynamically constructing Flask
applications based on configuration variables. This allows a developer to
package config, blueprints and extensions into isolated and reusable packages
which a framework can dynamically install into a Flask application.
Such a package (named ``tests``) could look like:
Such a package (named ``registry_module``) could look like and it is located
in ``tests`` directory:
* ``tests.views`` -- contains blueprints which should be registered on the
application object.
* ``tests.mockext`` -- contains a ``setup_app()`` method which be used to
install any Flask extensions on the application object.
* ``tests.config`` -- contains configuration variables specific for this
module.
* ``registry_module.views`` -- contains blueprints which should be registered
on the application object.
* ``registry_module.mockext`` -- contains a ``setup_app()`` method which be
used to install any Flask extensions on the application object.
* ``registry_module.config`` -- contains configuration variables specific for
this module.
Following is a simplified example of a Flask application factory, that will
load config, extensions and blueprints:
Expand All @@ -35,8 +35,8 @@
>>> from flask_registry import ConfigurationRegistry
>>> from flask_registry import BlueprintAutoDiscoveryRegistry
>>> class Config(object):
... PACKAGES = ['tests']
... EXTENSIONS = ['tests.mockext']
... PACKAGES = ['registry_module']
... EXTENSIONS = ['registry_module.mockext']
... USER_CFG = True
>>> def create_app(config):
... app = Flask('myapp')
Expand All @@ -60,7 +60,7 @@
>>> for pkg in app.extensions['registry']['packages']:
... print(pkg)
tests
registry_module
Extensions
^^^^^^^^^^
Expand All @@ -72,7 +72,7 @@
>>> for pkg in app.extensions['registry']['extensions']:
... print(pkg)
tests.mockext
registry_module.mockext
Configuration
^^^^^^^^^^^^^
Expand All @@ -84,8 +84,8 @@
>>> config.USER_CFG
True
>>> import tests.config
>>> tests.config.USER_CFG
>>> import registry_module.config
>>> registry_module.config.USER_CFG
False
>>> app.config['USER_CFG']
True
Expand All @@ -100,7 +100,7 @@
.. doctest::
>>> from tests import views
>>> from registry_module import views
>>> isinstance(views.blueprint, Blueprint)
True
>>> len(views.blueprints)
Expand All @@ -115,12 +115,12 @@

from __future__ import absolute_import

from werkzeug.utils import import_string
from flask import Blueprint, Config
from werkzeug.utils import import_string

from .core import ListRegistry, ImportPathRegistry
from .modulediscovery import ModuleDiscoveryRegistry, \
ModuleAutoDiscoveryRegistry
from .core import ImportPathRegistry, ListRegistry
from .modulediscovery import (ModuleAutoDiscoveryRegistry,
ModuleDiscoveryRegistry)


# pylint: disable=R0921
Expand Down
10 changes: 4 additions & 6 deletions flask_registry/registries/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand All @@ -23,18 +23,16 @@

from werkzeug.utils import find_modules, import_string

from .. import RegistryBase, RegistryError

try:
from collections import Sequence, MutableMapping
except ImportError:
from collections.abs import Sequence, MutableMapping

from .. import RegistryBase, RegistryError


class ListRegistry(RegistryBase, Sequence):

"""
Basic registry that just keeps a list of objects.
"""Basic registry that just keeps a list of objects.
Provides normal list-style access to the registry:
Expand Down
13 changes: 7 additions & 6 deletions flask_registry/registries/modulediscovery.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down Expand Up @@ -31,7 +31,7 @@
.. doctest::
>>> r['mypackages'] = ImportPathRegistry(initial=['tests'])
>>> r['mypackages'] = ImportPathRegistry(initial=['registry_module'])
Then, initialize the ``ModuleDiscoveryRegistry`` and run the discovery:
Expand All @@ -56,7 +56,7 @@
>>> app = Flask('myapp')
>>> r = Registry(app=app)
>>> pkg_proxy = RegistryProxy('mypackages', ImportPathRegistry,
... initial=['tests'])
... initial=['registry_module'])
>>> mod_proxy = RegistryProxy('mydiscoveredmodules',
... ModuleDiscoveryRegistry,
... 'helpers',
Expand All @@ -77,12 +77,13 @@
from __future__ import absolute_import

import sys

import six
from werkzeug.utils import find_modules, import_string
from werkzeug._compat import reraise
from flask import current_app, has_app_context
from werkzeug._compat import reraise
from werkzeug.utils import find_modules, import_string

from .. import RegistryProxy, RegistryBase, RegistryError
from .. import RegistryBase, RegistryError, RegistryProxy
from .core import ModuleRegistry


Expand Down
7 changes: 4 additions & 3 deletions flask_registry/registries/pkgresources.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down Expand Up @@ -70,7 +70,7 @@
>>> r = Registry(app=app)
>>> from flask_registry import ImportPathRegistry
>>> from flask_registry import PkgResourcesDirDiscoveryRegistry
>>> r['packages'] = ImportPathRegistry(initial=['tests'])
>>> r['packages'] = ImportPathRegistry(initial=['registry_module'])
>>> r['res'] = PkgResourcesDirDiscoveryRegistry('resources', app=app)
>>> os.path.basename(r['res'][0]) == 'testresource.cfg'
True
Expand All @@ -79,8 +79,9 @@
from __future__ import absolute_import

import os

from pkg_resources import iter_entry_points, resource_isdir, resource_listdir
from werkzeug.utils import import_string
from pkg_resources import iter_entry_points, resource_listdir, resource_isdir

from .core import DictRegistry
from .modulediscovery import ModuleAutoDiscoveryRegistry
Expand Down
2 changes: 1 addition & 1 deletion flask_registry/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Registry
# Copyright (C) 2013, 2014, 2015 CERN.
# Copyright (C) 2013, 2014, 2016 CERN.
#
# Flask-Registry is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
pep8ignore = tests/syntaxerror_*.py ALL
pep8ignore = tests/registry_module/syntaxerror_*.py ALL
addopts = --pep8 --ignore=docs --cov=flask_registry --cov-report=term-missing

0 comments on commit 699f8fd

Please sign in to comment.