• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python udir.join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_dont_inherit_across_import

    def test_dont_inherit_across_import(self):
        from pypy.tool.udir import udir

        udir.join("test_dont_inherit_across_import.py").write("x = 1/2\n")
        space = self.space
        s1 = str(
            py.code.Source(
                """
            from __future__ import division
            from test_dont_inherit_across_import import x
        """
            )
        )
        w_result = space.appexec(
            [space.wrap(str(udir)), space.wrap(s1)],
            """(udir, s1):
            import sys
            copy = sys.path[:]
            sys.path.insert(0, udir)
            try:
                exec s1
            finally:
                sys.path[:] = copy
            return x
        """,
        )
        assert space.float_w(w_result) == 0
开发者ID:camillobruni,项目名称:pygirl,代码行数:27,代码来源:test_compiler.py


示例2: compile_shared_lib

 def compile_shared_lib(self, outputfilename=None):
     self = self.convert_sources_to_files()
     if not self.separate_module_files:
         if sys.platform != 'win32':
             return self
         if not self.export_symbols:
             return self
         basepath = udir.join('module_cache')
     else:
         #basepath = py.path.local(self.separate_module_files[0]).dirpath()
         basepath = udir.join('shared_cache')
     if outputfilename is None:
         # find more or less unique name there
         pth = basepath.join('externmod').new(ext=host.so_ext)
         num = 0
         while pth.check():
             pth = basepath.join(
                 'externmod_%d' % (num,)).new(ext=host.so_ext)
             num += 1
         basepath.ensure(dir=1)
         outputfilename = str(pth.dirpath().join(pth.purebasename))
     lib = str(host.compile([], self, outputfilename=outputfilename,
                            standalone=False))
     d = self._copy_attributes()
     d['libraries'] += (lib,)
     d['separate_module_files'] = ()
     d['separate_module_sources'] = ()
     return ExternalCompilationInfo(**d)
开发者ID:are-prabhu,项目名称:pypy,代码行数:28,代码来源:cbuild.py


示例3: test_main_two

 def test_main_two(self):
     udir.ensure("js_two.py").write(py.code.Source("""
     def f():
         pass
     """))
     self._test_not_raises(udir.join("js_two.py"), ["f"])
     self._test_raises(udir.join("js_two.py"), [])
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_main.py


示例4: test_gcc_exec

def test_gcc_exec():
    f = udir.join("x.c")
    f.write("""
    #include <stdio.h>
    #include <test_gcc_exec.h>
    int main()
    {
       printf("%d\\n", ANSWER);
       return 0;
    }
    """)
    dir1 = udir.join('test_gcc_exec_dir1').ensure(dir=1)
    dir2 = udir.join('test_gcc_exec_dir2').ensure(dir=1)
    dir1.join('test_gcc_exec.h').write('#define ANSWER 3\n')
    dir2.join('test_gcc_exec.h').write('#define ANSWER 42\n')
    eci = ExternalCompilationInfo(include_dirs=[str(dir1)])
    # remove cache
    path = cache_file_path([f], eci, 'build_executable_cache')
    if path.check():
        path.remove()
    res = build_executable_cache([f], eci)
    assert res == "3\n"
    assert build_executable_cache([f], eci) == "3\n"
    eci2 = ExternalCompilationInfo(include_dirs=[str(dir2)])
    assert build_executable_cache([f], eci2) == "42\n"
    f.write("#error BOOM\n")
    err = py.test.raises(CompilationError, build_executable_cache, [f], eci2)
    print '<<<'
    print err
    print '>>>'
开发者ID:alkorzt,项目名称:pypy,代码行数:30,代码来源:test_gcc_cache.py


示例5: test_gcc_ask

