Esempio n. 1
0
 def save(self, s, noxmlsign):
     if noxmlsign:
         with open(self._aodsFile, 'w') as f:
             f.truncate()
             f.write(json.dumps(s))
     else:
         xml = creSignedXML(json.dumps(s))
         if len(xml) == 0:  # just for defense, should not happen
             raise EmptyAODSError('Journal empty, not saved - signature failed?')
         with open(self._aodsFile, 'w') as f:
             f.truncate()
             f.write(xml)
Esempio n. 2
0
 def create(self, s, noxmlsign):
     if os.path.exists(self._aodsFile):
         raise InvalidArgumentValueError('Must remove existing %s before creating a new AODS' %
                                         self._aodsFile)
     os.makedirs(os.path.dirname(self._aodsFile), exist_ok=True)
     if noxmlsign:
         with open(self._aodsFile, 'w') as f:
             f.write(json.dumps(s))
     else:
         j = json.dumps(s)
         x = creSignedXML(j, verbose=self.verbose)
         with open(self._aodsFile, 'w') as f:
             f.write(x)