From b9bdddde51c8c18abf66ef9b4d564fc403f16978 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 8 Nov 2016 13:40:43 -0500 Subject: [PATCH] remove or adopt incubated oslo code Switch to oslo.i18n fully. Move the old incubated apiclient package to storyboardclient._apiclient to make it clear it is no longer maintained by the Oslo team. Remove the configuration file for syncing from the Oslo incubator. Update the flake8 and coverage settings to ignore the apiclient in its new home until it is cleaned up and passes completely. Story: 2000776 Change-Id: I017e965353a20e0af151f0db9dc0ea8da9ff4b2f Signed-off-by: Doug Hellmann --- .coveragerc | 2 +- openstack-common.conf | 6 --- requirements.txt | 2 +- .../{openstack => _apiclient}/__init__.py | 0 .../common/apiclient => _apiclient}/auth.py | 2 +- .../common/apiclient => _apiclient}/base.py | 4 +- .../common/apiclient => _apiclient}/client.py | 8 ++-- .../apiclient => _apiclient}/exceptions.py | 2 +- .../apiclient => _apiclient}/fake_client.py | 2 +- .../common/apiclient => _apiclient}/utils.py | 4 +- storyboardclient/_i18n.py | 43 ++++++++++++++++++ storyboardclient/auth/oauth.py | 2 +- storyboardclient/base.py | 4 +- storyboardclient/openstack/common/__init__.py | 0 storyboardclient/openstack/common/_i18n.py | 45 ------------------- .../openstack/common/apiclient/__init__.py | 0 tox.ini | 2 +- 17 files changed, 60 insertions(+), 68 deletions(-) delete mode 100644 openstack-common.conf rename storyboardclient/{openstack => _apiclient}/__init__.py (100%) rename storyboardclient/{openstack/common/apiclient => _apiclient}/auth.py (99%) rename storyboardclient/{openstack/common/apiclient => _apiclient}/base.py (99%) rename storyboardclient/{openstack/common/apiclient => _apiclient}/client.py (98%) rename storyboardclient/{openstack/common/apiclient => _apiclient}/exceptions.py (99%) rename storyboardclient/{openstack/common/apiclient => _apiclient}/fake_client.py (99%) rename storyboardclient/{openstack/common/apiclient => _apiclient}/utils.py (96%) create mode 100644 storyboardclient/_i18n.py delete mode 100644 storyboardclient/openstack/common/__init__.py delete mode 100644 storyboardclient/openstack/common/_i18n.py delete mode 100644 storyboardclient/openstack/common/apiclient/__init__.py diff --git a/.coveragerc b/.coveragerc index b85d982..719aa1c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,7 +1,7 @@ [run] branch = True source = storyboardclient -omit = storyboardclient/tests/*,storyboardclient/openstack/* +omit = storyboardclient/tests/*,storyboardclient/apiclient/* [report] ignore_errors = True diff --git a/openstack-common.conf b/openstack-common.conf deleted file mode 100644 index 673656f..0000000 --- a/openstack-common.conf +++ /dev/null @@ -1,6 +0,0 @@ -[DEFAULT] - -# The list of modules to copy from oslo-incubator.git -module=apiclient -# The base module to hold the copy of openstack.common -base=storyboardclient diff --git a/requirements.txt b/requirements.txt index 4287273..e03c393 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ pbr>=0.6,!=0.7,<1.0 Babel>=1.3 oslo.config>=1.4.0 -oslo.i18n>=1.0.0 +oslo.i18n>=2.1.0 # Apache-2.0 oslo.log>=3.11.0 # Apache-2.0 oslo.serialization>=1.0.0 oslo.utils>=1.0.0 diff --git a/storyboardclient/openstack/__init__.py b/storyboardclient/_apiclient/__init__.py similarity index 100% rename from storyboardclient/openstack/__init__.py rename to storyboardclient/_apiclient/__init__.py diff --git a/storyboardclient/openstack/common/apiclient/auth.py b/storyboardclient/_apiclient/auth.py similarity index 99% rename from storyboardclient/openstack/common/apiclient/auth.py rename to storyboardclient/_apiclient/auth.py index 32c9bdc..3f95d70 100644 --- a/storyboardclient/openstack/common/apiclient/auth.py +++ b/storyboardclient/_apiclient/auth.py @@ -37,7 +37,7 @@ import os import six from stevedore import extension -from storyboardclient.openstack.common.apiclient import exceptions +from storyboardclient._apiclient import exceptions _discovered_plugins = {} diff --git a/storyboardclient/openstack/common/apiclient/base.py b/storyboardclient/_apiclient/base.py similarity index 99% rename from storyboardclient/openstack/common/apiclient/base.py rename to storyboardclient/_apiclient/base.py index ade5ea1..9ded1bb 100644 --- a/storyboardclient/openstack/common/apiclient/base.py +++ b/storyboardclient/_apiclient/base.py @@ -44,8 +44,8 @@ from oslo_utils import strutils import six from six.moves.urllib import parse -from storyboardclient.openstack.common._i18n import _ -from storyboardclient.openstack.common.apiclient import exceptions +from storyboardclient._i18n import _ +from storyboardclient._apiclient import exceptions def getid(obj): diff --git a/storyboardclient/openstack/common/apiclient/client.py b/storyboardclient/_apiclient/client.py similarity index 98% rename from storyboardclient/openstack/common/apiclient/client.py rename to storyboardclient/_apiclient/client.py index 2afbc5a..f613e81 100644 --- a/storyboardclient/openstack/common/apiclient/client.py +++ b/storyboardclient/_apiclient/client.py @@ -38,8 +38,8 @@ from oslo_utils import encodeutils from oslo_utils import importutils import requests -from storyboardclient.openstack.common._i18n import _ -from storyboardclient.openstack.common.apiclient import exceptions +from storyboardclient._i18n import _ +from storyboardclient._apiclient import exceptions _logger = logging.getLogger(__name__) SENSITIVE_HEADERS = ('X-Auth-Token', 'X-Subject-Token',) @@ -64,7 +64,7 @@ class HTTPClient(object): into terminal and send the same request with curl. """ - user_agent = "storyboardclient.openstack.common.apiclient" + user_agent = "storyboardclient._apiclient" def __init__(self, auth_plugin, @@ -292,7 +292,7 @@ class HTTPClient(object): >>> def test_clients(): ... from keystoneclient.auth import keystone - ... from openstack.common.apiclient import client + ... from openstack.common._apiclient import client ... auth = keystone.KeystoneAuthPlugin( ... username="user", password="pass", tenant_name="tenant", ... auth_url="http://auth:5000/v2.0") diff --git a/storyboardclient/openstack/common/apiclient/exceptions.py b/storyboardclient/_apiclient/exceptions.py similarity index 99% rename from storyboardclient/openstack/common/apiclient/exceptions.py rename to storyboardclient/_apiclient/exceptions.py index d716d0e..88571c6 100644 --- a/storyboardclient/openstack/common/apiclient/exceptions.py +++ b/storyboardclient/_apiclient/exceptions.py @@ -38,7 +38,7 @@ import sys import six -from storyboardclient.openstack.common._i18n import _ +from storyboardclient._i18n import _ class ClientException(Exception): diff --git a/storyboardclient/openstack/common/apiclient/fake_client.py b/storyboardclient/_apiclient/fake_client.py similarity index 99% rename from storyboardclient/openstack/common/apiclient/fake_client.py rename to storyboardclient/_apiclient/fake_client.py index d8f8673..f0bbef7 100644 --- a/storyboardclient/openstack/common/apiclient/fake_client.py +++ b/storyboardclient/_apiclient/fake_client.py @@ -43,7 +43,7 @@ import requests import six from six.moves.urllib import parse -from storyboardclient.openstack.common.apiclient import client +from storyboardclient._apiclient import client def assert_has_keys(dct, required=None, optional=None): diff --git a/storyboardclient/openstack/common/apiclient/utils.py b/storyboardclient/_apiclient/utils.py similarity index 96% rename from storyboardclient/openstack/common/apiclient/utils.py rename to storyboardclient/_apiclient/utils.py index 8eab764..87a3a39 100644 --- a/storyboardclient/openstack/common/apiclient/utils.py +++ b/storyboardclient/_apiclient/utils.py @@ -28,8 +28,8 @@ from oslo_utils import encodeutils from oslo_utils import uuidutils import six -from storyboardclient.openstack.common._i18n import _ -from storyboardclient.openstack.common.apiclient import exceptions +from storyboardclient._i18n import _ +from storyboardclient._apiclient import exceptions def find_resource(manager, name_or_id, **find_args): diff --git a/storyboardclient/_i18n.py b/storyboardclient/_i18n.py new file mode 100644 index 0000000..1e52989 --- /dev/null +++ b/storyboardclient/_i18n.py @@ -0,0 +1,43 @@ +# 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 oslo_i18n + +DOMAIN = "storyboardclient" + +_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN) + +# The primary translation function using the well-known name "_" +_ = _translators.primary + +# The contextual translation function using the name "_C" +# requires oslo.i18n >=2.1.0 +_C = _translators.contextual_form + +# The plural translation function using the name "_P" +# requires oslo.i18n >=2.1.0 +_P = _translators.plural_form + +# Translators for log levels. +# +# The abbreviated names are meant to reflect the usual use of a short +# name like '_'. The "L" is for "log" and the other letter comes from +# the level. +_LI = _translators.log_info +_LW = _translators.log_warning +_LE = _translators.log_error +_LC = _translators.log_critical + + +def get_available_languages(): + return oslo_i18n.get_available_languages(DOMAIN) diff --git a/storyboardclient/auth/oauth.py b/storyboardclient/auth/oauth.py index 532347e..7db9bc6 100644 --- a/storyboardclient/auth/oauth.py +++ b/storyboardclient/auth/oauth.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from storyboardclient.openstack.common.apiclient import auth +from storyboardclient._apiclient import auth class OAuthPlugin(auth.BaseAuthPlugin): diff --git a/storyboardclient/base.py b/storyboardclient/base.py index 2b8fa2e..458daca 100644 --- a/storyboardclient/base.py +++ b/storyboardclient/base.py @@ -17,9 +17,9 @@ import inspect import six +from storyboardclient._apiclient import base +from storyboardclient._apiclient import client from storyboardclient.auth import oauth -from storyboardclient.openstack.common.apiclient import base -from storyboardclient.openstack.common.apiclient import client DEFAULT_API_URL = "https://storyboard-dev.openstack.org/api/v1" diff --git a/storyboardclient/openstack/common/__init__.py b/storyboardclient/openstack/common/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/storyboardclient/openstack/common/_i18n.py b/storyboardclient/openstack/common/_i18n.py deleted file mode 100644 index a058a87..0000000 --- a/storyboardclient/openstack/common/_i18n.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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. - -"""oslo.i18n integration module. - -See http://docs.openstack.org/developer/oslo.i18n/usage.html - -""" - -try: - import oslo_i18n - - # NOTE(dhellmann): This reference to o-s-l-o will be replaced by the - # application name when this module is synced into the separate - # repository. It is OK to have more than one translation function - # using the same domain, since there will still only be one message - # catalog. - _translators = oslo_i18n.TranslatorFactory(domain='storyboardclient') - - # The primary translation function using the well-known name "_" - _ = _translators.primary - - # Translators for log levels. - # - # The abbreviated names are meant to reflect the usual use of a short - # name like '_'. The "L" is for "log" and the other letter comes from - # the level. - _LI = _translators.log_info - _LW = _translators.log_warning - _LE = _translators.log_error - _LC = _translators.log_critical -except ImportError: - # NOTE(dims): Support for cases where a project wants to use - # code from oslo-incubator, but is not ready to be internationalized - # (like tempest) - _ = _LI = _LW = _LE = _LC = lambda x: x diff --git a/storyboardclient/openstack/common/apiclient/__init__.py b/storyboardclient/openstack/common/apiclient/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tox.ini b/tox.ini index d5a4c6d..2dc3e95 100644 --- a/tox.ini +++ b/tox.ini @@ -31,4 +31,4 @@ commands = python setup.py build_sphinx show-source = True ignore = E123,E125,H803,H904 builtins = _ -exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build +exclude=.venv,.git,.tox,dist,doc,*_apiclient*,*lib/python*,*egg,build