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


Python Path.child方法代码示例

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


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

示例1: builder_inited

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def builder_inited(app):
    """Define certain settings
    """
    mydir = Path(__file__).parent.child('static').absolute()
    app.config.html_static_path.append(mydir)
    app.config.html_logo = mydir.child('logo_web3.png')
    app.config.html_favicon = mydir.child('favicon.ico')
开发者ID:lino-framework,项目名称:lino,代码行数:9,代码来源:__init__.py

示例2: environment

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def environment(**options):
    queryfinder = QueryFinder()

    searchpath =[]
    staticdirs = []

    sites = settings.SHEER_SITES
    for site in sites:
        site_path = Path(site)
        searchpath.append(site_path)
        searchpath.append(site_path.child('_includes'))
        searchpath.append(site_path.child('_layouts'))
        staticdirs.append(site_path.child('static'))

    options['loader'].searchpath += searchpath
    settings.STATICFILES_DIRS = staticdirs

    env = SheerlikeEnvironment(**options)
    env.globals.update({
        'static': staticfiles_storage.url,
        'url_for':url_for,
        'url': reverse,
        'queries': queryfinder,
        'more_like_this': more_like_this,
        'get_document': get_document,
        'selected_filters_for_field': selected_filters_for_field,
        'is_filter_selected': is_filter_selected,
    })
    env.filters.update({
        'date':date_filter
    })
    return env
开发者ID:kave,项目名称:django-sheerlike,代码行数:34,代码来源:__init__.py

示例3: build_jar

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
 def build_jar(self, outdir, alias):
     flags = '-storepass "`cat ~/.secret/.keystore_password`"'
     flags += ' -tsa http://timestamp.globalsign.com/scripts/timestamp.dll'
     outdir = Path(outdir)
     jarfile = outdir.child(self.jarfile)
     if jarfile.needs_update(self.jarcontent):
         local("jar cvfm %s %s" % (jarfile, ' '.join(self.jarcontent)))
     local("jarsigner %s %s %s" % (flags, jarfile, alias))
     for libfile in self.libjars:
         jarfile = outdir.child(libfile.name)
         if libfile.needs_update([jarfile]):
             libfile.copy(jarfile)
         local("jarsigner %s %s %s" % (flags, jarfile, alias))
开发者ID:ManuelWeidmann,项目名称:atelier,代码行数:15,代码来源:fablib.py

示例4: add_deployment

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def add_deployment(directory, name, templates_dir='templates', deployment_dir='deployment', mode=0777):
    """ Adds new deployment if not exists
    """
    context = {
        'datetime': datetime.datetime.now(),
        'name': name,
        'project_name': get_project_name(directory)
    }

    dd, df = get_deployment_info(directory, name)

    if df.exists():
        raise ExistingDeploymentError()

    # create deployments directory
    df.parent.mkdir(parents=True, mode=mode)

    # write deployment file
    df.write_file(
        get_rendered_template('deployment.py', context)
    )
    top_td = Path(__file__).parent.child(templates_dir)
    td = top_td.child(deployment_dir)
    for tf in td.walk():
        if tf.isdir():
            continue
        partitioned = tf.partition(td)
        target = Path(dd, Path(partitioned[2][1:]))
        target_dir = target.parent
        if not target_dir.exists():
            target_dir.mkdir(parents=True, mode=mode)
        tmp = tf.partition(top_td)[2][1:]
        rendered = get_rendered_template(tmp, context)
        target.write_file(rendered)
开发者ID:phonkee,项目名称:easyfab,代码行数:36,代码来源:commands.py

示例5: activate_env

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def activate_env():
    """ Activates the virtual environment for this project."""

    error_msg = None

    try:
        virtualenv_dir = Path(os.environ['WORKON_HOME'])
    except KeyError:
        error_msg = "Error: 'WORKON_HOME' is not set."

    if error_msg:
        color_init()
        sys.stderr.write(Fore.RED + Style.BRIGHT + error_msg + "\n")
        sys.exit(1)

    filepath = Path(__file__).absolute()
    site_dir = filepath.ancestor(4).components()[-1]
    repo_dir = filepath.ancestor(3).components()[-1]

    # Add the app's directory to the PYTHONPATH
    sys.path.append(filepath.ancestor(2))
    sys.path.append(filepath.ancestor(1))

    # Set manually in environment
    #os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'

    if os.environ['DJANGO_SETTINGS_MODULE'] == 'settings.production':
        bin_parent = site_dir
    else:
        bin_parent = repo_dir

    # Activate the virtual env
    activate_env = virtualenv_dir.child(bin_parent, "bin", "activate_this.py")
    execfile(activate_env, dict(__file__=activate_env))
开发者ID:copperwall,项目名称:SchedulerTool,代码行数:36,代码来源:manage.py

