Skip to content

Commit

Permalink
Merge pull request #49 from xsnippet/xsnippet.api
Browse files Browse the repository at this point in the history
Use xsnippet.api namespace instead of xsnippet_api
  • Loading branch information
malor committed Dec 23, 2017
2 parents 377ed34 + bdee434 commit ea5a0b0
Show file tree
Hide file tree
Showing 28 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[run]
branch = true
source = xsnippet_api/
source = xsnippet/
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ matrix:
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- env: TOXENV=openapi
- python: 3.6
env: TOXENV=openapi
- python: 3.6
env: TOXENV=docs

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ recursive-exclude * __pycache__
recursive-exclude * *.py[co]
recursive-exclude * .DS_Store

recursive-include xsnippet_api *.conf
recursive-include xsnippet *.conf
2 changes: 1 addition & 1 deletion contrib/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RUN pip install .
ENV XSNIPPET_API_SETTINGS=/etc/xsnippet-api.conf

EXPOSE 8000
ENTRYPOINT ["python", "-m", "xsnippet_api"]
ENTRYPOINT ["python", "-m", "xsnippet.api"]
17 changes: 12 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
# coding: utf-8

import os
from setuptools import setup, find_packages
from setuptools import setup, find_packages as _find_packages

from xsnippet_api import __version__ as version
from xsnippet_api import __license__ as license
from xsnippet.api import __version__ as version
from xsnippet.api import __license__ as license


here = os.path.dirname(__file__)
with open(os.path.join(here, 'README.rst'), 'r', encoding='utf-8') as f:
long_description = f.read()


# Unfortunately setuptools.find_packages() doesn't support PEP-420 namespace
# packages so we need our own implementation that does. All this shit happened
# due to desperate @ikalnytskyi's desire to use namespace packages.
def find_packages(namespace):
return ['%s.%s' % (namespace, pkg) for pkg in _find_packages(namespace)]


setup(
name='xsnippet-api',
version=version,
Expand All @@ -25,7 +32,7 @@
keywords='web-service restful-api snippet storage',
author='The XSnippet Team',
author_email='dev@xsnippet.org',
packages=find_packages(exclude=['docs', 'tests*']),
packages=find_packages('xsnippet'),
include_package_data=True,
zip_safe=False,
setup_requires=[
Expand All @@ -43,7 +50,7 @@
],
entry_points={
'console_scripts': [
'xsnippet-api = xsnippet_api.__main__:main',
'xsnippet-api = xsnippet.api.__main__:main',
],
},
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion tests/middlewares/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import jose.jwt as jwt
import pytest

from xsnippet_api import middlewares
from xsnippet.api import middlewares
from tests import AIOTestMeta, AIOTestApp


Expand Down
6 changes: 3 additions & 3 deletions tests/resources/test_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import pkg_resources
import pytest

from xsnippet_api.application import create_app
from xsnippet_api.conf import get_conf
from xsnippet.api.application import create_app
from xsnippet.api.conf import get_conf
from tests import AIOTestMeta, AIOTestApp


Expand Down Expand Up @@ -52,7 +52,7 @@ def setup(self):
]

conf = get_conf(
pkg_resources.resource_filename('xsnippet_api', 'default.conf'))
pkg_resources.resource_filename('xsnippet.api', 'default.conf'))
conf['auth'] = {'secret': 'SWORDFISH'}
self.app = create_app(conf)

Expand Down
10 changes: 5 additions & 5 deletions tests/services/test_snippet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import pkg_resources
import pytest

from xsnippet_api.database import create_connection
from xsnippet_api.conf import get_conf
from xsnippet_api.services import Snippet
from xsnippet_api import exceptions
from xsnippet.api.database import create_connection
from xsnippet.api.conf import get_conf
from xsnippet.api.services import Snippet
from xsnippet.api import exceptions

from tests import AIOTestMeta

Expand All @@ -26,7 +26,7 @@ class TestSnippet(metaclass=AIOTestMeta):

async def setup(self):
conf = get_conf(
pkg_resources.resource_filename('xsnippet_api', 'default.conf'))
pkg_resources.resource_filename('xsnippet.api', 'default.conf'))
self.db = create_connection(conf)
self.service = Snippet(self.db)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import pytest
import pkg_resources

from xsnippet_api import application, conf
from xsnippet_api.middlewares import auth
from xsnippet.api import application, conf
from xsnippet.api.middlewares import auth
from tests import AIOTestMeta, AIOTestApp


class TestApplication(metaclass=AIOTestMeta):

conf = conf.get_conf(
pkg_resources.resource_filename('xsnippet_api', 'default.conf'))
pkg_resources.resource_filename('xsnippet.api', 'default.conf'))
conf['auth'] = {'secret': 'SWORDFISH'}

def setup(self):
Expand All @@ -45,7 +45,7 @@ async def test_http_vary_header(self, name, value):