def test_gcc_ask():
    f = udir.join("y.c")
    f.write("""
    #include <stdio.h>
    #include <test_gcc_ask.h>
    int main()
    {
       printf("hello\\n");
       return 0;
    }
    """)
    dir1 = udir.join('test_gcc_ask_dir1').ensure(dir=1)
    dir2 = udir.join('test_gcc_ask_dir2').ensure(dir=1)
    dir1.join('test_gcc_ask.h').write('/* hello world */\n')
    dir2.join('test_gcc_ask.h').write('#error boom\n')
    eci = ExternalCompilationInfo(include_dirs=[str(dir1)])
    # remove cache
    path = cache_file_path([f], eci, 'try_compile_cache')
    if path.check():
        path.remove()
    assert try_compile_cache([f], eci)
    assert try_compile_cache([f], eci)
    assert build_executable_cache([f], eci) == "hello\n"
    eci2 = ExternalCompilationInfo(include_dirs=[str(dir2)])
    err = py.test.raises(CompilationError, try_compile_cache, [f], eci2)
    print '<<<'
    print err
    print '>>>'
开发者ID:alkorzt,项目名称:pypy,代码行数:28,代码来源:test_gcc_cache.py


示例6: setup_module

def setup_module(mod):
    if os.name != 'nt':
        mod.space = gettestobjspace(usemodules=['posix', 'fcntl'])
    else:
        # On windows, os.popen uses the subprocess module
        mod.space = gettestobjspace(usemodules=['posix', '_rawffi', 'thread'])
    mod.path = udir.join('posixtestfile.txt')
    mod.path.write("this is a test")
    mod.path2 = udir.join('test_posix2-')
    pdir = udir.ensure('posixtestdir', dir=True)
    pdir.join('file1').write("test1")
    os.chmod(str(pdir.join('file1')), 0600)
    pdir.join('file2').write("test2")
    pdir.join('another_longer_file_name').write("test3")
    mod.pdir = pdir
    unicode_dir = udir.ensure('fi\xc5\x9fier.txt', dir=True)
    unicode_dir.join('somefile').write('who cares?')
    mod.unicode_dir = unicode_dir

    # in applevel tests, os.stat uses the CPython os.stat.
    # Be sure to return times with full precision
    # even when running on top of CPython 2.4.
    os.stat_float_times(True)

    # Initialize sys.filesystemencoding
    space.call_method(space.getbuiltinmodule('sys'), 'getfilesystemencoding')
开发者ID:ieure,项目名称:pypy,代码行数:26,代码来源:test_posix2.py


示例7: test_32bit_makefile

    def test_32bit_makefile(self):
        if platform.machine() != "i386":
            py.test.skip("i386 only")
        plat32 = Darwin_i386()
        plat64 = Darwin_x86_64()
        eci = ExternalCompilationInfo()
        cfile_content = r"""
        #include <stdio.h>
        #include <limits.h>

        int main() {
                printf("%d\n", INT_MAX < LONG_MAX);
                return 0;
        }
        """

        tmpdir = udir.join("32_makefile" + self.__class__.__name__).ensure(dir=1)
        cfile = tmpdir.join("test_int_size.c")
        cfile.write(cfile_content)
        mk = plat32.gen_makefile([cfile], ExternalCompilationInfo(), path=tmpdir)
        mk.write()
        plat32.execute_makefile(mk)
        res = plat32.execute(tmpdir.join("test_int_size"))
        self.check_res(res, "0\n")
        if host_factory == Darwin_x86_64:
            tmpdir = udir.join("64_makefile" + self.__class__.__name__).ensure(dir=1)
            cfile = tmpdir.join("test_int_size.c")
            cfile.write(cfile_content)
            mk = plat64.gen_makefile([cfile], ExternalCompilationInfo(), path=tmpdir)
            mk.write()
            plat64.execute_makefile(mk)
            res = plat64.execute(tmpdir.join("test_int_size"))
            self.check_res(res, "1\n")
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:33,代码来源:test_darwin.py


示例8: setup_class

 def setup_class(cls):
     compiler = ccompiler.new_compiler()
     c_file = udir.join('rffilib.c')
     c_file.write(c_source)
     compiler.compile([str(c_file)], output_dir='/')
     compiler.link_shared_lib([str(udir.join('rffilib.o'))],
                               'rffi', output_dir=str(udir))
     cls.lib = ctypes.CDLL(str(udir.join('librffi.so')))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:test_c.py


