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


Python string.ascii_letters方法代码示例

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


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

示例1: scp

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def scp(args):
    """
    Transfer files to or from EC2 instance.
    """
    scp_opts, host_opts = extract_passthrough_opts(args, "scp"), []
    user_or_hostname_chars = string.ascii_letters + string.digits
    ssm_init_complete = False
    for i, arg in enumerate(args.scp_args):
        if arg[0] in user_or_hostname_chars and ":" in arg:
            hostname, colon, path = arg.partition(":")
            username, at, hostname = hostname.rpartition("@")
            if args.use_ssm and not ssm_init_complete:
                scp_opts += init_ssm(get_instance(hostname).id)
                ssm_init_complete = True
            host_opts, hostname = prepare_ssh_host_opts(username=username, hostname=hostname,
                                                        bless_config_filename=args.bless_config,
                                                        use_kms_auth=args.use_kms_auth, use_ssm=args.use_ssm)
            args.scp_args[i] = hostname + colon + path
    os.execvp("scp", ["scp"] + scp_opts + host_opts + args.scp_args) 
开发者ID:kislyuk,项目名称:aegea,代码行数:21,代码来源:ssh.py

示例2: copy_dependencies

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def copy_dependencies(f):
    config_path = '/etc/yangcatalog/yangcatalog.conf'
    config = ConfigParser.ConfigParser()
    config._interpolation = ConfigParser.ExtendedInterpolation()
    config.read(config_path)
    yang_models = config.get('Directory-Section', 'save-file-dir')
    tmp = config.get('Directory-Section', 'temp')
    out = f.getvalue()
    letters = string.ascii_letters
    suffix = ''.join(random.choice(letters) for i in range(8))
    dep_dir = '{}/yangvalidator-dependencies-{}'.format(tmp, suffix)
    os.mkdir(dep_dir)
    dependencies = out.split(':')[1].strip().split(' ')
    for dep in dependencies:
        for file in glob.glob(r'{}/{}*.yang'.format(yang_models, dep)):
            shutil.copy(file, dep_dir)
    return dep_dir 
开发者ID:YangCatalog,项目名称:bottle-yang-extractor-validator,代码行数:19,代码来源:views.py

示例3: cmh_autotune

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def cmh_autotune(self, module, message, additional_data, cm):
		message = message[len(self.CONTROL_AUTOTUNE)+2:]
		# get tune type, requested record type, length and encoding for crafting the answer
		(query_type, RRtype, length, encode_class) = struct.unpack("<BHHH", message[0:7])
		if self.DNS_proto.get_RR_type(RRtype)[0] == None:
			return True
		
		# extra parameters added to be able to response in the proper way
		additional_data = additional_data + (True, self.download_encoding_list[encode_class], self.DNS_proto.get_RR_type(RRtype)[0])		
		if (query_type == 0) or (query_type == 3):
			# record && downstream length discovery
			message = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
		if query_type == 1:
			# A record name length discovery
			message = struct.pack("<i", binascii.crc32(message[7:]))
		if query_type == 2:
			# checking download encoding, echoing back request payload
			message = message[7:]

		module.send(common.CONTROL_CHANNEL_BYTE, self.CONTROL_AUTOTUNE_CLIENT+message, additional_data)
		return True

	# tune control message handler
	# client sets the record type and encodings by calling this
	# server side 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:27,代码来源:DNS.py

示例4: test_fails_url_build_if_param_not_passed

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def test_fails_url_build_if_param_not_passed(app):
    url = "/"

    for letter in string.ascii_letters:
        url += f"<{letter}>/"

    @app.route(url)
    def fail(request):
        return text("this should fail")

    fail_args = list(string.ascii_letters)
    fail_args.pop()

    fail_kwargs = {l: l for l in fail_args}

    with pytest.raises(URLBuildError) as e:
        app.url_for("fail", **fail_kwargs)

    assert "Required parameter `Z` was not passed to url_for" in str(e.value) 
开发者ID:huge-success,项目名称:sanic,代码行数:21,代码来源:test_url_building.py

示例5: gen_salt

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def gen_salt(self, set_=True):
        """
            Generate a random salt
        """

        min_char = 8
        max_char = 12
        allchar = string.ascii_letters + string.punctuation + string.digits
        salt = "".join(choice(allchar)
                       for x in range(randint(min_char, max_char))).encode()

        # Set the salt in the same instance if required
        if set_:
            self.set_salt(salt)

        return salt 
