def __init__(self, contract): """Stash the contract filepath""" config = project_structure.load_config() self.contract_language = project_structure.contract_language(contract, config) self.contractdir = "contract" self.compile_command = config[self.contract_language]["compile_command"] contract = contract.strip() if contract: self.contract_files = [self.contract_filename(contract)] else: ext = project_structure.language_extension(self.contract_language) self.contract_files = project_structure.list_files(self.contractdir, ext)
def __init__(self, contract_name, contract_language="serpent"): """Stash the contract details and generate various filepaths""" self.contract_name = os.path.splitext(contract_name)[0] intercaps = "".join([x.capitalize() for x in contract_name.split("_")]) self.contract_classname = "Test" + intercaps test_dir = "test" contract_dir = "contract" config = project_structure.load_config() contract_ext = project_structure.language_extension(contract_language) contract_filename = "%s.%s" % (self.contract_name, contract_ext) test_filename = config["ace"]["test_framework"] + ".py.template" self.test_template_filepath = os.path.join(test_dir, test_filename) contract_source_filename = "contract." + contract_ext self.contract_template_filepath = os.path.join(contract_dir, contract_source_filename) # If we swap the project_structure code in, keep this as well self.contract_filepath = os.path.join(contract_dir, contract_filename) self.test_filepath = os.path.join(test_dir, "test_" + contract_name + ".py")
def contract_filename(self, contract): """Format up the contract filename""" if contract.endswith(".py"): contract = re.sub("test_", "", contract) extension = project_structure.language_extension(self.contract_language) return project_structure.project_filepath(self.contractdir, contract, extension)