示例9: setup_module

def setup_module(mod): 
    mod.space = gettestobjspace(usemodules=['posix'])
    mod.path = udir.join('posixtestfile.txt') 
    mod.path.write("this is a test")
    mod.path2 = udir.join('posixtestlargefile')
    pdir = udir.ensure('posixtestdir', dir=True)
    pdir.join('file1').write("test1")
    os.chmod(str(pdir.join('file1')), 0600)
    pdir.join('file2').write("test2")
    pdir.join('another_longer_file_name').write("test3")
    mod.pdir = pdir
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:test_posix2.py


示例10: setup_class

 def setup_class(cls):
     testfn.write(testcode, 'w')
     udir.join(testmodule + '.py').write(testmodulecode, 'w')
     udir.ensure(testpackage, '__init__.py')
     udir.join(testpackage, testmodule + '.py').write(testmodulecode, 'w')
     space = cls.space
     cls.w_oldsyspath = space.appexec([space.wrap(str(udir))], """(udir):
         import sys
         old = sys.path[:]
         sys.path.insert(0, udir)
         return old
     """)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:12,代码来源:test_main.py


示例11: rundemo

def rundemo(entrypoint, *args):
    view = conftest.option.view
    seed = demo_conftest.option.randomseed
    benchmark = bench_conftest.option.benchmark

    logfile = str(udir.join('%s.log' % (entrypoint.__name__,)))
    try:
        os.unlink(logfile)
    except OSError:
        pass
    os.environ['PYPYJITLOG'] = logfile

    if benchmark:
        py.test.skip("benchmarking: working in progress")
        arglist = ', '.join(['a%d' % i for i in range(len(args))])
        miniglobals = {'Benchmark': bench_conftest.Benchmark,
                       'original_entrypoint': entrypoint}
        exec py.code.Source("""
            def benchmark_runner(%s):
                bench = Benchmark()
                while 1:
                    res = original_entrypoint(%s)
                    if bench.stop():
                        break
                return res
        """ % (arglist, arglist)).compile() in miniglobals
        entrypoint = miniglobals['benchmark_runner']

    nb_args = len(args)      # XXX ints only for now
    if machine_code_dumper:
        machine_code_dumper._freeze_() # clean up state
    rgenop = RGenOp()
    gv_entrypoint = rcompile(rgenop, entrypoint, [int]*nb_args,
                             random_seed=seed)
    if machine_code_dumper:
        machine_code_dumper._freeze_()    # clean up state

    print
    print 'Random seed value: %d' % (seed,)
    print

    print 'Running %s(%s)...' % (entrypoint.__name__,
                                 ', '.join(map(repr, args)))
    expected = entrypoint(*args)
    print 'Python ===>', expected
    F1 = lltype.FuncType([lltype.Signed] * nb_args, lltype.Signed)
    fp = RGenOp.get_python_callable(lltype.Ptr(F1), gv_entrypoint)
    res = runfp(fp, *args)
    print '%-6s ===>' % RGenOp.__name__, res
    print
    if res != expected:
        raise AssertionError(
            "expected return value is %s, got %s\nseed = %s" % (
                expected, res, seed))

    if view and machine_code_dumper:
        from pypy.jit.codegen.i386.viewcode import World
        world = World()
        world.parse(open(logfile))
        world.show()
开发者ID:antoine1fr,项目名称:pygirl,代码行数:60,代码来源:support.py


示例12: eating_callback

    def eating_callback(self):
        h_source = py.code.Source("""
        #ifndef _CALLBACK_H
        #define _CALLBACK_H
        extern Signed eating_callback(Signed arg, Signed(*call)(Signed));
        #endif /* _CALLBACK_H */
        """)
        
        h_include = udir.join('callback.h')
        h_include.write(h_source)

        c_source = py.code.Source("""
        Signed eating_callback(Signed arg, Signed(*call)(Signed))
        {
            Signed res = call(arg);
            if (res == -1)
              return -1;
            return res;
        }
        """)

        eci = ExternalCompilationInfo(includes=['callback.h'],
                                      include_dirs=[str(udir)],
                                      separate_module_sources=[c_source],
                                      export_symbols=['eating_callback'])

        args = [SIGNED, CCallback([SIGNED], SIGNED)]
        eating_callback = llexternal('eating_callback', args, SIGNED,
                                     compilation_info=eci)

        return eating_callback
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:test_rffi.py


示例13: return_char

 def return_char(self, signed):
     ctype_pref = ["un", ""][signed]
     rffi_type = [UCHAR, SIGNEDCHAR][signed]
     h_source = py.code.Source("""
     %ssigned char returnchar(void)
     {
         return 42;
     }
     """ % (ctype_pref, ))
     h_file = udir.join("opaque2%s.h" % (ctype_pref, ))
     h_file.write(h_source)
 
     from pypy.rpython.tool import rffi_platform
     eci = ExternalCompilationInfo(
         includes=[h_file.basename],
         include_dirs=[str(udir)]
     )
     ll_returnchar = llexternal('returnchar', [], rffi_type, compilation_info=eci)
 
     def f():
         result = ll_returnchar()
         return result
 
     f1 = self.compile(f, [])
     assert f1() == chr(42)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:25,代码来源:test_rffi.py


示例14: test_prebuilt_constant

 def test_prebuilt_constant(self):
     py.test.skip("Think how to do it sane")
     h_source = py.code.Source("""
     int x = 3;
     char** z = NULL;
     #endif
     """)
     h_include = udir.join('constants.h')
     h_include.write(h_source)
 
     eci = ExternalCompilationInfo(includes=['stdio.h',
                                             str(h_include.basename)],
                                   include_dirs=[str(udir)])
 
     get_x, set_x = CExternVariable(lltype.Signed, 'x', eci)
     get_z, set_z = CExternVariable(CCHARPP, 'z', eci)
 
     def f():
         one = get_x()
         set_x(13)
         return one + get_x()
 
     def g():
         l = liststr2charpp(["a", "b", "c"])
         try:
             set_z(l)
             return charp2str(get_z()[2])
         finally:
             free_charpp(l)
 
     fn = self.compile(f, [])
     assert fn() == 16
     gn = self.compile(g, [])
     assert gn() == "c"
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:34,代码来源:test_rffi.py


示例15: convert_sources_to_files

 def convert_sources_to_files(self, cache_dir=None, being_main=False):
     if not self.separate_module_sources:
         return self
     if cache_dir is None:
         cache_dir = udir.join('module_cache').ensure(dir=1)
     num = 0
     files = []
     for source in self.separate_module_sources:
         while 1:
             filename = cache_dir.join('module_%d.c' % num)
             num += 1
             if not filename.check():
                 break
         f = filename.open("w")
         if being_main:
             f.write("#define PYPY_NOT_MAIN_FILE\n")
         if sys.platform == 'win32':
             f.write("#define WIN32_LEAN_AND_MEAN\n")
         self.write_c_header(f)
         source = str(source)
         f.write(source)
         if not source.endswith('\n'):
             f.write('\n')
         f.close()
         files.append(str(filename))
     d = self._copy_attributes()
     d['separate_module_sources'] = ()
     d['separate_module_files'] += tuple(files)
     return ExternalCompilationInfo(**d)
开发者ID:alkorzt,项目名称:pypy,代码行数:29,代码来源:cbuild.py


示例16: instrument_result

    def instrument_result(self, args):
        backend, ts = self.get_backend_and_type_system()
        if backend != 'c' or sys.platform == 'win32':
            raise Exception("instrumentation requires the c backend"
                            " and unix for now")
        from pypy.tool.udir import udir
        
        datafile = udir.join('_instrument_counters')
        makeProfInstrument = lambda compiler: ProfInstrument(datafile, compiler)

        pid = os.fork()
        if pid == 0:
            # child compiling and running with instrumentation
            self.config.translation.instrument = True
            self.config.translation.instrumentctl = (makeProfInstrument,
                                                     args)
            raise Instrument
        else:
            pid, status = os.waitpid(pid, 0)
            if os.WIFEXITED(status):
                status = os.WEXITSTATUS(status)
                if status != 0:
                    raise Exception, "instrumentation child failed: %d" % status
            else:
                raise Exception, "instrumentation child aborted"
            import array, struct
            n = datafile.size()//struct.calcsize('L')
            datafile = datafile.open('rb')
            counters = array.array('L')
            counters.fromfile(datafile, n)
            datafile.close()
            return counters
