当前位置: 首页>>代码示例>>Python>>正文


Python Connector.from_string方法代码示例

本文整理汇总了Python中connector.Connector.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.from_string方法的具体用法?Python Connector.from_string怎么用?Python Connector.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在connector.Connector的用法示例。


在下文中一共展示了Connector.from_string方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: clone_repo

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import from_string [as 别名]
def clone_repo(src, dest):
    """
    Clone a repository.
    
    Arguments:
    src  -- URL of to the repository to clone from.
    dest -- URL of the target directory of the clone.
    
    Returns:
    A clone of the supplied repository.
    """
    src_connector = Connector.from_string(src)
    with src_connector.connected():
        origin = repo.Repo.load_from_disk(src_connector)
        dest = os.path.join(dest, origin.name)  # make clone at "<dest>/<name>"
        dest_connector = Connector.from_string(dest)
        with dest_connector.connected():
            clone = repo.Repo.clone(origin, dest_connector)
    init_repo_logging(clone)
    log.info("Cloned repository from %s to %s" % (src, dest))
    return clone
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:23,代码来源:app.py

示例2: load_repo

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import from_string [as 别名]
def load_repo(url):
    """
    Load an existing repository from disk and return it.
    
    Arguments:
    url -- URL of the repository on disk.
    
    Returns:
    The loaded repository.
    """
    connector = Connector.from_string(url)
    with connector.connected():
        rep = repo.Repo.load_from_disk(connector)
    init_repo_logging(rep)
    log.info("Loaded PictureClerk repository from disk")
    return rep
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:18,代码来源:app.py

示例3: init_repo

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import from_string [as 别名]
def init_repo(url):
    """
    Initialize a new repository and return it.
    
    Arguments:
    url -- URL of the repository to be initialized (e.g. '/home/user/repo').
    
    Returns:
    The initialized repository.
    """
    config = repo.new_repo_config()
    connector = Connector.from_string(url)
    with connector.connected():
        rep = repo.Repo.create_on_disk(connector, config)
    init_repo_logging(rep)
    log.info("Initialized empty PictureClerk repository")
    return rep
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:19,代码来源:app.py

示例4: backup_repo

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import from_string [as 别名]
def backup_repo(rep, *urls):
    """
    Backup a repository to multiple locations.
    
    Arguments:
    rep  -- Repository to be backed up
    urls -- Backup repository to these locations (1 or more URL args).
    
    Returns:
    Backup repositories (clones of the supplied respositories).
    """
    backups = list()
    for url in urls:
        url = os.path.join(url, rep.name)
        connector = Connector.from_string(url)
        with rep.connector.connected(), connector.connected():
            backup = repo.Repo.clone(rep, connector)
        init_repo_logging(backup)
        backups.append(backup)
        log.info("Backed up repository to %s" % url)
    return backups
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:23,代码来源:app.py

示例5: merge_repos

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import from_string [as 别名]
def merge_repos(rep, *others):
    """
    Merge multiple repositories into one.
    
    Arguments:
    rep    -- Merge 'others' repositories into this repository.
    others -- Path to repositories to merge into 'rep' (1 or more path args).
    """
    with rep.connector.connected():
        for url in others:
            log.info("Merging repository '%s'", url)
            connector = Connector.from_string(url)
            with connector.connected():
                other = repo.Repo.load_from_disk(connector)
                # copy picture files
                for picture in other.index.iterpics():
                    for fname in picture.get_filenames():
                        connector.copy(fname, rep.connector, dest_path=fname)
            # add pictures to index
            rep.index.add(other.index.iterpics())
    log.info("Saving index to file.")
    with rep.connector.connected():
        rep.save_index_to_disk()
    return rep
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:26,代码来源:app.py


注:本文中的connector.Connector.from_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。