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


Python path.Path类代码示例

本文整理汇总了Python中fbuild.path.Path的典型用法代码示例。如果您正苦于以下问题:Python Path类的具体用法?Python Path怎么用?Python Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: copy_dir_to

def copy_dir_to(ctx, dstdir, srcdir, *, pattern=None) -> fbuild.db.DSTS:
    #print("Copy dir to: from srcdir = " + 
    #  str(srcdir) + ", pattern=" + str(pattern) +
    #  ", to " + str(dstdir))
    srcdir = Path(srcdir)

    srcs = []
    dsts = []

    for src in srcdir.find(pattern=pattern, include_dirs=False):
        dst = src.removeroot(srcdir+os.sep).addroot(dstdir)
        dst.parent.makedirs()

        srcs.append(src)
        dsts.append(dst)

        #ctx.logger.check(' * copy', '%s -> %s' % (src, dst), color='yellow')
        try:
            src.copy(dst)
        except shutil.SameFileError:
            pass

    ctx.db.add_external_dependencies_to_call(srcs=srcs)

    return dsts
开发者ID:DawidvC,项目名称:felix,代码行数:25,代码来源:__init__.py

示例2: test_flx

def test_flx(phase, felix, src, *args, **kwargs):
    src = Path(src)

    passed = True
    for static in False, True:
        try:
            exe = felix.compile(src, static=static, flags=["--usage=prototype"])
        except fbuild.ExecutionError as e:
            phase.ctx.logger.log(e, verbose=1)
            if e.stdout:
                phase.ctx.logger.log(e.stdout.decode("utf-8", "ignore").strip(), verbose=1)
            if e.stderr:
                phase.ctx.logger.log(e.stderr.decode("utf-8", "ignore").strip(), verbose=1)
            passed = False
            continue

        if static:
            dst = exe + ".static.stdout"
        else:
            dst = exe + ".shared.stdout"

        expect = src.replaceext(".expect")

        passed &= check_flx(
            phase.ctx,
            felix,
            *args,
            exe=exe,
            dst=dst,
            expect=expect if expect.exists() else None,
            static=static,
            **kwargs
        )

    return passed
开发者ID:eccstartup,项目名称:felix,代码行数:35,代码来源:flx.py

示例3: test_flx

def test_flx(phase, felix, src, *args, **kwargs):
    src = Path(src)

    passed = True
    for static in False, True:
        try:
            exe = felix.compile(src, static=static)
        except fbuild.ExecutionError as e:
            phase.ctx.logger.log(e, verbose=1)
            if e.stdout:
                phase.ctx.logger.log(e.stdout.decode('utf-8','ignore').strip(), verbose=1)
            if e.stderr:
                phase.ctx.logger.log(e.stderr.decode('utf-8','ignore').strip(), verbose=1)
            passed = False
            continue

        if static:
            dst = exe + '.static.stdout'
        else:
            dst = exe + '.shared.stdout'

        expect = src.replaceext('.expect')

        passed &= check_flx(phase.ctx, felix, *args,
            exe=exe,
            dst=dst,
            expect=expect if expect.exists() else None,
            static=static,
            **kwargs)

    return passed
开发者ID:arowM,项目名称:felix,代码行数:31,代码来源:flx.py

示例4: __call__

    def __call__(self, dst, srcs, *args, buildroot=None, **kwargs):
        """Run a scala script."""

        dst = Path(dst).addroot(buildroot or self.ctx.buildroot)
        dst.makedirs()

        stdout, stderr = self._run(srcs, *args, dst=dst, **kwargs)
        return dst, stdout, stderr
开发者ID:felix-lang,项目名称:fbuild,代码行数:8,代码来源:scala.py

示例5: build

def build(ctx):
    rec = configure(ctx)
    src = rec.dasm.translate('src/x86_64.dasc', 'codegen.c')
    rejit = rec.c.build_lib('rejit', Path.glob('src/*.c') + Path.glob('utf/*.c'),
        includes=['.', ctx.buildroot])
    rec.c.build_exe('bench', ['bench.c'], libs=[rejit])
    rec.c.build_exe('ex', ['ex.c'], libs=[rejit])
    if rec.tests:
        rec.c.build_exe('tst', ['tst.c'], cflags=rec.testflags, libs=[rejit])