示例6: sphinx_build

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def sphinx_build(builder, docs_dir,
                 cmdline_args=[], language=None, build_dir_cmd=None):
    args = ['sphinx-build', '-b', builder]
    args += cmdline_args
    # ~ args += ['-a'] # all files, not only outdated
    # ~ args += ['-P'] # no postmortem
    # ~ args += ['-Q'] # no output
    # build_dir = docs_dir.child(env.build_dir_name)
    build_dir = Path(env.build_dir_name)
    if language is not None:
        args += ['-D', 'language=' + language]
        # needed in select_lang.html template
        args += ['-A', 'language=' + language]
        if language != env.languages[0]:
            build_dir = build_dir.child(language)
            #~ print 20130726, build_dir
    if env.tolerate_sphinx_warnings:
        args += ['-w', 'warnings_%s.txt' % builder]
    else:
        args += ['-W']  # consider warnings as errors
        # args += ['-vvv']  # increase verbosity
    #~ args += ['-w'+Path(env.root_dir,'sphinx_doctest_warnings.txt')]
    args += ['.', build_dir]
    cmd = ' '.join(args)
    with lcd(docs_dir):
        local(cmd)
    if build_dir_cmd is not None:
        with lcd(build_dir):
            local(build_dir_cmd)
开发者ID:khchine5,项目名称:atelier,代码行数:31,代码来源:fablib.py

示例7: test_dump2py

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
 def test_dump2py(self):
     for prj in ["lino_book/projects/belref"]:
         p = Path(prj)
         tmp = p.child('tmp').absolute()
         tmp.rmtree()
         self.run_django_admin_command_cd(p, 'dump2py', tmp)
         self.assertEqual(tmp.child('restore.py').exists(), True)
开发者ID:khchine5,项目名称:book,代码行数:9,代码来源:test_misc.py

示例8: create_server_config

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def create_server_config():
    """
    1) Create temporary copy of all files from project_name/server_config
       in project_dir/tmp.
    2) Replace template tags using sed commands to fill missing paths.

    Template variables
    PROJECT_DIR
    PROJECT_NAME
    STAGE
    USER

    """

    extensions = {"dev": "-dev", "stage": "-stage", "prod": "-prod"}

    stage = prompt("Set stage: [dev|stage|prod]: ")
    user = prompt("System username: ")
    nginx_server_address = prompt("Nginx ip/domain: ")
    project_name = prompt("Project name: ")
    project_name = project_name + extensions[stage]

    PROJECT_DIR = Path(__file__).parent
    SERVER_CONFIG_FILES_DIR = PROJECT_DIR.child("server_config")

    replace_project_dir = "sed -i 's,PROJECT_DIR,{project_dir},g' {target_file}"
    replace_user = "sed -i 's,USER,{user},g' {target_file}"
    replace_project_name = "sed -i 's,PROJECT_NAME,{project_name},g' {target_file}"
    replace_stage = "sed -i 's,STAGE,{stage},g' {target_file}"
    replace_nginx_server_address = "sed -i 's,NGINX_SERVER_ADDRESS,{nginx_server_address},g' {target_file}"

    tmp = PROJECT_DIR.child("tmp")
    local("mkdir {} -p".format(tmp))
    # Copy all server config files to tmp directory
    local("cp {}/* {}".format(SERVER_CONFIG_FILES_DIR, tmp))
    # Change nginx file name
    local("mv {}/nginx {}/{}".format(tmp, tmp, project_name))
    # Change supervisor file name
    local("mv {}/supervisor {}/{}.conf".format(tmp, tmp, project_name))

    for path in tmp.listdir():
        local(replace_project_dir.format(project_dir=PROJECT_DIR, target_file=path))
        local(replace_user.format(user=user, target_file=path))
        local(replace_project_name.format(project_name=project_name, target_file=path))
        local(replace_stage.format(stage=stage, target_file=path))
        local(replace_nginx_server_address.format(nginx_server_address=nginx_server_address, target_file=path))
    print("Finished processing templates for server config.")
开发者ID:jacol12345,项目名称:django-project-template,代码行数:49,代码来源:fabfile.py

