python类_get_candidate_names()的实例源码

test_tempfile.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_retval(self):
        # _get_candidate_names returns a _RandomNameSequence object
        obj = tempfile._get_candidate_names()
        self.assertIsInstance(obj, tempfile._RandomNameSequence)
test_tempfile.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_same_thing(self):
        # _get_candidate_names always returns the same object
        a = tempfile._get_candidate_names()
        b = tempfile._get_candidate_names()

        self.assertTrue(a is b)
test_tempfile.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _mock_candidate_names(*names):
    return support.swap_attr(tempfile,
                             '_get_candidate_names',
                             lambda: iter(names))
test_tempfile.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_retval(self):
        # _get_candidate_names returns a _RandomNameSequence object
        obj = tempfile._get_candidate_names()
        self.assertIsInstance(obj, tempfile._RandomNameSequence)
test_tempfile.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_same_thing(self):
        # _get_candidate_names always returns the same object
        a = tempfile._get_candidate_names()
        b = tempfile._get_candidate_names()

        self.assertTrue(a is b)
test_tempfile.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _mock_candidate_names(*names):
    return support.swap_attr(tempfile,
                             '_get_candidate_names',
                             lambda: iter(names))
test_tempfile.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_retval(self):
        # _get_candidate_names returns a _RandomNameSequence object
        obj = tempfile._get_candidate_names()
        self.assertIsInstance(obj, tempfile._RandomNameSequence)
test_tempfile.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def test_same_thing(self):
        # _get_candidate_names always returns the same object
        a = tempfile._get_candidate_names()
        b = tempfile._get_candidate_names()

        self.assertTrue(a is b)
helpers.py 文件源码 项目:pyvips 作者: jcupitt 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def temp_filename(directory, suffix):
    temp_name = next(tempfile._get_candidate_names())
    filename = os.path.join(directory, temp_name + suffix)

    return filename


# run a 2-ary function on two things -- loop over elements pairwise if the
# things are lists
mixins.py 文件源码 项目:eggsnspam 作者: wayfair 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def setUp(self):
        # Get a random temporary file to use for testing
        self.tmp_status_file = next(tempfile._get_candidate_names())
        self.app.config['HEALTHCHECK_STATUS_FILE'] = self.tmp_status_file
        super(HealthViewTestCaseMixin, self).setUp()
test_tempfile.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_retval(self):
        # _get_candidate_names returns a _RandomNameSequence object
        obj = tempfile._get_candidate_names()
        self.assertIsInstance(obj, tempfile._RandomNameSequence)
test_tempfile.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_same_thing(self):
        # _get_candidate_names always returns the same object
        a = tempfile._get_candidate_names()
        b = tempfile._get_candidate_names()

        self.assertTrue(a is b)
test_tempfile.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _mock_candidate_names(*names):
    return support.swap_attr(tempfile,
                             '_get_candidate_names',
                             lambda: iter(names))
googleimg.py 文件源码 项目:tulen 作者: detorto 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_new_file_name():
#    return tempfile._get_candidate_names()
    global ci    
    while True:
        ci += 1
        ci = ci % max_file_i
        yield str(ci)
googleimg.py 文件源码 项目:tulen 作者: detorto 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_images_urls(soup):
    a =  soup.find_all("a",{"class":"gallery__item carousel__item"})
    if len(a) == 0:
        return []
    images_urls = []
    for img in a:
        h = img.get("href")
        parsed = urlparse.urlparse(h)
        image = urlparse.parse_qs(parsed.query)['img_url'][0]
        images_urls.append(image)

    return images_urls

#temp_name = next(tempfile._get_candidate_names())
googleimg.py 文件源码 项目:tulen 作者: detorto 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def getCaptchaImage(self, soup):
        i = soup.find("img", { "class" : "form__captcha" })
        url= i.get("src")

        print soup.find_all("input")
        self.last_key = soup.find("input",{"name":"key"})["value"]
        self.last_retpath = soup.find("input",{"name":"retpath"})["value"]
        fname = "./files/"+next(tempfile._get_candidate_names())+".jpg"
        download_image(url, fname)
        return fname
