示例#1
0
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
示例#2
0
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
示例#3
0
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)
示例#4
0
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)
示例#5
0
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])
示例#6
0
def docstring(value):
    # type: (AStringValue) -> ADefine
    """Define the docstring for the YAML file"""
    return Define("docstring", value)
示例#7
0
def int32(name, value):
    # type: (AName, AInt32Value) -> ADefine
    """Define an int32 parameter to be used within this YAML file"""
    return Define(name, value)
示例#8
0
def float64(name, value):
    # type: (AName, AFloat64Value) -> ADefine
    """Define a float64 parameter to be used within this YAML file"""
    return Define(name, value)
示例#9
0
def string(name, value):
    # type: (AName, AStringValue) -> ADefine
    """Define a string parameter to be used within this YAML file"""
    return Define(name, value)
示例#10
0
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())
示例#11
0
def int32(name: AName, value: AInt32Value) -> ADefine:
    """Define an int32 parameter to be used within this YAML file"""
    return Define(name, value)