示例9: savejson

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def savejson(d):
    status = d['status']
    if status.startswith('Pendent'):
        status = 'Pendent'
    carpeta = Path(exportpath, status, d['year'], d['month'])
    carpeta.mkdir(parents=True)
    fpath = carpeta.child('{}.json'.format(d['id']))
    with open(fpath, 'w') as f:
        json.dump(d, f, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:chaosct,项目名称:ideatorrent-extractor,代码行数:11,代码来源:extreuinfo.py

示例10: update_catalog_code

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def update_catalog_code():
    """Update .po files from .pot file."""
    from lino.core.site import to_locale
    locale_dir = env.locale_dir
    # locale_dir = get_locale_dir()
    if locale_dir is None:
        return
    locale_dir = Path(locale_dir)
    for loc in env.languages:
        if loc != env.languages[0]:
            args = ["python", "setup.py"]
            args += ["update_catalog"]
            args += ["--domain django"]
            #~ args += [ "-d" , locale_dir ]
            args += ["-o", locale_dir.child(loc, 'LC_MESSAGES', 'django.po')]
            args += ["-i", locale_dir.child("django.pot")]
            args += ["-l", to_locale(loc)]
            cmd = ' '.join(args)
            #~ must_confirm(cmd)
            local(cmd)
开发者ID:khchine5,项目名称:atelier,代码行数:22,代码来源:fablib.py

示例11: build_jar

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
    def build_jar(self, ctx, outdir, alias):
        flags = '-storepass "`cat ~/.secret/.keystore_password`"'
        if self.tsa:
            flags += ' -tsa {0}'.format(self.tsa)

        def run_signer(jarfile):
            ctx.run("jarsigner %s %s %s" % (flags, jarfile, alias), pty=True)
            ctx.run("jarsigner -verify %s" % jarfile, pty=True)

        outdir = Path(outdir)
        jarfile = outdir.child(self.jarfile)
        if jarfile.needs_update(self.jarcontent):
            jarcontent = [x.replace("$", r"\$") for x in self.jarcontent]
            ctx.run("jar cvfm %s %s" % (jarfile, ' '.join(jarcontent)), pty=True)
        run_signer(jarfile)
        for libfile in self.libjars:
            jarfile = outdir.child(libfile.name)
            if not jarfile.exists() or libfile.needs_update([jarfile]):
                libfile.copy(jarfile)
            run_signer(jarfile)
开发者ID:khchine5,项目名称:atelier,代码行数:22,代码来源:jarbuilder.py

示例12: dev

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def dev():
    env.hosts = ['77.120.104.181']
    env.user = 'dev'
    env.port = 2020

    env.shell = '/bin/sh -c'

    env.django_settings_module = 'settings.development'

    project_path = Path('/var/home/dev/multiad/')
    env.env_path = project_path.child('env','bin')
    env.django_path = project_path.child('multiad', 'project')
    gunicorn_wsgi = 'wsgi:application'
    gunicorn_port = 9324
    env.gunicorn_pid = project_path.child('gunicorn.pid')
    settings = 'settings.development'
    worker_count = 3
    cfg_template = '{} -b 127.0.0.1:{} -w{} --max-requests=500 -D --pid {}'
    env.gunicorn_cfg = cfg_template.format(
        gunicorn_wsgi, gunicorn_port, worker_count, env.gunicorn_pid
    )
开发者ID:kharandziuk,项目名称:django-dev-env,代码行数:23,代码来源:fabfile.py

示例13: init

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def init(directory, deployment_dir='deployment', mode=0777):
    """ Initializes easyfab fabric file along with deployments directory
    """
    directory = Path(directory)
    path = directory.child(deployment_dir)
    if path.exists():
        print 'Deployment directory already exists'
    else:
        path.mkdir(parents=True, mode=mode)

    # write module constuctor
    path.child('__init__.py').write_file("")

    fabfile = directory.child('fabfile.py')
    if fabfile.exists():
        print 'fabfile already exists'
    else:
        rendered = get_rendered_template('fabfile.py', {
            'datetime': datetime.datetime.now()
        })
        fabfile.write_file(rendered)
开发者ID:phonkee,项目名称:easyfab,代码行数:23,代码来源:commands.py

示例14: __get_path

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
 def __get_path(self):
     """
     Gets the path to the backup location
     :return: Unipath if local, string if FTP
     """
     if self.ftp:
         return 'ftp://{}{}'.format(self.ftp_server,
                                    self.__slashes(self.ftp_path))
     else:
         basedir = Path(self.config.get('BASE_DIR', ''))
         backup_dir = basedir.child('alchemydumps')
         if not backup_dir.exists():
             backup_dir.mkdir()
         return self.__slashes(str(backup_dir.absolute()))
开发者ID:YukSeungChan,项目名称:alchemydumps,代码行数:16,代码来源:backup.py

示例15: get_project_info_tasks

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import child [as 别名]
def get_project_info_tasks(root_dir):
    "Find the project info for the given directory."
    prj = _PROJECTS_DICT.get(root_dir)
    if prj is None:
        # if no config.py found, add current working directory.
        p = Path().resolve()
        while p:
            if p.child('tasks.py').exists():
                prj = add_project(p)
                break
            p = p.parent
        # raise Exception("No %s in %s" % (root_dir, _PROJECTS_DICT.keys()))
    prj.load_tasks()
    return prj
开发者ID:khchine5,项目名称:atelier,代码行数:16,代码来源:projects.py


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