Exemple #1
0
def patch_node_config(testnet_config: TestnetConfiguration):
    for node_config in testnet_config.all_nodes_config_folders():
        config_file = node_config / 'config.toml'
        data = utils.read_toml_file(config_file)
        node_config_toml.patch(data, testnet_config)
        utils.write_toml_file(config_file, data)

        config_file = node_config / 'api.toml'
        data = utils.read_toml_file(config_file)
        node_config_toml.patch_api(data, testnet_config)
        utils.write_toml_file(config_file, data)

        genesis_smart_contracts_file = node_config / 'genesisSmartContracts.json'
        data = utils.read_json_file(genesis_smart_contracts_file)
        genesis_smart_contracts_json.patch(data, testnet_config)
        utils.write_json_file(genesis_smart_contracts_file, data)
Exemple #2
0
    def _patch_mandos_tests(self):
        test_dir_path = path.join(self.directory, "mandos")
        if not path.isdir(test_dir_path):
            return

        test_paths = [e for e in utils.list_files(test_dir_path, suffix=".json")]
        self._replace_in_files(
            test_paths,
            [
                (f"{self.template_name}.wasm", f"{self.project_name}.wasm")
            ]
        )

        for file in test_paths:
            data = utils.read_json_file(file)
            # Patch fields
            data["name"] = data.get("name", "").replace(self.template_name, self.project_name)
            utils.write_json_file(file, data)
Exemple #3
0
def parse(args: Any):
    logger.warning("Always review --expression parameters before executing this command!")

    file = Path(args.file).expanduser()
    expression: str = args.expression
    suffix = file.suffix
    data = None

    if suffix == ".json":
        data = utils.read_json_file(str(file))
    else:
        raise errors.BadUsage(f"File isn't parsable: {file}")

    try:
        result = eval(expression, {
            "data": data
        })
    except KeyError:
        result = ""

    print(result)
Exemple #4
0
def read_file() -> Dict[str, Any]:
    if not os.path.isfile(CONFIG_PATH):
        return dict()
    return utils.read_json_file(CONFIG_PATH)
 def get_language(self, template):
     metadata_file = self.get_metadata_file(template)
     metadata = utils.read_json_file(metadata_file)
     return metadata.get("language", "unknown")
Exemple #6
0
def _read_file(use_global: bool) -> Dict[str, Any]:
    filename = _get_filename(use_global)

    if not os.path.isfile(filename):
        return dict()
    return utils.read_json_file(filename)
 def load_config(self):
     config_file = self.get_config_file()
     config = utils.read_json_file(str(config_file))
     return config