コード例 #1
0
ファイル: manifest.py プロジェクト: haje01/wzdat
 def checksum(self):
     with HDF(self.uname) as hdf:
         try:
             return int(hdf.store[HDF_CHKSUM_FMT.format(self.sname)])
         except KeyError, e:
             logging.warning("HDFStore - checksum: {}".format(e))
             return 0
コード例 #2
0
ファイル: manifest.py プロジェクト: haje01/wzdat
 def _append(self, value, aformat, append, columns, dropna, **kwargs):
     import pandas as pd
     ktuple = tuple(((k, v if isinstance(v, tuple) else tuple(v)) for k,
                     v in kwargs.items()))
     _args = (dataframe_checksum(value), self.uname, self.sname, aformat,
              append, columns, dropna, ktuple)
     # escape None for hashing
     args = map(lambda x: 0 if x is None else x, _args)
     chksum = hash(tuple(args))
     # logging.debug('  chksum: {}'.format(chksum))
     self.manifest._out_hdf_chksum = chksum
     logging.debug("HDFStore append - _out_hdf_chksum {}".format(chksum))
     with HDF(self.uname) as hdf:
         hdf.store.append(self.sname, value, aformat, append, columns,
                          dropna, **kwargs)
         # write checksum
         hsname = HDF_CHKSUM_FMT.format(self.sname)
         if append:
             pchksum = int(hdf.store[hsname])
             chksum = pchksum + chksum
         hdf.store.append(hsname, pd.Series([str(chksum)]), append=False)