开发者ID:gabfl,项目名称:vault,代码行数:18,代码来源:Encryption.py

示例6: test_tab_completion_not_sorted

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def test_tab_completion_not_sorted(qtmodeltester, fake_web_tab, win_registry,
                                   tabbed_browser_stubs):
    """Ensure that the completion row order is the same as tab index order.

    Would be violated for more than 9 tabs if the completion was being
    alphabetically sorted on the first column, or the others.
    """
    expected = []
    for idx in range(1, 11):
        url = "".join(random.sample(string.ascii_letters, 12))
        title = "".join(random.sample(string.ascii_letters, 12))
        expected.append(("0/{}".format(idx), url, title))

    tabbed_browser_stubs[0].widget.tabs = [
        fake_web_tab(QUrl(tab[1]), tab[2], idx)
        for idx, tab in enumerate(expected)
    ]
    model = miscmodels.buffer()
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        '0': expected,
        '1': [],
    }) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:27,代码来源:test_models.py

示例7: setUp

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def setUp(self):
        warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed.*<ssl.SSLSocket.*>")
        self.dl_dir = os.path.join(tempfile.gettempdir(), "".join([random.choice(string.ascii_letters+string.digits) for i in range(8)]), '')
        while os.path.exists(self.dl_dir):
            self.dl_dir = os.path.join(tempfile.gettempdir(), "".join([random.choice(string.ascii_letters+string.digits) for i in range(8)]), '')
            
        self.res_7za920_mirrors = [
            "https://github.com/iTaybb/pySmartDL/raw/master/test/7za920.zip",
            "https://sourceforge.mirrorservice.org/s/se/sevenzip/7-Zip/9.20/7za920.zip",
            "http://www.bevc.net/dl/7za920.zip",
            "http://ftp.psu.ru/tools/7-zip/stable/7za920.zip",
            "http://www.mirrorservice.org/sites/downloads.sourceforge.net/s/se/sevenzip/7-Zip/9.20/7za920.zip"
        ]
        self.res_7za920_hash = '2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac'
        self.res_testfile_1gb = 'http://www.ovh.net/files/1Gio.dat'
        self.res_testfile_100mb = 'http://www.ovh.net/files/100Mio.dat'
        self.enable_logging = "-vvv" in sys.argv 
开发者ID:iTaybb,项目名称:pySmartDL,代码行数:19,代码来源:test_pySmartDL.py

示例8: s_cname

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def s_cname(s, t):
  CNAME0 = string.ascii_letters + "_.!:"
  CNAME1 = string.ascii_letters + string.digits + "_."

  token = ""
  if s.peek() not in CNAME0:
    return False

  token = s.get()

  try:
    while s.peek() in CNAME1:
      token += s.get()
  except StreamException:
    pass

  t.append((TokenTypes.IDENTIFIER, token))  # TODO: maybe add more info on type

  return True 
开发者ID:gynvael,项目名称:stream,代码行数:21,代码来源:casm.py

示例9: s_ctype

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def s_ctype(s, t):
  CTYPE0 = string.ascii_letters + "_.!:"
  CTYPE1 = string.ascii_letters + string.digits + "_."

  token = ""
  if s.peek() not in CTYPE0:
    return False

  token = s.get()

  try:
    while s.peek() in CTYPE1:
      token += s.get()
  except StreamException:
    pass

  t.append(token)  # TODO: maybe add more info on type

  return True 
开发者ID:gynvael,项目名称:stream,代码行数:21,代码来源:casm.py

示例10: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def __init__(
        self, k, t=None, sep=None, dotted=False
    ):  # type: (str, Optional[KeyType], Optional[str], bool) -> None
        if t is None:
            if any(
                [c not in string.ascii_letters + string.digits + "-" + "_" for c in k]
            ):
                t = KeyType.Basic
            else:
                t = KeyType.Bare

        self.t = t
        if sep is None:
            sep = " = "

        self.sep = sep
        self.key = k
        self._dotted = dotted 
开发者ID:sdispater,项目名称:tomlkit,代码行数:20,代码来源:items.py

