Skip to content

Commit

Permalink
OrderedDict support in python 2.6
Browse files Browse the repository at this point in the history
OrderedDict support in python 2.6.
Flake8 format changes.
Add the json format for info option.

JIRA: PDC-1912
  • Loading branch information
chcao55 committed Jul 20, 2017
1 parent 6c821f7 commit d996f43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pdc_client/plugins/product_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from __future__ import print_function

import json
from collections import OrderedDict
try:
from collections import OrderedDict
except ImportError:
# Python 2.6 needs this back-port
from ordereddict import OrderedDict

from pdc_client.plugin_helpers import (PDCClientPlugin,
extract_arguments,
Expand Down Expand Up @@ -75,6 +79,9 @@ def product_version_create(self, args):
def product_version_info(self, args, product_version_id=None):
product_version_id = product_version_id or args.product_version_id
product_version = self.client["product-versions"][product_version_id]._()
if args.json:
print(json.dumps(product_version))
return

fmt = '{0:20} {1}'
for key, value in self.prep_for_print(product_version).items():
Expand Down
1 change: 1 addition & 0 deletions pdc_client/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def autocomplete(*args):
'contact.py',
'image.py',
'permission.py',
'product_version.py',
'release.py',
'repo.py',
'rpm.py'
Expand Down
2 changes: 1 addition & 1 deletion tests/product_version/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_info(self, api):

# compare stdout with data/info.txt
with self.expect_output('info.txt'):
self.runner.run([
self.runner.run([
'product-version',
'info',
'test-product-version-1',
Expand Down

0 comments on commit d996f43

Please sign in to comment.