python类template()的实例源码

test_tempfile.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def test_exports(self):
        # There are no surprising symbols in the tempfile module
        dict = tempfile.__dict__

        expected = {
            "NamedTemporaryFile" : 1,
            "TemporaryFile" : 1,
            "mkstemp" : 1,
            "mkdtemp" : 1,
            "mktemp" : 1,
            "TMP_MAX" : 1,
            "gettempprefix" : 1,
            "gettempdir" : 1,
            "tempdir" : 1,
            "template" : 1,
            "SpooledTemporaryFile" : 1
        }

        unexp = []
        for key in dict:
            if key[0] != '_' and key not in expected:
                unexp.append(key)
        self.assertTrue(len(unexp) == 0,
                        "unexpected keys: %s" % unexp)
test_tempfile.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def test_exports(self):
        # There are no surprising symbols in the tempfile module
        dict = tempfile.__dict__

        expected = {
            "NamedTemporaryFile" : 1,
            "TemporaryFile" : 1,
            "mkstemp" : 1,
            "mkdtemp" : 1,
            "mktemp" : 1,
            "TMP_MAX" : 1,
            "gettempprefix" : 1,
            "gettempdir" : 1,
            "tempdir" : 1,
            "template" : 1,
            "SpooledTemporaryFile" : 1
        }

        unexp = []
        for key in dict:
            if key[0] != '_' and key not in expected:
                unexp.append(key)
        self.assertTrue(len(unexp) == 0,
                        "unexpected keys: %s" % unexp)
test_tempfile.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_exports(self):
        # There are no surprising symbols in the tempfile module
        dict = tempfile.__dict__

        expected = {
            "NamedTemporaryFile" : 1,
            "TemporaryFile" : 1,
            "mkstemp" : 1,
            "mkdtemp" : 1,
            "mktemp" : 1,
            "TMP_MAX" : 1,
            "gettempprefix" : 1,
            "gettempdir" : 1,
            "tempdir" : 1,
            "template" : 1,
            "SpooledTemporaryFile" : 1,
            "TemporaryDirectory" : 1,
        }

        unexp = []
        for key in dict:
            if key[0] != '_' and key not in expected:
                unexp.append(key)
        self.assertTrue(len(unexp) == 0,
                        "unexpected keys: %s" % unexp)
test_tempfile.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def test_exports(self):
        # There are no surprising symbols in the tempfile module
        dict = tempfile.__dict__

        expected = {
            "NamedTemporaryFile" : 1,
            "TemporaryFile" : 1,
            "mkstemp" : 1,
            "mkdtemp" : 1,
            "mktemp" : 1,
            "TMP_MAX" : 1,
            "gettempprefix" : 1,
            "gettempdir" : 1,
            "tempdir" : 1,
            "template" : 1,
            "SpooledTemporaryFile" : 1
        }

        unexp = []
        for key in dict:
            if key[0] != '_' and key not in expected:
                unexp.append(key)
        self.assertTrue(len(unexp) == 0,
                        "unexpected keys: %s" % unexp)
test_tempfile.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_exports(self):
        # There are no surprising symbols in the tempfile module
        dict = tempfile.__dict__

        expected = {
            "NamedTemporaryFile" : 1,
            "TemporaryFile" : 1,
            "mkstemp" : 1,
            "mkdtemp" : 1,
            "mktemp" : 1,
            "TMP_MAX" : 1,
            "gettempprefix" : 1,
            "gettempdir" : 1,
            "tempdir" : 1,
            "template" : 1,
            "SpooledTemporaryFile" : 1,
            "TemporaryDirectory" : 1,
        }

        unexp = []
        for key in dict:
            if key[0] != '_' and key not in expected:
                unexp.append(key)
        self.assertTrue(len(unexp) == 0,
                        "unexpected keys: %s" % unexp)
test_tempfile.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def test_exports(self):
        # There are no surprising symbols in the tempfile module
        dict = tempfile.__dict__

        expected = {
            "NamedTemporaryFile" : 1,
            "TemporaryFile" : 1,
            "mkstemp" : 1,
            "mkdtemp" : 1,
            "mktemp" : 1,
            "TMP_MAX" : 1,
            "gettempprefix" : 1,
            "gettempdir" : 1,
            "tempdir" : 1,
            "template" : 1,
            "SpooledTemporaryFile" : 1,
            "TemporaryDirectory" : 1,
        }

        unexp = []
        for key in dict:
            if key[0] != '_' and key not in expected:
                unexp.append(key)
        self.assertTrue(len(unexp) == 0,
                        "unexpected keys: %s" % unexp)
tmpdirs.py 文件源码 项目:auditwheel 作者: pypa 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
        self.name = mkdtemp(suffix, prefix, dir)
        self._closed = False
tempdir.py 文件源码 项目:leetcode 作者: thomasyimgit 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
            self.name = mkdtemp(suffix, prefix, dir)
            self._closed = False
test_tempfile.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def make_temp(self):
        return tempfile._mkstemp_inner(tempfile.gettempdir(),
                                       tempfile.template,
                                       '',
                                       tempfile._bin_openflags)
test_tempfile.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def make_temp(self):
        return tempfile._mkstemp_inner(tempfile.gettempdir(),
                                       tempfile.template,
                                       '',
                                       tempfile._bin_openflags)
