def mapTemplate(temp_dict):
    '''
    Maps a template dictionary to a template class
    :param temp_dict: a template dict
    :return: a template class
    '''
    template = Template(temp_dict['ID'])
    template.category = temp_dict['Categoria']
    template.title = temp_dict['Titolo del template']
    template.description = temp_dict['Descrizione']
    template.nmsgmin = int(temp_dict['Numero di messaggi (min)'])
    template.nmsgmax = int(temp_dict['Numero di messaggi (max)'])
    template.period = float(temp_dict['Durata (settimane)'])
    template.channels = temp_dict['Canale'].split(', ')
    return template
def getTemplate(id_template):
    '''
    Makes a API call to get the details of a template having the id, fill a Template class and returns it
    :param id_template: id of the template to retrieve
    :return: template class filled
    '''

    json_template = requests.get(getApipath() + 'getTemplate/' + id_template).json()[0]

    if 'Template' in json_template:
        json_template = json_template['Template']
    else:
        return None

    template = Template(id_template)
    template.title = json_template['title']
    template.category = json_template['category']
    template.description = json_template['description']
    template.nmsgmax = json_template['max_number_messages']
    template.nmsgmin = json_template['min_number_messages']
    template.period = json_template['period']
    template.addressed_to = json_template['addressed_to']
    template.flowchart = json_template['flowchart']
    template.compulsory = json_template['compulsory']
    for c in json_template['channels']:
        template.channels.append(c['channel_name'])

    return template
Beispiel #3
0
 def __init__(self):
     self.userinput = UserInput()
     self.userinput.test()
     self.template = Template()
     for i in self.userinput.Tasks:
         pass
Beispiel #4
0
 def read_template(self, path):
     # 将指定路径的template.xml解析出来
     tp = Template()
     tp.nta = et.parse(path)
     return tp
 def read_template(self, path):
     # 将指定路径的template.xml解析出来
     tp = Template()
     tp.nta = et.parse(path)
     return tp