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


Python Folder.child_folder方法代码示例

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


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

示例1: __upload

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import child_folder [as 别名]
def __upload(proj, repo, branch, data, maker, force=True):
    root, source, dist = (None, None, None)
    try:
        root = Folder(data.root or '~')
        source = root.child_folder('src')
        source.make()
        source = source.child_folder(proj)
        dist = root.child_folder('dist')
        tree = Tree(source, repo=repo, branch=branch)
        key = None
        if not force:
            key = check_revision_already_published(proj, data.bucket, tree)

        if not key:
            b = Bucket(data.bucket)
            b.make()
            key_folder = Folder(proj).child_folder(branch)
            zippath = dist.child_file(proj + '.zip')
            tree.clone(tip_only=True)
            sha = tree.get_revision(short=False)
            key_folder = key_folder.child_folder(sha)
            target = dist.child_folder(proj)
            target.make()
            maker(source, target)
            target.zip(zippath.path)
            b.add_file(zippath, target_folder=key_folder.path)
            key = b.bucket.get_key(key_folder.child(zippath.name))
    finally:
        if source:
            source.delete()
        if dist:
            dist.delete()

    return key.generate_url(30000)
开发者ID:gitbot,项目名称:builder,代码行数:36,代码来源:builder.py

示例2: _get_layout_folder

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import child_folder [as 别名]
 def _get_layout_folder(root, layout_name='basic'):
     """
     Finds the layout folder from the given root folder.
     If it does not exist, return None
     """
     layouts_folder = Folder(unicode(root)).child_folder(LAYOUTS)
     layout_folder = layouts_folder.child_folder(layout_name)
     return layout_folder if layout_folder.exists else None
开发者ID:AlfiyaZi,项目名称:hyde,代码行数:10,代码来源:layout.py

示例3: check_revision_already_published

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import child_folder [as 别名]
def check_revision_already_published(proj, bucket_name, tree):
    b = Bucket(bucket_name)
    if not b.connect():
        return None

    sha = tree.get_revision_remote()
    key_folder = Folder(proj).child_folder(tree.branch_name)
    key_folder = key_folder.child_folder(sha)
    key_path = key_folder.child(proj + '.zip')
    return b.bucket.get_key(key_path)
开发者ID:gitbot,项目名称:builder,代码行数:12,代码来源:builder.py

示例4: get_worker_outputs

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import child_folder [as 别名]
def get_worker_outputs(data):
    result = None
    try:
        region = data.region or 'us-east-1'
        root = Folder(data.root or '~')
        source = root.child_folder('src')
        source.make()
        source = source.child_folder('worker')
        repo = data.worker_repo or 'git://github.com/gitbot/worker.git'
        branch = data.worker_branch or 'master'

        #   1. Pull worker repo
        tree = Tree(source, repo, branch)
        tree.clone(tip_only=True)

        #   2. Call gitbot.stack.publish with 'gitbot.yaml'
        worker_stack_name = stack.publish_stack(
                                    source.child_file('gitbot.yaml'),
                                    wait=True)
        result = stack.get_outputs(worker_stack_name, region)
    except Exception, e:
        print repr(e)
        raise
开发者ID:gitbot,项目名称:builder,代码行数:25,代码来源:builder.py

示例5: Config

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import child_folder [as 别名]
class Config(Expando):
    """
    Represents the hyde configuration file
    """

    def __init__(self, sitepath, config_file=None, config_dict=None):
        self.default_config = dict(
            mode='production',
            simple_copy = [],
            content_root='content',
            deploy_root='deploy',
            media_root='media',
            layout_root='layout',
            media_url='/media',
            base_url="/",
            encode_safe=None,
            not_found='404.html',
            plugins = [],
            ignore = [ "*~", "*.bak", ".hg", ".git", ".svn"],
            meta = {
                "nodemeta": 'meta.yaml'
            }
        )
        self.config_file = config_file
        self.config_dict = config_dict
        self.load_time = datetime.min
        self.config_files = []
        self.sitepath = Folder(sitepath)
        super(Config, self).__init__(self.load())

    @property
    def last_modified(self):
        return max((conf.last_modified for conf in self.config_files))

    def needs_refresh(self):
        if not self.config_files:
            return True
        return any((conf.has_changed_since(self.load_time)
                        for conf in self.config_files))

    def load(self):
        conf = dict(**self.default_config)
        conf.update(self.read_config(self.config_file))
        if self.config_dict:
            conf.update(self.config_dict)
        return conf

    def reload(self):
        if not self.config_file:
            return
        self.update(self.load())


    def read_config(self, config_file):
        """
        Reads the configuration file and updates this
        object while allowing for inherited configurations.
        """
        conf_file = self.sitepath.child(
                            config_file if
                                    config_file else 'site.yaml')
        conf = {}
        if File(conf_file).exists:
            self.config_files.append(File(conf_file))
            logger.info("Reading site configuration from [%s]", conf_file)
            with codecs.open(conf_file, 'r', 'utf-8') as stream:
                conf = yaml.load(stream)
                if 'extends' in conf:
                    parent = self.read_config(conf['extends'])
                    parent.update(conf)
                    conf = parent
        self.load_time = datetime.now()
        return conf


    @property
    def deploy_root_path(self):
        """
        Derives the deploy root path from the site path
        """
        return self.sitepath.child_folder(self.deploy_root)

    @property
    def content_root_path(self):
        """
        Derives the content root path from the site path
        """
        return self.sitepath.child_folder(self.content_root)

    @property
    def media_root_path(self):
        """
        Derives the media root path from the content path
        """
        return self.content_root_path.child_folder(self.media_root)

    @property
    def layout_root_path(self):
        """
        Derives the layout root path from the site path
#.........这里部分代码省略.........
开发者ID:jperry,项目名称:hyde,代码行数:103,代码来源:model.py


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