test_tempfile.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def default_mkstemp_inner(self):
        return tempfile._mkstemp_inner(tempfile.gettempdir(),
                                       tempfile.template,
                                       '',
                                       tempfile._bin_openflags)
scons-time.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def make_temp_file(**kw):
    try:
        result = tempfile.mktemp(**kw)
        result = os.path.realpath(result)
    except TypeError:
        try:
            save_template = tempfile.template
            prefix = kw['prefix']
            del kw['prefix']
            tempfile.template = prefix
            result = tempfile.mktemp(**kw)
        finally:
            tempfile.template = save_template
    return result
tempdir.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
            self.name = mkdtemp(suffix, prefix, dir)
            self._closed = False
tempdir.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
            self.name = mkdtemp(suffix, prefix, dir)
            self._closed = False
__init__.py 文件源码 项目:SuperOcto 作者: mcecchi 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def temppath(prefix=None, suffix=""):
    import tempfile

    temp = tempfile.NamedTemporaryFile(prefix=prefix if prefix is not None else tempfile.template,
                                       suffix=suffix,
                                       delete=False)
    try:
        temp.close()
        yield temp.name
    finally:
        os.remove(temp.name)
context_managers.py 文件源码 项目:DjangoCMS 作者: farhan711 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
        self.name = mkdtemp(suffix, prefix, dir)
test_tempfile.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def default_mkstemp_inner(self):
        return tempfile._mkstemp_inner(tempfile.gettempdir(),
                                       tempfile.template,
                                       '',
                                       tempfile._bin_openflags)
test_tempfile.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def make_temp(self):
        return tempfile._mkstemp_inner(tempfile.gettempdir(),
                                       tempfile.template,
                                       '',
                                       tempfile._bin_openflags)
__init__.py 文件源码 项目:sdk-samples 作者: cradlepoint 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def remove_test_files():
    """Remove files and directores created during tests."""
    for name in os.listdir(u('.')):
        if name.startswith(tempfile.template):
            if os.path.isdir(name):
                shutil.rmtree(name)
            else:
                safe_remove(name)
__init__.py 文件源码 项目:sdk-samples 作者: cradlepoint 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_server_handler():
    """Return the first FTPHandler instance running in the IOLoop."""
    ioloop = IOLoop.instance()
    for fd in ioloop.socket_map:
        instance = ioloop.socket_map[fd]
        if isinstance(instance, FTPHandler):
            return instance
    raise RuntimeError("can't find any FTPHandler instance")


# commented out as per bug http://bugs.python.org/issue10354
# tempfile.template = 'tmp-pyftpdlib'
test_tempfile.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def default_mkstemp_inner(self):
        return tempfile._mkstemp_inner(tempfile.gettempdir(),
                                       tempfile.template,
                                       '',
                                       tempfile._bin_openflags)
TestCmd.py 文件源码 项目:gyp 作者: electron 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def tempdir(self, path=None):
        """Creates a temporary directory.
        A unique directory name is generated if no path name is specified.
        The directory is created, and will be removed when the TestCmd
        object is destroyed.
        """
        if path is None:
            try:
                path = tempfile.mktemp(prefix=tempfile.template)
            except TypeError:
                path = tempfile.mktemp()
        os.mkdir(path)

        # Symlinks in the path will report things
        # differently from os.getcwd(), so chdir there
        # and back to fetch the canonical path.
        cwd = os.getcwd()
        try:
            os.chdir(path)
            path = os.getcwd()
        finally:
            os.chdir(cwd)

        # Uppercase the drive letter since the case of drive
        # letters is pretty much random on win32:
        drive,rest = os.path.splitdrive(path)
        if drive:
            path = string.upper(drive) + rest

        #
        self._dirlist.append(path)
        global _Cleanup
        try:
            _Cleanup.index(self)
        except ValueError:
            _Cleanup.append(self)

        return path
tempdir.py 文件源码 项目:blender 作者: gastrodia 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
            self.name = mkdtemp(suffix, prefix, dir)
            self._closed = False
tempdir.py 文件源码 项目:blender 作者: gastrodia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
            self.name = mkdtemp(suffix, prefix, dir)
            self._closed = False
cqlsh_copy_tests.py 文件源码 项目:cassandra-dtest 作者: apache 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_temp_file(self, prefix=template, suffix=""):
        """
        On windows we cannot open temporary files after creating them unless we close them first.
        For this reason we must also create them with delete=False (or they would be deleted immediately when closed)
        and we want to make sure that the test object owns a reference to the file objects by adding them
        to self._tempfiles, so that they can be deleted when the test finishes.
        """
        ret = NamedTemporaryFile(delete=False, prefix=prefix, suffix=suffix)
        self._tempfiles.append(ret)
        if is_win():
            ret.close()
        return ret
__init__.py 文件源码 项目:processtap 作者: firodj 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def create_temp_file_name(suffix, prefix=None, dir=None):
    """small convinience function that creates temporal file.

    This function is a wrapper aroung Python built-in function - tempfile.mkstemp
    """
    if not prefix:
        prefix = tempfile.template
    fd, name = tempfile.mkstemp( suffix=suffix, prefix=prefix, dir=dir )
    file_obj = os.fdopen( fd )
    file_obj.close()
    return name
tempdir.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __init__(self, suffix="", prefix=template, dir=None):
            self.name = mkdtemp(suffix, prefix, dir)
            self._closed = False


问题


面经


文章

微信
公众号

扫码关注公众号