Changeset View
Changeset View
Standalone View
Standalone View
contrib/linearize/linearize-data.py
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | def get_blk_dt(blk_hdr): | ||||
dt_ym = datetime.datetime(dt.year, dt.month, 1) | dt_ym = datetime.datetime(dt.year, dt.month, 1) | ||||
return (dt_ym, nTime) | return (dt_ym, nTime) | ||||
# When getting the list of block hashes, undo any byte reversals. | # When getting the list of block hashes, undo any byte reversals. | ||||
def get_block_hashes(settings): | def get_block_hashes(settings): | ||||
blkindex = [] | blkindex = [] | ||||
f = open(settings['hashlist'], "r") | f = open(settings['hashlist'], "r", encoding="utf8") | ||||
for line in f: | for line in f: | ||||
line = line.rstrip() | line = line.rstrip() | ||||
if settings['rev_hash_bytes'] == 'true': | if settings['rev_hash_bytes'] == 'true': | ||||
line = hex_switchEndian(line) | line = hex_switchEndian(line) | ||||
blkindex.append(line) | blkindex.append(line) | ||||
print("Read " + str(len(blkindex)) + " hashes") | print("Read " + str(len(blkindex)) + " hashes") | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | def run(self): | ||||
print("Done ({} blocks written)".format((self.blkCountOut))) | print("Done ({} blocks written)".format((self.blkCountOut))) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
if len(sys.argv) != 2: | if len(sys.argv) != 2: | ||||
print("Usage: linearize-data.py CONFIG-FILE") | print("Usage: linearize-data.py CONFIG-FILE") | ||||
sys.exit(1) | sys.exit(1) | ||||
f = open(sys.argv[1]) | f = open(sys.argv[1], encoding="utf8") | ||||
for line in f: | for line in f: | ||||
# skip comment lines | # skip comment lines | ||||
m = re.search(r'^\s*#', line) | m = re.search(r'^\s*#', line) | ||||
if m: | if m: | ||||
continue | continue | ||||
# parse key=value lines | # parse key=value lines | ||||
m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line) | m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line) | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |