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

* Added a 'SchedulerCode()' type class to the 'rivwebpyapi' API.
	* Modified the 'rivwebpyapi.ListCartSchedCodes()' call to return
	a list of 'rivwebpyapi.SchedulerCode' objects.
	* Modified the 'rivwebpyapi.ListSchedulerCodes()' call to return
	a list of 'rivwebpyapi.SchedulerCode' objects.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-12-12 16:28:45 -05:00
parent c216bc618c
commit b9164bad15
4 changed files with 35 additions and 27 deletions

View File

@ -22763,3 +22763,9 @@
* Added an 'SaveLog()' method to the 'rivwebpyapi' API.
2021-12-12 Fred Gleason <fredg@paravelsystems.com>
* Added a 'RivendellType()' base class to the 'rivwebpyapi' API.
2021-12-12 Fred Gleason <fredg@paravelsystems.com>
* Added a 'SchedulerCode()' type class to the 'rivwebpyapi' API.
* Modified the 'rivwebpyapi.ListCartSchedCodes()' call to return
a list of 'rivwebpyapi.SchedulerCode' objects.
* Modified the 'rivwebpyapi.ListSchedulerCodes()' call to return
a list of 'rivwebpyapi.SchedulerCode' objects.

View File

@ -219,6 +219,11 @@ LOGLINE_FIELDS={
'extAnncType': 'string'
}
SCHEDULER_CODE_FIELDS={
'code': 'string',
'description': 'string'
}
class RivWebPyApi_ListHandler(ContentHandler):
def __init__(self,base_tag,fields):
self.__output=[]
@ -414,6 +419,10 @@ class LogLine(RivendellType):
def __init__(self,values={}):
super().__init__(LOGLINE_FIELDS,values)
class SchedulerCode(RivendellType):
def __init__(self,values={}):
super().__init__(SCHEDULER_CODE_FIELDS,values)
class rivwebpyapi(object):
"""
Create a 'RivWebPyApi' object for accessing the Web API.
@ -1279,7 +1288,7 @@ class rivwebpyapi(object):
def ListCartSchedCodes(self,cart_number):
"""
Returns the set of scheduler codes associated with a Rivendell
cart (list of dictionaries)
cart (list of rivwebpyapi.SchedulerCode objects).
Takes the following arguments:
@ -1308,17 +1317,15 @@ class rivwebpyapi(object):
if(r.status_code!=requests.codes.ok):
self.__throwError(response=r)
#
# Generate the output dictionary
#
fields={
'code': 'string',
'description': 'string'
}
handler=RivWebPyApi_ListHandler(base_tag='schedCode',fields=fields)
handler=RivWebPyApi_ListHandler(base_tag='schedCode',
fields=SCHEDULER_CODE_FIELDS)
xml.sax.parseString(r.text,handler)
out=handler.output()
ret=[]
for item in out:
ret.append(SchedulerCode(item))
return handler.output()
return ret
def ListCut(self,cart_number,cut_number):
"""
@ -1603,7 +1610,7 @@ class rivwebpyapi(object):
def ListSchedulerCodes(self):
"""
Returns a list of all defined Rivendell schedule codes
(list of dictionaries)
(list of rivwebpyapi.SchedulerCode objects).
"""
#
@ -1625,14 +1632,15 @@ class rivwebpyapi(object):
#
# Generate the output dictionary
#
fields={
'code': 'string',
'description': 'string'
}
handler=RivWebPyApi_ListHandler(base_tag='schedCode',fields=fields)
handler=RivWebPyApi_ListHandler(base_tag='schedCode',
fields=SCHEDULER_CODE_FIELDS)
xml.sax.parseString(r.text,handler)
out=handler.output()
ret=[]
for item in out:
ret.append(SchedulerCode(item))
return handler.output()
return ret
def ListServices(self,trackable):
"""
@ -2161,12 +2169,6 @@ class rivwebpyapi(object):
if(r.status_code!=requests.codes.ok):
self.__throwError(response=r)
def SavePodcast(self,cast_id,filename):
"""
Save posted podcast audio to the Rivendell audio store.

View File

@ -77,6 +77,6 @@ except rivwebpyapi.RivWebPyError as err:
# Display the code list
#
for code in codes:
print('code: '+str(code['code']))
print('description: '+str(code['description']))
for key in code.values():
print(key+': '+str(code.values()[key]))
print('')

View File

@ -72,6 +72,6 @@ except rivwebpyapi.RivWebPyError as err:
# Display the code list
#
for code in codes:
print('code: '+str(code['code']))
print('description: '+str(code['description']))
for key in code.values():
print(key+': '+str(code.values()[key]))
print('')