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.
Add a json return for info option.
Add filters on list option.
Add test cases.

JIRA: PDC-1911
  • Loading branch information
chcao55 committed Jul 20, 2017
1 parent e1f5736 commit fa01127
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pdc_client/plugins/product.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 @@ -71,6 +75,9 @@ def product_create(self, args):
def product_info(self, args, short=None):
short = short or args.short
product = self.client.products[short]._()
if args.json:
print(json.dumps(product))
return

fmt = '{0:20} {1}'
for key, value in self.prep_for_print(product).items():
Expand All @@ -83,7 +90,8 @@ def product_list(self, args):
elif not args.all:
filters['active'] = True

products = self.client.get_paged(self.client.products._, **filters)
products = self.client.get_paged(self.client["products"]._, **filters)

if args.json:
print(json.dumps(list(products)))
return
Expand Down

0 comments on commit fa01127

Please sign in to comment.