开发者ID:kirbyfan64,项目名称:rejit,代码行数:9,代码来源:fbuildroot.py

示例6: tempdir

def tempdir(*args, **kwargs):
    '''
    Create a temporary directory and yield it's path. When we regain context,
    remove the directory.
    '''

    path = Path(_tempfile.mkdtemp(*args, **kwargs))
    try:
        yield path
    finally:
        path.rmtree(ignore_errors=True)
开发者ID:DawidvC,项目名称:felix,代码行数:11,代码来源:temp.py

示例7: tempdir

def tempdir(dir=None, delete=False, *args, **kwargs):
    '''
    Create a temporary directory and yield it's path. If *delete* is truthy,
    when we regain context, remove the directory.
    '''

    path = Path(_tempfile.mkdtemp(dir=dir or _default_tempdir, *args, **kwargs))
    try:
        yield path
    finally:
        if delete:
            path.rmtree(ignore_errors=True)
开发者ID:felix-lang,项目名称:fbuild,代码行数:12,代码来源:temp.py

示例8: move_to

def move_to(ctx, dstdir, srcs:fbuild.db.SRCS) -> fbuild.db.DSTS:
    dstdir.makedirs()

    dsts = []

    for src in srcs:
        src = Path(src)
        dst = dstdir / src.name
        ctx.logger.check(' * move', '%s -> %s' % (src, dst), color='yellow')
        src.move(dst)
        dsts.append(dst)

    return dsts
开发者ID:FelixKiprono,项目名称:felix,代码行数:13,代码来源:__init__.py

示例9: run_test

    def run_test(src):
        src = Path(src)
        dst = _make_stdout_dst(ctx, src)
        expect = src.replaceext('.expect')

        # Make sure the destination directory exists.
        dst.parent.makedirs()

        if not expect.exists():
            expect = None

        passed = check_flxi_test(ctx, src=src, dst=dst, expect=expect)
        return src, passed
开发者ID:erickt,项目名称:felix2,代码行数:13,代码来源:test.py

示例10: check_fluid

def check_fluid(linker):
    fluidsynth = Path(linker.prefix + 'fluidsynth' + linker.suffix)
    fluidsynth = fluidsynth.addroot(Path('fluidsynth') / 'fluidsynth' / 'src')

    message = textwrap.dedent('''
    You need to build Fluidsynth separately first!
    Try runnung 'cd fluidsynth/fluidsynth; cmake'.
    (See http://sourceforge.net/p/fluidsynth/wiki/BuildingWithCMake/ for info.)
    '''.rstrip().lstrip('\n')).replace('\n', ' ', 1)

    if not fluidsynth.exists():
        raise fbuild.ConfigFailed(message)

    return fluidsynth
开发者ID:midifi,项目名称:midifi,代码行数:14,代码来源:fbuildroot.py

示例11: __call__

    def __call__(
        self, src: fbuild.db.SRC, *, break_on_error=True, flags=[], buildroot=None, **kwargs
    ) -> fbuild.db.DSTS:
        buildroot = buildroot or self.ctx.buildroot
        src = Path(src)

        cmd = [
            sys.executable,
            self.exe.relpath(buildroot),
            "--cache-prefix=lpsrc-cache",
            "--trace=sources",
            "--trace=changes",
            "--nocache",
        ]

        if break_on_error:
            cmd.append("--break-on-error")
        cmd.extend(flags)
        cmd.append(src.relpath(buildroot))

        stdout, stderr = self.ctx.execute(
            cmd,
            "iscr extracting",
            src,
            color="green",
            cwd=buildroot,
            env={"PYTHONPATH": Path("buildsystem").relpath(buildroot)},
            **kwargs
        )

        srcs = []
        dsts = []
        ipk_regex = re.compile("^CREATING .* NAMED FILE SOURCE (.*) \[.*\]")
        file_regex = re.compile("^File (.*) is (NEW|CHANGED|unchanged)")
        for line in io.StringIO(stdout.decode()):
            m = ipk_regex.match(line)
            if m:
                path = Path(m.group(1))
                if not path.exists():
                    # The path may be relative to the .pak file.
                    path = src.parent / path
                srcs.append(path)
            else:
                m = file_regex.match(line)
                if m:
                    dsts.append(Path(m.group(1)))

        # self.ctx.db.add_external_dependencies_to_call(srcs=srcs)

        return dsts
