2021-12-12 Fred Gleason <fredg@paravelsystems.com>

* Added a 'Group()' type class to the 'rivwebpyapi' API.
	* Modified the 'rivwebpyapi.ListGroup()' call to return
	a  'rivwebpyapi.Group' object.
	* Modified the 'rivwebpyapi.ListGroups()' call to return
	a list of 'rivwebpyapi.Group' objects.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-12-12 16:39:43 -05:00
parent b9164bad15
commit 0443fd9341
4 changed files with 40 additions and 54 deletions

View File

@ -22769,3 +22769,9 @@
a list of 'rivwebpyapi.SchedulerCode' objects. a list of 'rivwebpyapi.SchedulerCode' objects.
* Modified the 'rivwebpyapi.ListSchedulerCodes()' call to return * Modified the 'rivwebpyapi.ListSchedulerCodes()' call to return
a list of 'rivwebpyapi.SchedulerCode' objects. a list of 'rivwebpyapi.SchedulerCode' objects.
2021-12-12 Fred Gleason <fredg@paravelsystems.com>
* Added a 'Group()' type class to the 'rivwebpyapi' API.
* Modified the 'rivwebpyapi.ListGroup()' call to return
a 'rivwebpyapi.Group' object.
* Modified the 'rivwebpyapi.ListGroups()' call to return
a list of 'rivwebpyapi.Group' objects.

View File

@ -121,6 +121,20 @@ CUT_FIELDS={
'talkEndPoint': 'integer' 'talkEndPoint': 'integer'
} }
GROUP_FIELDS={
'name': 'string',
'description': 'string',
'defaultCartType': 'string',
'defaultLowCart': 'integer',
'defaultHighCart': 'integer',
'cutShelfLife': 'integer',
'defaultTitle': 'string',
'enforceCartRange': 'boolean',
'reportTfc': 'boolean',
'reportMus': 'boolean',
'color': 'string'
}
LOG_FIELDS={ LOG_FIELDS={
'name': 'string', 'name': 'string',
'serviceName': 'string', 'serviceName': 'string',
@ -411,6 +425,10 @@ class Cut(RivendellType):
def __init__(self,values={}): def __init__(self,values={}):
super().__init__(CUT_FIELDS,values) super().__init__(CUT_FIELDS,values)
class Group(RivendellType):
def __init__(self,values={}):
super().__init__(GROUP_FIELDS,values)
class Log(RivendellType): class Log(RivendellType):
def __init__(self,values={}): def __init__(self,values={}):
super().__init__(LOG_FIELDS,values) super().__init__(LOG_FIELDS,values)
@ -1417,7 +1435,7 @@ class rivwebpyapi(object):
def ListGroup(self,group_name): def ListGroup(self,group_name):
""" """
Returns a Rivendell group (dictionary). Returns a Rivendell group (rivwebpyapi.Group object).
Takes the following argument: Takes the following argument:
@ -1445,27 +1463,15 @@ class rivwebpyapi(object):
# #
# Generate the output dictionary # Generate the output dictionary
# #
fields={ handler=RivWebPyApi_ListHandler(base_tag='group',fields=GROUP_FIELDS)
'name': 'string',
'description': 'string',
'defaultCartType': 'string',
'defaultLowCart': 'integer',
'defaultHighCart': 'integer',
'cutShelfLife': 'integer',
'defaultTitle': 'string',
'enforceCartRange': 'boolean',
'reportTfc': 'boolean',
'reportMus': 'boolean',
'color': 'string'
}
handler=RivWebPyApi_ListHandler(base_tag='group',fields=fields)
xml.sax.parseString(r.text,handler) xml.sax.parseString(r.text,handler)
return handler.output()[0] return Group(handler.output()[0])
def ListGroups(self): def ListGroups(self):
""" """
Returns a list of all Rivendell groups (list of dictionaries). Returns a list of all Rivendell groups
(list of rivwebpyapi.Group objects).
""" """
# #
@ -1487,23 +1493,14 @@ class rivwebpyapi(object):
# #
# Generate the output dictionary # Generate the output dictionary
# #
fields={ handler=RivWebPyApi_ListHandler(base_tag='group',fields=GROUP_FIELDS)
'name': 'string',
'description': 'string',
'defaultCartType': 'string',
'defaultLowCart': 'integer',
'defaultHighCart': 'integer',
'cutShelfLife': 'integer',
'defaultTitle': 'string',
'enforceCartRange': 'boolean',
'reportTfc': 'boolean',
'reportMus': 'boolean',
'color': 'string'
}
handler=RivWebPyApi_ListHandler(base_tag='group',fields=fields)
xml.sax.parseString(r.text,handler) xml.sax.parseString(r.text,handler)
out=handler.output()
ret=[]
for item in out:
ret.append(Group(item))
return handler.output() return ret
def ListLog(self,log_name): def ListLog(self,log_name):
""" """

View File

@ -71,17 +71,8 @@ except rivwebpyapi.RivWebPyError as err:
sys.exit(1) sys.exit(1)
# #
# Display the group list # Display the group
# #
print('') for key in grp.values():
print('name: '+grp['name']) print(key+': '+str(grp.values()[key]))
print('description: '+grp['description'])
print('defaultCartType: '+grp['defaultCartType'])
print('defaultLowCart: '+str(grp['defaultLowCart']))
print('defaultHighCart: '+str(grp['defaultHighCart']))
print('cutShelfLife: '+str(grp['cutShelfLife']))
print('defaultTitle: '+grp['defaultTitle'])
print('enforceCartRange: '+str(grp['enforceCartRange']))
print('reportTfc: '+str(grp['reportTfc']))
print('reportMus: '+str(grp['reportMus']))
print('') print('')

View File

@ -69,14 +69,6 @@ except rivwebpyapi.RivWebPyError as err:
# Display the group list # Display the group list
# #
for grp in groups: for grp in groups:
print('name: '+grp['name']) for key in grp.values():
print('description: '+grp['description']) print(key+': '+str(grp.values()[key]))
print('defaultCartType: '+grp['defaultCartType'])
print('defaultLowCart: '+str(grp['defaultLowCart']))
print('defaultHighCart: '+str(grp['defaultHighCart']))
print('cutShelfLife: '+str(grp['cutShelfLife']))
print('defaultTitle: '+grp['defaultTitle'])
print('enforceCartRange: '+str(grp['enforceCartRange']))
print('reportTfc: '+str(grp['reportTfc']))
print('reportMus: '+str(grp['reportMus']))
print('') print('')