workspaces.py 文件源码 项目:infrared 作者: redhat-openstack 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _copy_outside_keys(self):
        """Copy key from out of the workspace into one"""
        paths_map = {}
        real_inv = os.path.join(self.path, os.readlink(self.inventory))

        for line in fileinput.input(real_inv, inplace=True):
            key_defs = re.findall(r"ansible_ssh_private_key_file=\/\S+", line)
            for key_def in key_defs:
                path = key_def.split("=")[-1]
                paths_map.setdefault(path, path)

            new_line = line.strip()
            for mapped_orig, mapped_new in paths_map.iteritems():
                if mapped_orig == mapped_new:
                    keyfilename = os.path.basename(mapped_orig)
                    rand_part = next(tempfile._get_candidate_names())
                    new_fname = "{}-{}".format(keyfilename, rand_part)

                    shutil.copy2(mapped_orig, os.path.join(
                                 self.path, new_fname))
                    paths_map[mapped_orig] = os.path.join(
                        self.path_placeholder, new_fname)
                    new_fname = paths_map[mapped_orig]
                else:
                    new_fname = mapped_new

                new_line = re.sub(mapped_orig, new_fname, new_line)

            print(new_line)
utilities.py 文件源码 项目:DeepPhoneticToolsTutorial 作者: MLSpeech 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def generate_tmp_filename(extension):
    return tempfile._get_default_tempdir() + "/" + next(tempfile._get_candidate_names()) + "." + extension
__init__.py 文件源码 项目:visdom 作者: facebookresearch 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def video(self, tensor=None, videofile=None, win=None, env=None, opts=None):
        """
        This function plays a video. It takes as input the filename of the video
        or a `LxHxWxC` tensor containing all the frames of the video. The function
        does not support any plot-specific `options`.
        """
        opts = {} if opts is None else opts
        opts['fps'] = opts.get('fps', 25)
        _assert_opts(opts)
        assert tensor is not None or videofile is not None, \
            'should specify video tensor or file'

        if tensor is not None:
            import cv2
            import tempfile
            assert tensor.ndim == 4, 'video should be in 4D tensor'
            videofile = '/tmp/%s.ogv' % next(tempfile._get_candidate_names())
            if cv2.__version__.startswith('2'):  # OpenCV 2
                fourcc = cv2.cv.CV_FOURCC(
                    chr(ord('T')),
                    chr(ord('H')),
                    chr(ord('E')),
                    chr(ord('O'))
                )
            elif cv2.__version__.startswith('3'):  # OpenCV 3
                fourcc = cv2.VideoWriter_fourcc(
                    chr(ord('T')),
                    chr(ord('H')),
                    chr(ord('E')),
                    chr(ord('O'))
                )
            writer = cv2.VideoWriter(
                videofile,
                fourcc,
                opts.get('fps'),
                (tensor.shape[1], tensor.shape[2])
            )
            assert writer.isOpened(), 'video writer could not be opened'
            for i in range(tensor.shape[0]):
                writer.write(tensor[i, :, :, :])
            writer.release()
            writer = None

        extension = videofile.split(".")[-1].lower()
        mimetypes = dict(mp4='mp4', ogv='ogg', avi='avi', webm='webm')
        mimetype = mimetypes.get(extension)
        assert mimetype is not None, 'unknown video type: %s' % extension

        bytestr = loadfile(videofile)
        videodata = """
            <video controls>
                <source type="video/%s" src="data:video/%s;base64,%s">
                Your browser does not support the video tag.
            </video>
        """ % (mimetype, mimetype, base64.b64encode(bytestr).decode('utf-8'))
        return self.text(text=videodata, win=win, env=env, opts=opts)


问题


面经


文章

微信
公众号

扫码关注公众号