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


Python Folder.make方法代码示例

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


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

示例1: gen

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import make [as 别名]
def gen(source, data, target=None):
    source_command = ShellCommand(cwd=source.path)
    if source.child_file("requirements.txt").exists:
        source_command.call("pip", "install", "-r", "requirements.txt")
    if source.child_file("package.json").exists:
        source_command.call("npm", "install")

    # Generate
    target = target or data.target or source.parent.child("dist/www")
    dist = Folder(target)
    dist.make()

    template = source.child_file(data.config_template or "env.yaml")
    conf = source.child_file(data.config_file_name or "settings.gitbot")
    transform(template, conf, data)

    source_command.call("hyde", "gen", "-r", "-c", conf.name, "-d", dist.path)
    return dist
开发者ID:gitbot,项目名称:gitbot,代码行数:20,代码来源:hyde.py

示例2: Tree

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import make [as 别名]
class Tree(object):

    def __init__(self, source, repo=None, remote='origin', branch='master'):
        if not source:
            raise Exception('You must provide the source')
        self.source = Folder(source)
        self.repo = repo
        self.remote = remote
        self.branch_name = branch
        self.tagger = Tagger(self)
        self.git = ShellCommand(cwd=self.source.path, cmd='git')

    def get_revision_remote(self):
        out = self.git.get('ls-remote', self.repo, self.branch_name, cwd='.')
        return out.split()[0]

    def get_branch(self):
        return self.git.get('rev-parse', '--abbrev-ref', 'HEAD')

    def get_revision(self, ref=None, short=True):
        self.ensure_source_exists()
        return self.git.get('rev-parse',
            '--short' if short else '',
            (ref or 'HEAD')).strip()

    def get_last_committed(self, ref=None):
        self.ensure_source_exists()
        modified = self.git.get('log',
                                (ref or 'HEAD'),
                                '-1', '--pretty=format:%ad', '--date=local')
        return datetime.strptime(modified, '%a %b %d %H:%M:%S %Y')

    def ensure_repo_exists(self):
        if not self.repo:
            raise GitException('This tree [%s] does not have a repo.'
                                % self.source.path)

    def ensure_source_exists(self):
        if not self.source.exists:
            raise GitException('The source directory [%s] is missing.'
                                % self.source.path)

    def ensure_source_does_not_exist(self):
        if self.source.exists:
            raise GitException('The source directory [%s] exists already.'
                                % self.source.path)

    def make(self, bare=False):
        self.ensure_source_exists()
        logger.info('Initializing git...')
        self.git.call('init', '--bare' if bare else None)

    def make_ref(self, ref, sha='HEAD'):
        self.ensure_source_exists()
        logger.info(
            'Creating a ref (%s) to commit (%s)...' % (
                    ref,
                    sha
                ))
        self.git.call('update-ref', ref, sha)

    def add_remote(self):
        self.ensure_source_exists()
        logger.info(
            'Adding remote repo (%s) with alias (%s)...' % (
                    self.repo,
                    self.remote
                ))

        self.git.call('remote', 'add', self.remote, self.repo)

    def clone(self, tip_only=False):
        self.ensure_source_does_not_exist()
        self.ensure_repo_exists()
        logger.info('Cloning tree...')
        self.source.parent.make()
        self.git.call('clone',
                        self.repo,
                        self.source.name,
                        '--depth' if tip_only else None,
                        '1' if tip_only else None,
                        '--branch' if tip_only else None,
                        self.branch_name if tip_only else None,
                        cwd=self.source.parent.path)
        self.checkout()

    def checkout(self, ref=None):
        self.ensure_source_exists()
        logger.info('Checking out %s...' % (ref or self.branch_name))
        self.git.call('checkout', (ref or self.branch_name))

    def new_branch(self, branch_name):
        logger.info('Setting up new branch %s...' % self.branch_name)
        self.git.call('branch', branch_name)

    @contextmanager
    def branch(self, branch_name):
        old_branch = self.branch_name
        self.branch_name = branch_name
        self.checkout()
#.........这里部分代码省略.........
开发者ID:cnuber,项目名称:gitbot,代码行数:103,代码来源:git.py


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