diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51390f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.egg-info +/AUTHORS +/ChangeLog +build +dist diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..d606ab6 --- /dev/null +++ b/README.rst @@ -0,0 +1,27 @@ +======================== +OpenStack Summit Counter +======================== + +The ``summit count`` plugin for python-openstackclient helps the user +determine the number of summits they have attended since the beginning +of their interaction with OpenStack. + +Installing +========== + +:: + + $ pip install openstack-summit-counter + +Using +===== + +:: + + $ openstack summit count $first $current + +For example, if your first summit was for the "Folsom" series and the +next summit is for "Rocky":: + + $ openstack summit count folsom rocky + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..41ba77f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +pbr!=2.1.0,>=2.0.0 # Apache-2.0 +python-openstackclient>=3.12.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..fc431cb --- /dev/null +++ b/setup.cfg @@ -0,0 +1,27 @@ +[metadata] +name = openstack-summit-counter +summary = OSC Plugin to help compute the number of summits someone has attended. +description-file = + README.rst +author = Doug Hellmann +author-email = doug@doughellmann.com +home-page = https://pypi.python.org/pypi/openstack-summit-counter +classifier = + Environment :: Console + Environment :: OpenStack + Intended Audience :: Information Technology + License :: OSI Approved :: Apache Software License + Programming Language :: Python + Programming Language :: Python :: 3 + +[files] +packages = + summit_counter + +[entry_points] +openstack.cli = + summit count = summit_counter.main:SummitCount + summit list = summit_counter.main:SummitList + +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..fec7777 --- /dev/null +++ b/setup.py @@ -0,0 +1,28 @@ +# 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 setuptools + +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + +setuptools.setup( + setup_requires=['pbr>=2.0.0'], + pbr=True) diff --git a/summit_counter/__init__.py b/summit_counter/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/summit_counter/main.py b/summit_counter/main.py new file mode 100644 index 0000000..420b82a --- /dev/null +++ b/summit_counter/main.py @@ -0,0 +1,81 @@ +# 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. + +from cliff import lister +from cliff import show + +_SUMMITS = [ + ('Austin', 'Austin', 'https://wiki.openstack.org/wiki/Design_Summit/Austin'), + ('Bexar', 'San Antonio', 'https://wiki.openstack.org/wiki/Design_Summit/Bexar'), + ('Cactus', 'Santa Clara', ''), + ('Diablo', '', ''), + ('Essex', 'Boston', 'https://wiki.openstack.org/wiki/Design_Summit/Essex'), + ('Folsom', 'San Francisco', 'https://wiki.openstack.org/wiki/Design_Summit/Folsom'), + ('Grizzly', 'San Diego', 'https://wiki.openstack.org/wiki/Design_Summit/Grizzly'), + ('Havana', 'Portland', 'https://wiki.openstack.org/wiki/Design_Summit/Havana'), + ('Icehouse', 'Hong Kong', 'https://wiki.openstack.org/wiki/Design_Summit/Icehouse'), + ('Juno', 'Atlanta', 'https://wiki.openstack.org/wiki/Design_Summit/Juno'), + ('Kilo', 'Paris', 'https://wiki.openstack.org/wiki/Design_Summit/Kilo'), + ('Liberty', 'Vancouver', 'https://wiki.openstack.org/wiki/Design_Summit/Liberty'), + ('Mitaka', 'Tokyo', 'https://www.openstack.org/summit/tokyo-2015/'), + ('Newton', 'Austin', 'https://wiki.openstack.org/wiki/Design_Summit/Newton'), + ('Ocata', 'Barcelona', 'https://www.openstack.org/summit/barcelona-2016'), + ('Pike', 'Boston', 'https://www.openstack.org/summit/boston-2017'), + ('Queens', 'Sydney', 'https://www.openstack.org/summit/sydney-2017'), + ('Rocky', 'Vancouver', 'https://www.openstack.org/summit/vancouver-2018'), +] + + +class SummitCount(show.ShowOne): + + # Set the command so that when we run through + # python-openstackclient we do not require authentication. + auth_required = False + + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + choices = [s[0].lower() for s in _SUMMITS] + parser.add_argument( + 'first', + help='Your first summit', + choices=choices, + ) + parser.add_argument( + 'current', + help='The current summit', + choices=choices, + nargs='?', + default=choices[-1], + ) + return parser + + def _name_to_num(self, name): + return ord(name.lower()[0]) - ord('a') + 1 + + def take_action(self, parsed_args): + first = self._name_to_num(parsed_args.first) + current = self._name_to_num(parsed_args.current) + return (('Summits',), (current - first + 1,)) + + +class SummitList(lister.Lister): + + # Set the command so that when we run through + # python-openstackclient we do not require authentication. + auth_required = False + + def take_action(self, parsed_args): + columns = ('Number', 'Name', 'Location', 'URL') + summits = [] + for i, s in enumerate(_SUMMITS, 1): + summits.append((i,) + s) + return (columns, summits)