开发者ID:antoine1fr,项目名称:pygirl,代码行数:32,代码来源:driver.py


示例17: test_64_32_results

    def test_64_32_results(self):
        if platform.machine() != "i386":
            py.test.skip("i386 only")
        plat32 = Darwin_i386()
        plat64 = Darwin_x86_64()
        cfile = udir.join("test_int_size.c")
        cfile.write(
            r"""
        #include <stdio.h>
        #include <limits.h>

        int main() {
                printf("%d\n", INT_MAX < LONG_MAX);
                return 0;
        }
        """
        )
        eci = ExternalCompilationInfo()
        executable = plat32.compile([cfile], eci)
        res = plat32.execute(executable)
        self.check_res(res, "0\n")
        if host_factory == Darwin_x86_64:
            executable = plat64.compile([cfile], eci)
            res = plat64.execute(executable)
            self.check_res(res, "1\n")
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:25,代码来源:test_darwin.py


示例18: test_frameworks

    def test_frameworks(self):
        objcfile = udir.join("test_simple.m")
        objcfile.write(
            r"""
        #import <Foundation/Foundation.h>
        #include "test.h"

        int main (int argc, const char * argv[]) {
            NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
            NSArray *args = [[NSProcessInfo processInfo] arguments];
            NSCountedSet *cset = [[NSCountedSet alloc] initWithArray:args];

            printf("%d\n", XXX_STUFF);

            [cset release];
            [pool release];
            return 0;
        }
        """
        )
        includedir = py.path.local(__file__).dirpath().join("include")
        eci = ExternalCompilationInfo(frameworks=("Cocoa",), include_dirs=(includedir,))
        executable = self.platform.compile([objcfile], eci)
        res = self.platform.execute(executable)
        self.check_res(res)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:25,代码来源:test_darwin.py


示例19: test_counters

    def test_counters(self):
        from pypy.rpython.lltypesystem import lltype
        from pypy.rpython.lltypesystem.lloperation import llop
        def entry_point(argv):
            llop.instrument_count(lltype.Void, 'test', 2)
            llop.instrument_count(lltype.Void, 'test', 1)
            llop.instrument_count(lltype.Void, 'test', 1)
            llop.instrument_count(lltype.Void, 'test', 2)
            llop.instrument_count(lltype.Void, 'test', 1)        
            return 0
        t = TranslationContext(self.config)
        t.config.translation.instrument = True
        t.buildannotator().build_types(entry_point, [s_list_of_strings])
        t.buildrtyper().specialize()

        cbuilder = CStandaloneBuilder(t, entry_point, config=t.config) # xxx
        cbuilder.generate_source()
        cbuilder.compile()

        counters_fname = udir.join("_counters_")
        os.putenv('_INSTRUMENT_COUNTERS', str(counters_fname))
        try:
            data = cbuilder.cmdexec()
        finally:
            os.unsetenv('_INSTRUMENT_COUNTERS')

        f = counters_fname.open('rb')
        counters_data = f.read()
        f.close()

        import struct
        counters = struct.unpack("LLL", counters_data)

        assert counters == (0,3,2)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:34,代码来源:test_standalone.py


示例20: safe_filename

 def safe_filename(self):
     name = self.safe_name(self.listnames())
     num = 0
     while udir.join(name + '.py').check():
         num += 1
         name = self.safe_name(self.listnames()) + "_" + str(num)
     return name + '.py'
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:conftest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python all.backend_optimizations函数代码示例发布时间:2022-05-27
下一篇:
Python udir.ensure函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap