Beispiel #1
0
 def issue(self, answers):
     result = {}
     try:
         client = CcRest(self.API_ROOT)
         response = str(client.issue(self.STANDARD_LICENSE, answers))
         result['name'] = self.LICENSE_NAME_RE.findall(response)[0]
         result['url'] = self.LICENSE_URL_RE.findall(response)[0]
         result['img'] = self.LICENSE_IMG_RE.findall(response)[0]
     except:
         return result
     return result
Beispiel #2
0
    def get_cc_issue_fields(self):
        fields = []
        try:
            client = CcRest(self.API_ROOT)
        except HTTPError:
            return fields

        # convert in list
        raw_fields = client.fields(self.STANDARD_LICENSE)
        for k in raw_fields['__keys__']:
            f = raw_fields[k]
            f['id'] = k
            enum = [{'value':value, 'text':text} for value, text in f['enum'].items()]
            if k == 'jurisdiction':
                for i, e in enumerate(enum):
                    if e['value'] == '':
                        generic = enum.pop(i)
                enum.sort(key=lambda x: x['text'])
                enum.insert(0, generic)
            f['enum'] = enum
            fields.append(f)

        return fields