示例11: _create_tmp_files

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def _create_tmp_files(self):
        """
        Create the temporary files needed for testing.  Use the tempfile
        package so that the files will be automatically removed during
        garbage collection.
        """
        for size_str in self.sizes:
            # Determine the size of the file to create
            size_desc = size_str.split("-")
            size = int(size_desc[0])
            if size_desc[1] == 'M':
                size *= 1000000
            elif size_desc[1] == 'K':
                size *= 1000

            # Create the dictionary of files to test with
            buf = ''.join(random.choice(ascii_letters) for i in range(size))
            if sys.version_info >= (3,):
                buf = buf.encode('ascii')
            tmp_file = tempfile.NamedTemporaryFile('w+b')
            tmp_file.write(buf)
            self.files[size_str] = tmp_file 
开发者ID:openstack,项目名称:pyeclib,代码行数:24,代码来源:test_pyeclib_c.py

示例12: _create_tmp_files

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def _create_tmp_files(self):
        """
        Create the temporary files needed for testing.  Use the tempfile
        package so that the files will be automatically removed during
        garbage collection.
        """
        for size_str in self.file_sizes:
            # Determine the size of the file to create
            size_desc = size_str.split("-")
            size = int(size_desc[0])
            if size_desc[1] == 'M':
                size *= 1000000
            elif size_desc[1] == 'K':
                size *= 1000

            # Create the dictionary of files to test with
            buf = ''.join(random.choice(ascii_letters) for i in range(size))
            if sys.version_info >= (3,):
                buf = buf.encode('ascii')
            tmp_file = tempfile.NamedTemporaryFile()
            tmp_file.write(buf)
            self.files[size_str] = tmp_file 
开发者ID:openstack,项目名称:pyeclib,代码行数:24,代码来源:test_pyeclib_api.py

示例13: test_verify_fragment_inline_chksum_succeed

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def test_verify_fragment_inline_chksum_succeed(self):
        pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32")

        filesize = 1024 * 1024 * 3
        file_str = ''.join(random.choice(ascii_letters)
                           for i in range(filesize))
        file_bytes = file_str.encode('utf-8')

        for pyeclib_driver in pyeclib_drivers:
            fragments = pyeclib_driver.encode(file_bytes)

            fragment_metadata_list = []

            for fragment in fragments:
                fragment_metadata_list.append(
                    pyeclib_driver.get_metadata(fragment))

            expected_ret_value = {"status": 0}

            self.assertTrue(pyeclib_driver.verify_stripe_metadata(
                fragment_metadata_list) == expected_ret_value) 
开发者ID:openstack,项目名称:pyeclib,代码行数:23,代码来源:test_pyeclib_api.py

示例14: getRandomStr

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def getRandomStr(types='letter', length=8):
        """ 随机产生length长度的字符串

        :param types: 随机字符串的类型
        types in ['letter', 'ascii'] 返回包含字母的字符串
        types in ['digit', 'num']: 返回包含数字的字符串
        其他:返回混合字母和数字的字符串

        :param length: 返回字符串的长度
        :return: 长度为length,类型为types的字符串

        todo string.punctuation

        """
        import random
        import string
        if types in ['letter', 'ascii']:
            return ''.join(random.sample(string.ascii_letters, length))
        if types in ['digit', 'num']:
            return ''.join(random.sample(string.digits, length))
        else:
            return ''.join(random.sample(string.ascii_letters + string.digits, length)) 
开发者ID:pchaos,项目名称:wanggeService,代码行数:24,代码来源:base.py

示例15: test_plot_scatter

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_letters [as 别名]
def test_plot_scatter(self):
        df = DataFrame(randn(6, 4),
                       index=list(string.ascii_letters[:6]),
                       columns=['x', 'y', 'z', 'four'])

        _check_plot_works(df.plot.scatter, x='x', y='y')
        _check_plot_works(df.plot.scatter, x=1, y=2)

        with pytest.raises(TypeError):
            df.plot.scatter(x='x')
        with pytest.raises(TypeError):
            df.plot.scatter(y='y')

        # GH 6951
        axes = df.plot(x='x', y='y', kind='scatter', subplots=True)
        self._check_axes_shape(axes, axes_num=1, layout=(1, 1)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_frame.py


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