-
Notifications
You must be signed in to change notification settings - Fork 1
/
dict2akn.py
94 lines (86 loc) · 3.72 KB
/
dict2akn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from datetime import date, datetime
def dict2akn(dict):
akn = {}
verTs = datetime.utcfromtimestamp(float(dict['versions'][0]['versionTimestamp']/1000))
verDate = str(verTs.date())
docType = dict['extraFieldValues'].pop('documentType')
if(docType == 'ΠΡΑΞΗ'):
docType = 'act'
else:
docType = 'doc'
dateF = str(verTs.year) + '/' + str(verTs.month)
baseUri = '/gr/' + docType + '/' + dateF + '/'
expression = baseUri + verDate
issueDate = str(datetime.fromtimestamp(float(dict['issueDate']/1000)).date())
publishTimestamp = str(datetime.utcfromtimestamp(float(dict['publishTimestamp']/1000)))
submissionTimestamp = str(datetime.utcfromtimestamp(float(dict['submissionTimestamp']/1000)))
for v in dict['versions']:
v['versionTimestamp'] = str(datetime.utcfromtimestamp(float(v['versionTimestamp']/1000)))
akn['akomaNtoso'] = {
'doc': {
'meta': {
'identification': {
'FRBRWork': {
'FRBRthis': baseUri,
'FRBRuri': baseUri,
'FRBRdate': {
'date': verDate,
'name': dict['versions'][0]['status']
},
'FRBRauthor': dict['versions'][0]['creator'],
'FRBRcountry': 'gr',
'FRBRname': docType
},
'FRBRExpression': {
'FRBRthis': expression,
'FRBRuri': expression,
'FRBRdate': {
'date': issueDate,
'status': dict['status']
},
'FRBRauthor': dict['signerIds'],
'FRBRcountry': 'gr',
'FRBRlanguage': 'gr',
},
'FRBRManifestation': {
'FRBRthis': expression + '.xml',
'FRBRuri': expression + '.akn',
'FRBRdate': {
'date': str(date.today()),
'name': 'AKNConversion'
},
'FRBRauthor': 'Indlovu',
'FRBRcountry': 'gr',
'FRBRlanguage': 'gr'
},
'FRBRItem': {
'url': dict['url'],
'documentUrl': dict['warnings']
}
},
'lifecycle': dict['versions'],
'publication': {
'ada': dict['ada'],
'protocolNumber': dict['protocolNumber'],
'versionId': dict['versionId'],
'organizationId': dict['organizationId'],
'signerIds': dict['signerIds'],
'unitIds': dict['unitIds'],
'publishTimestamp': publishTimestamp
},
'proprietary': {
'subject': dict['subject'],
'thematicCategoryIds': dict['thematicCategoryIds'],
'decisionTypeId': dict['decisionTypeId'],
'submissionTimestamp': submissionTimestamp,
'extraFieldValues': dict['extraFieldValues'],
'attachments': dict['attachments'],
'warnings': dict['warnings'],
'correctedVersionId': dict['correctedVersionId'],
'privateData': dict['privateData']
}
}
},
'_xmlns': 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0/CSD13'
}
return akn