def env_file_to_str_lambda(args, env_file):
    if env_file.startswith('~'):
        path = PosixPath(str(env_file)).expanduser()
        return ['--env-file', str(os.path.normpath(path.absolute()))]
    if env_file.startswith('/') == False:
        dirname = os.path.dirname(args.composefile)
        path = PosixPath(dirname, str(env_file))
        return ['--env-file', str(os.path.normpath(path.absolute()))]
    return ['--env-file', env_file]
def volume_dict_pairs_to_str(args, keyval_arr):
    key = keyval_arr[0]
    val = keyval_arr[1]
    if key == 'read_only':
        return 'readonly=' + str(val)
    if key == 'source':
        if val.startswith('~'):
            path = PosixPath(str(val)).expanduser()
            return 'source=' + str(os.path.normpath(path.absolute()))
        if val.startswith('.'):
            dirname = os.path.dirname(args.composefile)
            path = PosixPath(dirname, str(val))
            return 'source=' + str(os.path.normpath(path.absolute()))
        return 'source=' + str(val)
    return key + '=' + str(val)
示例#3
0
文件: core.py 项目: thalesmg/giz
def create_gist(
    gh: Github,
    name: str,
    filepaths: List[PosixPath],
    public: bool = False,
    description: Union[str, _NotSetType] = NotSet,
):
    files = {f.name: InputFileContent(f.read_text()) for f in filepaths}
    u = gh.get_user()
    gist = u.create_gist(public, files, description)
    clone_gist(gist, name)
    dest = PosixPath(name)
    print("gist created and cloned")
    print(dest.absolute())