async def test_auth_secret_is_generated_if_not_set(self):
app_conf = conf.get_conf(
pkg_resources.resource_filename('xsnippet_api', 'default.conf'))
pkg_resources.resource_filename('xsnippet.api', 'default.conf'))
app_conf['auth'] = {'secret': ''}

app = application.create_app(app_conf)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import aiohttp.web as web
import pkg_resources

from xsnippet_api import conf, database, resource
from xsnippet.api import conf, database, resource
from tests import AIOTestMeta, AIOTestApp


Expand All @@ -30,7 +30,7 @@ async def post(self):
class TestResource(metaclass=AIOTestMeta):

conf = conf.get_conf(
pkg_resources.resource_filename('xsnippet_api', 'default.conf'))
pkg_resources.resource_filename('xsnippet.api', 'default.conf'))

def setup(self):
self.app = web.Application()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest

from aiohttp import web
from xsnippet_api import router
from xsnippet.api import router

from tests import AIOTestMeta, AIOTestApp

Expand Down
5 changes: 1 addition & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[tox]
skipsdist = true
envlist = py3, openapi, docs

[testenv]
usedevelop = true
deps =
pytest
pytest-cov
Expand All @@ -14,7 +12,7 @@ commands =
{envpython} -m pytest {posargs:.} --cov --cov-append --strict

[testenv:openapi]
usedevelop = false
basepython = python3
deps = flex
commands =
swagger-flex -s contrib/openapi/spec.yml
Expand All @@ -29,7 +27,6 @@ commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/

[testenv:docker-build]
usedevelop = false
basepython = python3
deps =
whitelist_externals = bash
Expand Down
2 changes: 1 addition & 1 deletion xsnippet_api/__init__.py → xsnippet/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api
xsnippet.api
------------
The project implements XSnippet RESTful API, using aiohttp framework.
Expand Down
8 changes: 4 additions & 4 deletions xsnippet_api/__main__.py → xsnippet/api/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.__main__
xsnippet.api.__main__
---------------------
The module contains application runner that starts XSnippet API
Expand All @@ -14,8 +14,8 @@

from aiohttp import web

from xsnippet_api.application import create_app
from xsnippet_api.conf import get_conf
from xsnippet.api.application import create_app
from xsnippet.api.conf import get_conf


def main(args=sys.argv[1:]):
Expand All @@ -29,7 +29,7 @@ def main(args=sys.argv[1:]):
port=int(conf['server']['port']))


# let's make this module and xsnippet_api package to be executable, so
# let's make this module and xsnippet.api package to be executable, so
# anyone can run it without entry_points' console script
if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.application
xsnippet.api.application
------------------------
Provides a factory function to create an application instance,
Expand Down
2 changes: 1 addition & 1 deletion xsnippet_api/conf.py → xsnippet/api/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.conf
xsnippet.api.conf
-----------------
The module provides a function that gathers application settings
Expand Down
2 changes: 1 addition & 1 deletion xsnippet_api/database.py → xsnippet/api/database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.database
xsnippet.api.database
---------------------
Provides a factory function that creates a database connection
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion xsnippet_api/exceptions.py → xsnippet/api/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.exceptions
xsnippet.api.exceptions
-----------------------
The module contains a set of XSnipet's exceptions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.middlewares
xsnippet.api.middlewares
------------------------
The package contains various helper middlewares used by the application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.middlewares.auth
xsnippet.api.middlewares.auth
-----------------------------
The module implements auth middleware that performs authentication
Expand Down
4 changes: 2 additions & 2 deletions xsnippet_api/resource.py → xsnippet/api/resource.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
xsnippet_api.resource
xsnippet.api.resource
---------------------
The module provides a base class of RESTful API resources. It's not
exposed via :ref:`xsnippet_api.resources` package, and is intended
exposed via :ref:`xsnippet.api.resources` package, and is intended
for internal usage only.
:copyright: (c) 2016 The XSnippet Team, see AUTHORS for details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.resources
xsnippet.api.resources
----------------------
The package contains implementations of RESTful API resources.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.resources.misc
xsnippet.api.resources.misc
---------------------------
Various misc stuff that is used internally by other modules of the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.resources.snippets
xsnippet.api.resources.snippets
-------------------------------
The module implements snippets resource that provides CRUD interface
Expand Down
2 changes: 1 addition & 1 deletion xsnippet_api/router.py → xsnippet/api/router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.router
xsnippet.api.router
-------------------
Provides an aiohttp router class for API versioning. In its depth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.services
xsnippet.api.services
---------------------
:copyright: (c) 2016 The XSnippet Team, see AUTHORS for details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
xsnippet_api.services.snippet
xsnippet.api.services.snippet
-----------------------------
Snippet service implements domain business logic for managing
Expand Down

0 comments on commit ea5a0b0

Please sign in to comment.