def module_path(name: AModuleName, path: AModulePath) -> ADefine: """Load an external malcolm module (e.g. ADCore/etc/malcolm)""" define = Define(name, path) assert os.path.isdir(path), "%r doesn't exist" % path name = "malcolm.modules.%s" % name import_package_from_path(name, path) return define
def module_path(name: AModuleName, path: AModulePath) -> ADefine: """Load an external malcolm module (e.g. ADCore/etc/malcolm)""" define = Define(name, path) assert os.path.isdir(path), f"{path!r} doesn't exist" name = f"malcolm.modules.{name}" import_package_from_path(name, path) return define
def export_env_string(name, value): # type: (AEnvName, AEnvValue) -> ADefine """Exports an environment variable with the given value""" os.environ[name] = value return Define(name, value)
def cmd_string(name, cmd): # type: (AName, ACmd) -> ADefine """Define a string parameter coming from a shell command to be used within this YAML file. Trailing newlines will be stripped.""" value = subprocess.check_output(cmd, shell=True).rstrip("\n") return Define(name, value)
def env_string(name, env): # type: (AName, AEnvSource) -> ADefine """Define a string parameter coming from the environment to be used within this YAML file""" return Define(name, os.environ[env])
def docstring(value): # type: (AStringValue) -> ADefine """Define the docstring for the YAML file""" return Define("docstring", value)
def int32(name, value): # type: (AName, AInt32Value) -> ADefine """Define an int32 parameter to be used within this YAML file""" return Define(name, value)
def float64(name, value): # type: (AName, AFloat64Value) -> ADefine """Define a float64 parameter to be used within this YAML file""" return Define(name, value)
def string(name, value): # type: (AName, AStringValue) -> ADefine """Define a string parameter to be used within this YAML file""" return Define(name, value)
def tmp_dir(name: AName) -> ADefine: """Make a temporary directory, and define a string parameter containing its path on disk""" return Define(name, tempfile.mkdtemp())
def int32(name: AName, value: AInt32Value) -> ADefine: """Define an int32 parameter to be used within this YAML file""" return Define(name, value)