From 17c83e994dd864e0db1ac1db64899d5cc6bbe275 Mon Sep 17 00:00:00 2001 From: Peter Balland Date: Tue, 7 Jan 2014 14:04:28 -0800 Subject: [PATCH] Restructure to follow OpenStack cookiecutter template Change-Id: I337e1fa6d4ff3efa30ca50fda5c5fe9dd96d7b3c --- .coveragerc | 7 ++ .gitignore | 53 ++++++++++++- .gitreview | 4 + .mailmap | 3 + .testr.conf | 7 ++ CONTRIBUTING.rst | 17 +++++ HACKING.rst | 4 + LICENSE | 1 - MANIFEST.in | 6 ++ README | 19 ----- README.rst | 24 ++++++ babel.cfg | 1 + congress/__init__.py | 19 +++++ {src => congress}/policy/Congress.g | 0 {src => congress}/policy/__init__.py | 0 {src => congress}/policy/compile.py | 0 {src => congress}/policy/runtime.py | 0 {src => congress}/policy/tests/__init__.py | 0 .../policy/tests/test_compiler.py | 0 .../policy/tests/test_runtime.py | 0 {src => congress}/policy/unify.py | 0 {src => congress}/server/__init__.py | 0 {src => congress}/server/ad_sync.py | 0 {src => congress}/server/server.py | 0 {src => congress}/server/webservice.py | 0 {src => congress}/server/wsgi.py | 0 congress/tests/__init__.py | 13 ++++ congress/tests/base.py | 53 +++++++++++++ .../tests}/functional/test_api.py | 0 congress/tests/test_congress.py | 28 +++++++ doc/source/conf.py | 75 +++++++++++++++++++ doc/source/contributing.rst | 1 + doc/source/index.rst | 24 ++++++ doc/source/installation.rst | 12 +++ doc/source/readme.rst | 1 + doc/source/usage.rst | 7 ++ openstack-common.conf | 7 ++ requirements.txt | 2 + setup.cfg | 46 ++++++++++++ setup.py | 22 ++++++ test-requirements.txt | 11 +++ tox.ini | 34 +++++++++ 42 files changed, 480 insertions(+), 21 deletions(-) create mode 100644 .coveragerc create mode 100644 .gitreview create mode 100644 .mailmap create mode 100644 .testr.conf create mode 100644 CONTRIBUTING.rst create mode 100644 HACKING.rst create mode 100644 MANIFEST.in delete mode 100644 README create mode 100644 README.rst create mode 100644 babel.cfg create mode 100644 congress/__init__.py rename {src => congress}/policy/Congress.g (100%) rename {src => congress}/policy/__init__.py (100%) rename {src => congress}/policy/compile.py (100%) rename {src => congress}/policy/runtime.py (100%) rename {src => congress}/policy/tests/__init__.py (100%) rename {src => congress}/policy/tests/test_compiler.py (100%) rename {src => congress}/policy/tests/test_runtime.py (100%) rename {src => congress}/policy/unify.py (100%) rename {src => congress}/server/__init__.py (100%) rename {src => congress}/server/ad_sync.py (100%) rename {src => congress}/server/server.py (100%) rename {src => congress}/server/webservice.py (100%) rename {src => congress}/server/wsgi.py (100%) create mode 100644 congress/tests/__init__.py create mode 100644 congress/tests/base.py rename {tests => congress/tests}/functional/test_api.py (100%) create mode 100644 congress/tests/test_congress.py create mode 100755 doc/source/conf.py create mode 100644 doc/source/contributing.rst create mode 100644 doc/source/index.rst create mode 100644 doc/source/installation.rst create mode 100644 doc/source/readme.rst create mode 100644 doc/source/usage.rst create mode 100644 openstack-common.conf create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100755 setup.py create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..8a350cd80 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = True +source = congress +omit = congress/tests/*,congress/openstack/* + +[report] +ignore-errors = True \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7b8a98af0..574e38734 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,56 @@ -*.pyc +# Congress build/runtime artifacts /Congress.tokens /src/policy/CongressLexer.py /src/policy/CongressParser.py +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +.testrepository + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +doc/build + +# pbr generates these +AUTHORS +ChangeLog + +# Editors +*~ +.*.swp diff --git a/.gitreview b/.gitreview new file mode 100644 index 000000000..6655fb285 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/congress.git diff --git a/.mailmap b/.mailmap new file mode 100644 index 000000000..cc92f17b8 --- /dev/null +++ b/.mailmap @@ -0,0 +1,3 @@ +# Format is: +# +# \ No newline at end of file diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 000000000..fb622677a --- /dev/null +++ b/.testr.conf @@ -0,0 +1,7 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list \ No newline at end of file diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 000000000..3d89987ce --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,17 @@ +If you would like to contribute to the development of OpenStack, +you must follow the steps in the "If you're a developer, start here" +section of this page: + + http://wiki.openstack.org/HowToContribute + +Once those steps have been completed, changes to OpenStack +should be submitted for review via the Gerrit tool, following +the workflow documented at: + + http://wiki.openstack.org/GerritWorkflow + +Pull requests submitted through GitHub will be ignored. + +Bugs should be filed on Launchpad, not GitHub: + + https://bugs.launchpad.net/congress \ No newline at end of file diff --git a/HACKING.rst b/HACKING.rst new file mode 100644 index 000000000..847e24794 --- /dev/null +++ b/HACKING.rst @@ -0,0 +1,4 @@ +congress Style Commandments +=============================================== + +Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ \ No newline at end of file diff --git a/LICENSE b/LICENSE index 68c771a09..67db85882 100644 --- a/LICENSE +++ b/LICENSE @@ -173,4 +173,3 @@ defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..90f8a7aef --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include AUTHORS +include ChangeLog +exclude .gitignore +exclude .gitreview + +global-exclude *.pyc \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index 1ed91b14f..000000000 --- a/README +++ /dev/null @@ -1,19 +0,0 @@ -Congress ----------------------------------- -Copyright (c) 2013 VMware, Inc. All rights reserved. - -1. Compile: - -- from the root directory - make - -2. Run the API server: - -- from the root directory - ./scripts/run_api_server - -3. Run the unit tests - -- from the root directory - ./scripts/run_tests - diff --git a/README.rst b/README.rst new file mode 100644 index 000000000..72c93aa26 --- /dev/null +++ b/README.rst @@ -0,0 +1,24 @@ +=============================== +congress +=============================== + +Congress: The open policy framework for the cloud. + +* Free software: Apache license +* Documentation: http://docs.openstack.org/developer/congress + +1. Compile: + +- from the root directory + make + +2. Run the API server: + +- from the root directory + ./scripts/run_api_server + +3. Run the unit tests + +- from the root directory + ./scripts/run_tests + diff --git a/babel.cfg b/babel.cfg new file mode 100644 index 000000000..efceab818 --- /dev/null +++ b/babel.cfg @@ -0,0 +1 @@ +[python: **.py] diff --git a/congress/__init__.py b/congress/__init__.py new file mode 100644 index 000000000..c43a596c9 --- /dev/null +++ b/congress/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import pbr.version + + +__version__ = pbr.version.VersionInfo( + 'congress').version_string() \ No newline at end of file diff --git a/src/policy/Congress.g b/congress/policy/Congress.g similarity index 100% rename from src/policy/Congress.g rename to congress/policy/Congress.g diff --git a/src/policy/__init__.py b/congress/policy/__init__.py similarity index 100% rename from src/policy/__init__.py rename to congress/policy/__init__.py diff --git a/src/policy/compile.py b/congress/policy/compile.py similarity index 100% rename from src/policy/compile.py rename to congress/policy/compile.py diff --git a/src/policy/runtime.py b/congress/policy/runtime.py similarity index 100% rename from src/policy/runtime.py rename to congress/policy/runtime.py diff --git a/src/policy/tests/__init__.py b/congress/policy/tests/__init__.py similarity index 100% rename from src/policy/tests/__init__.py rename to congress/policy/tests/__init__.py diff --git a/src/policy/tests/test_compiler.py b/congress/policy/tests/test_compiler.py similarity index 100% rename from src/policy/tests/test_compiler.py rename to congress/policy/tests/test_compiler.py diff --git a/src/policy/tests/test_runtime.py b/congress/policy/tests/test_runtime.py similarity index 100% rename from src/policy/tests/test_runtime.py rename to congress/policy/tests/test_runtime.py diff --git a/src/policy/unify.py b/congress/policy/unify.py similarity index 100% rename from src/policy/unify.py rename to congress/policy/unify.py diff --git a/src/server/__init__.py b/congress/server/__init__.py similarity index 100% rename from src/server/__init__.py rename to congress/server/__init__.py diff --git a/src/server/ad_sync.py b/congress/server/ad_sync.py similarity index 100% rename from src/server/ad_sync.py rename to congress/server/ad_sync.py diff --git a/src/server/server.py b/congress/server/server.py similarity index 100% rename from src/server/server.py rename to congress/server/server.py diff --git a/src/server/webservice.py b/congress/server/webservice.py similarity index 100% rename from src/server/webservice.py rename to congress/server/webservice.py diff --git a/src/server/wsgi.py b/congress/server/wsgi.py similarity index 100% rename from src/server/wsgi.py rename to congress/server/wsgi.py diff --git a/congress/tests/__init__.py b/congress/tests/__init__.py new file mode 100644 index 000000000..f88664ea4 --- /dev/null +++ b/congress/tests/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. \ No newline at end of file diff --git a/congress/tests/base.py b/congress/tests/base.py new file mode 100644 index 000000000..93b83262c --- /dev/null +++ b/congress/tests/base.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +import fixtures +import testtools + +_TRUE_VALUES = ('true', '1', 'yes') + + +class TestCase(testtools.TestCase): + + """Test case base class for all unit tests.""" + + def setUp(self): + """Run before each test method to initialize test environment.""" + + super(TestCase, self).setUp() + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid do not set a timeout. + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + + self.useFixture(fixtures.NestedTempfile()) + self.useFixture(fixtures.TempHomeDir()) + + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: + stdout = self.useFixture(fixtures.StringStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: + stderr = self.useFixture(fixtures.StringStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + + self.log_fixture = self.useFixture(fixtures.FakeLogger()) \ No newline at end of file diff --git a/tests/functional/test_api.py b/congress/tests/functional/test_api.py similarity index 100% rename from tests/functional/test_api.py rename to congress/tests/functional/test_api.py diff --git a/congress/tests/test_congress.py b/congress/tests/test_congress.py new file mode 100644 index 000000000..58bcef4bb --- /dev/null +++ b/congress/tests/test_congress.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +test_congress +---------------------------------- + +Tests for `congress` module. +""" + +from congress.tests import base + + +class TestCongress(base.TestCase): + + def test_something(self): + pass \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100755 index 000000000..592882c27 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + #'sphinx.ext.intersphinx', + 'oslo.sphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'congress' +copyright = u'2013, OpenStack Foundation' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} \ No newline at end of file diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst new file mode 100644 index 000000000..8cb3146fe --- /dev/null +++ b/doc/source/contributing.rst @@ -0,0 +1 @@ +.. include:: ../../CONTRIBUTING.rst \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 000000000..75ea8992e --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,24 @@ +.. congress documentation master file, created by + sphinx-quickstart on Tue Jul 9 22:26:36 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to congress's documentation! +======================================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + readme + installation + usage + contributing + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/source/installation.rst b/doc/source/installation.rst new file mode 100644 index 000000000..b8e4197ae --- /dev/null +++ b/doc/source/installation.rst @@ -0,0 +1,12 @@ +============ +Installation +============ + +At the command line:: + + $ pip install congress + +Or, if you have virtualenvwrapper installed:: + + $ mkvirtualenv congress + $ pip install congress \ No newline at end of file diff --git a/doc/source/readme.rst b/doc/source/readme.rst new file mode 100644 index 000000000..6b2b3ec68 --- /dev/null +++ b/doc/source/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst \ No newline at end of file diff --git a/doc/source/usage.rst b/doc/source/usage.rst new file mode 100644 index 000000000..5e9893e1f --- /dev/null +++ b/doc/source/usage.rst @@ -0,0 +1,7 @@ +======== +Usage +======== + +To use congress in a project:: + + import congress \ No newline at end of file diff --git a/openstack-common.conf b/openstack-common.conf new file mode 100644 index 000000000..8b7d6c2f4 --- /dev/null +++ b/openstack-common.conf @@ -0,0 +1,7 @@ +[DEFAULT] + +# The list of modules to copy from oslo-incubator.git +module=install_venv_common + +# The base module to hold the copy of openstack.common +base=congress \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..864634192 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pbr>=0.5.21,<1.0 +Babel>=0.9.6 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..c940da89e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[metadata] +name = congress +summary = Congress: The open policy framework for the cloud. +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 2.6 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.3 + +[files] +packages = + congress + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/build/html + +[compile_catalog] +directory = congress/locale +domain = congress + +[update_catalog] +domain = congress +output_dir = congress/locale +input_file = congress/locale/congress.pot + +[extract_messages] +keywords = _ gettext ngettext l_ lazy_gettext +mapping_file = babel.cfg +output_file = congress/locale/congress.pot diff --git a/setup.py b/setup.py new file mode 100755 index 000000000..33f185abf --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools + +setuptools.setup( + setup_requires=['pbr>=0.5.21,<1.0'], + pbr=True) \ No newline at end of file diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..3434db12b --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,11 @@ +hacking>=0.5.6,<0.8 + +coverage>=3.6 +discover +fixtures>=0.3.14 +python-subunit +sphinx>=1.1.2 +oslo.sphinx +testrepository>=0.0.17 +testscenarios>=0.4,<0.5 +testtools>=0.9.32 \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..453559d75 --- /dev/null +++ b/tox.ini @@ -0,0 +1,34 @@ +[tox] +minversion = 1.6 +envlist = py26,py27,py33,pypy,pep8 +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} + LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = python setup.py testr --slowest --testr-args='{posargs}' + +[testenv:pep8] +commands = flake8 + +[testenv:venv] +commands = {posargs} + +[testenv:cover] +commands = python setup.py testr --coverage --testr-args='{posargs}' + +[flake8] +# H803 skipped on purpose per list discussion. +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125,H803 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build \ No newline at end of file