def main(): this_dir = os.path.dirname(__file__) src_dir = os.path.join(this_dir, "..", "..", "images") dstf = open('image_resources.h', 'w+') dstf.write("#pragma once\n") for f in fs.list(path=src_dir): final = Image.open(f) ident = "_".join(os.path.basename(f).split(".")[:-1]).upper() dstf.write("\nconst unsigned char %s[] PROGMEM = {\n" % (ident)) buffer = getBitmap(final) cnt = 0 for byte in buffer: cnt += 1 if cnt == 1: dstf.write(" ") dstf.write('0x%02X' % byte) elif cnt == 12: cnt = 0 dstf.write(', 0x%02X,' % byte) dstf.write('\n') else: dstf.write(', 0x%02X' % byte) dstf.write('};\n')
def test_find_not_recursive(): files = [f for f in list(fs.list(TEST_DIR)) if fs.extname(f) == '.txt'] fs_files = list( fs.find('*.txt', TEST_DIR, recursive=False) ) assert len(files) > 0 assert len(files) is len(fs_files) assert sorted(files) == sorted(fs_files)
def test_find_not_recursive(): files = [f for f in list(fs.list(TEST_DIR)) if fs.extname(f) == '.txt'] fs_files = list(fs.find('*.txt', TEST_DIR, recursive=False)) assert len(files) > 0 assert len(files) is len(fs_files) assert sorted(files) == sorted(fs_files)
def test_list(): files = [ os.path.join(TEST_DIR,f) for f in os.listdir(TEST_DIR) if os.path.isfile(os.path.join(TEST_DIR,f)) ] fs_files = list( fs.list(TEST_DIR) ) assert len(files) is len(fs_files) assert sorted(files) == sorted(fs_files)
#!/usr/bin/env python3 from ethereum.tester import languages from ethereum import tester as t import json import os import fs contract_dir = fs.abspath('../contracts/') contracts = list(fs.list(contract_dir)) def main(): print(contracts) for contract in contracts: with open(contract, 'r') as file: code = file.read().decode('windows-1252') print(code) # combined = languages['solidity'].combined(code) # compiled_code = combined[-1][1]["bin_hex"] # abi = combined[-1][1]["abi"] # print(compiled_code, abi) if __name__ == '__main__': main()
def __exec__(args): fs.list()