Skip to content

Commit

Permalink
Merge de561aa into 0f6467a
Browse files Browse the repository at this point in the history
  • Loading branch information
eonpatapon committed Sep 12, 2019
2 parents 0f6467a + de561aa commit 16a0177
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -13,6 +13,7 @@ install:
- pip install coverage
- pip install nose
- pip install .
- pip install datrie
before_script:
- flake8 --ignore E501,W504 contrail_api_cli
script:
Expand Down
7 changes: 6 additions & 1 deletion contrail_api_cli/resource.py
Expand Up @@ -14,7 +14,10 @@
except ImportError:
from collections import UserDict, UserList

import datrie
try:
import datrie
except ImportError:
datrie = False
from keystoneauth1.exceptions.http import HttpError
from prompt_toolkit.completion import Completion

Expand Down Expand Up @@ -759,6 +762,8 @@ class ResourceCache(object):
"""Resource cache of discovered resources.
"""
def __init__(self):
if datrie is False:
raise RuntimeError("missing datrie package.")
self.cache = {
'resources': datrie.Trie(string.printable),
'collections': datrie.Trie(string.printable)
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Expand Up @@ -7,8 +7,10 @@
'keystoneauth1',
'requests>=2.20.0',
'gevent<1.3',
'datrie'
]
extras_require = {
'resource_completion': ['datrie'],
}

test_requires = []

Expand All @@ -30,6 +32,7 @@
packages=find_packages(),
package_data={'contrail_api_cli': ['schemas/*/*']},
install_requires=install_requires,
extras_require=extras_require,
scripts=[],
license="MIT",
entry_points={
Expand Down Expand Up @@ -62,8 +65,8 @@
'help = contrail_api_cli.commands.shell:Help',
],
'contrail_api_cli.completer': [
'resources = contrail_api_cli.resource:ResourceCache',
'collections = contrail_api_cli.resource:ResourceCache',
'resources = contrail_api_cli.resource:ResourceCache [resource_completion]',
'collections = contrail_api_cli.resource:ResourceCache [resource_completion]',
'commands = contrail_api_cli.manager:CommandManager',
]
},
Expand Down

0 comments on commit 16a0177

Please sign in to comment.