开发者ID:narychen,项目名称:felix,代码行数:50,代码来源:iscr.py

示例12: build_flx_drivers

def build_flx_drivers(phase):
    path = Path('src/compiler/drivers')

    call('buildsystem.ocs.build_exe', phase)

    lib = phase.ocaml.build_lib(path / 'flx_driver',
        srcs=Path.glob(path / '*.ml{,i}'))

    return {
        'flxi': phase.ocaml.build_exe('bin/flxi',
            srcs=Path(path / 'flxi' / '*.ml{,i}').glob(),
            libs=[
                call('buildsystem.dypgen.build_lib', phase),
                call('buildsystem.ocs.build_lib', phase),
                lib,
                build_flx_misc(phase),
                build_flx_core(phase),
                build_flx_parse(phase),
                build_flx_bind(phase),
                build_flx_codegen(phase)],
            external_libs=[
                'batteries',
                'threads',
                'llvm',
                'llvm_analysis',
                'llvm_executionengine',
                'llvm_scalar_opts',
                'llvm_target'],
            flags=['-thread'],
            packages=['batteries'],
            cc=phase.cxx.static.compiler.gcc.exe) }
开发者ID:erickt,项目名称:felix2,代码行数:31,代码来源:flx_compiler.py

示例13: build

def build(phase, felix):
    print ("BUILDING PLUGINS")
    for f in Path.glob('src/lib/plugins/*'):
      copy(ctx=phase.ctx, src=f, dst=phase.ctx.buildroot / 'share'/f[4:]) 
    plugins = [
      #"ocaml2html",
      #"py2html",
      #"fdoc2html",
      #"flx2html",
      #"cpp2html",
      #"fpc2html",
      #"fdoc_slideshow",
      #"fdoc_paragraph",
      #"fdoc_heading",
      #"fdoc_fileseq",
      #"fdoc_scanner",
      #"fdoc_button",
      "toolchain_clang_osx",
      "toolchain_clang_linux",
      "toolchain_gcc_osx",
      "toolchain_gcc_linux",
      "toolchain_gcc48_linux",
      ]
    for base in plugins:
      shlib = felix.compile(phase.ctx.buildroot/('share/lib/plugins/'+base+'.flx'),flags=['-od',phase.ctx.buildroot/'host/lib/rtl'])
开发者ID:martindemello,项目名称:felix,代码行数:25,代码来源:plugins.py

示例14: copy_to

def copy_to(ctx, dstdir, srcs:fbuild.db.SRCS) -> fbuild.db.DSTS:
    dstdir.makedirs()

    dsts = []

    for src in srcs:
        src = Path(src)
        dst = dstdir / src.name
        ctx.logger.check(' * copy', '%s -> %s' % (src, dst), color='yellow')
        try:
            src.copy(dst)
        except shutil.SameFileError:
            pass
        dsts.append(dst)

    return dsts
开发者ID:FelixKiprono,项目名称:felix,代码行数:16,代码来源:__init__.py

示例15: __call__

    def __call__(self, src:fbuild.db.SRC, dst=None, *,
            suffix=None,
            verbose=False,
            name_prefix=None,
            defines=False,
            flags=[],
            buildroot=None) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot
        suffix = suffix or self.suffix
        dst = Path.addroot(dst or src, buildroot).replaceext(suffix)
        dst.parent.makedirs()

        cmd = [self.exe]

        if verbose:
            cmd.append('-v')

        if name_prefix is not None:
            cmd.extend(('-p', name_prefix))

        if defines:
            cmd.append('-d')

        cmd.extend(self.flags)
        cmd.extend(flags)
        cmd.extend(('-o', dst))
        cmd.append(src)

        self.ctx.execute(cmd, self.exe, '%s -> %s' % (src, dst), color='yellow')

        return dst
开发者ID:felix-lang,项目名称:fbuild,代码行数:31,代码来源:bison.py


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