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


Python string.ascii_lowercase方法代码示例

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


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

示例1: setup_passwords

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def setup_passwords():
    try:
        char_set = string.ascii_lowercase + string.ascii_uppercase + string.digits
        f = open('/etc/ppp/chap-secrets', 'w')
        pw1 = gen_random_text(12)
        pw2 = gen_random_text(12)
        f.write("username1 l2tpd {} *\n".format(pw1))
        f.write("username2 l2tpd {} *".format(pw2))
        f.close()
        f = open('/etc/ipsec.secrets', 'w')
        f.write('1.2.3.4 %any: PSK "{}"'.format(gen_random_text(16)))
        f.close()
    except:
        logger.exception("Exception creating passwords:")
        return False

    return True 
开发者ID:sockeye44,项目名称:instavpn,代码行数:19,代码来源:util.py

示例2: v2a_sym

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def v2a_sym(a, labels, shapes, ixs):
    """
    Decompresses the antisymmetric array.
    Args:
        a (numpy.ndarray): array to decompress;
        labels (iterable): array's axes' labels;
        shapes (iterable): arrays' shapes;
        ixs (iterable): indexes of lower-triangle parts;

    Returns:
        Decompressed amplitude tensors.
    """
    result = []
    pos = 0
    for lbls, shape, ix in zip(labels, shapes, ixs):
        ampl = numpy.zeros(shape, dtype=a.dtype)
        end = pos + len(ix[0])
        ampl[ix] = a[pos:end]
        pos = end
        for l in set(lbls):
            letters = iter(string.ascii_lowercase)
            str_spec = ''.join(next(letters) if i == l else '.' for i in lbls)
            ampl = p(str_spec, ampl)
        result.append(ampl)
    return result 
开发者ID:pyscf,项目名称:pyscf,代码行数:27,代码来源:pyscf_helpers.py

示例3: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def __init__(self, gateway, config, connector_type):
        super().__init__()    # Initialize parents classes
        self.statistics = {'MessagesReceived': 0,
                           'MessagesSent': 0}    # Dictionary, will save information about count received and sent messages.
        self.__config = config    # Save configuration from the configuration file.
        self.__gateway = gateway    # Save gateway object, we will use some gateway methods for adding devices and saving data from them.
        self.setName(self.__config.get("name",
                                       "Custom %s connector " % self.get_name() + ''.join(choice(ascii_lowercase) for _ in range(5))))    # get from the configuration or create name for logs.
        log.info("Starting Custom %s connector", self.get_name())    # Send message to logger
        self.daemon = True    # Set self thread as daemon
        self.stopped = True    # Service variable for check state
        self.__connected = False    # Service variable for check connection to device
        self.__devices = {}    # Dictionary with devices, will contain devices configurations, converters for devices and serial port objects
        self.__load_converters(connector_type)    # Call function to load converters and save it into devices dictionary
        self.__connect_to_devices()    # Call function for connect to devices
        log.info('Custom connector %s initialization success.', self.get_name())    # Message to logger
        log.info("Devices in configuration file found: %s ", '\n'.join(device for device in self.__devices))    # Message to logger 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:19,代码来源:custom_serial_connector.py

示例4: _test_string

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def _test_string(self, encoding="ascii"):
        str_length = randint(1, 8)
        str_value = ''.join(choice(ascii_lowercase) for _ in range(str_length))

        configs = [{
            "key": "stringVar",
            "is_ts": True,
            "type": "string",
            "start": 0,
            "length": str_length,
            "encoding": encoding
        }]

        can_data = str_value.encode(encoding)
        tb_data = self.converter.convert(configs, can_data)
        self.assertEqual(tb_data["telemetry"]["stringVar"], str_value) 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:18,代码来源:test_bytes_can_uplink_converter.py

示例5: test_string_attribute_and_custom_device_type

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def test_string_attribute_and_custom_device_type(self):
        self._create_connector("ts_and_attr.json")
        device_name = self.config["devices"][0]["name"]
        config = self.config["devices"][0]["attributes"][0]
        value_matches = re.search(self.connector.VALUE_REGEX, config["value"])

        string_value = ''.join(choice(ascii_lowercase) for _ in range(int(value_matches.group(2))))
        can_data = list(config["command"]["value"].to_bytes(config["command"]["length"],
                                                            config["command"]["byteorder"]))
        can_data.extend(string_value.encode(value_matches.group(5)))

        message_count = 5
        for _ in range(message_count):
            self.bus.send(Message(arbitration_id=config["nodeId"],
                                  is_fd=config["isFd"],
                                  data=can_data))

        sleep(1)  # Wait while connector process CAN message

        self.assertEqual(self.gateway.send_to_storage.call_count, message_count)
        self.gateway.send_to_storage.assert_called_with(self.connector.get_name(),
                                                        {"deviceName": device_name,
                                                         "deviceType": self.config["devices"][0]["type"],
                                                         "attributes": [{"serialNumber": string_value}],
                                                         "telemetry": []}) 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:27,代码来源:test_can_connector.py

示例6: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def __init__(self, gateway, config, connector_type):
        super().__init__()
        self.__log = log
        self._default_converters = {
            "uplink": "JsonRESTUplinkConverter",
            "downlink": "JsonRESTDownlinkConverter"
        }
        self.__config = config
        self._connector_type = connector_type
        self.statistics = {'MessagesReceived': 0,
                           'MessagesSent': 0}
        self.__gateway = gateway
        self.__USER_DATA = {}
        self.setName(config.get("name", 'REST Connector ' + ''.join(choice(ascii_lowercase) for _ in range(5))))

        self._connected = False
        self.__stopped = False
        self.daemon = True
        self._app = Flask(self.get_name())
        self._api = Api(self._app)
        self.__rpc_requests = []
        self.__attribute_updates = []
        self.__fill_requests_from_TB()
        self.endpoints = self.load_endpoints()
        self.load_handlers() 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:27,代码来源:rest_connector.py

示例7: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def __init__(self, gateway, config, connector_type):
        self.statistics = {'MessagesReceived': 0,
                           'MessagesSent': 0}
        super().__init__()
        self.__gateway = gateway
        self._connector_type = connector_type
        self.__master = None
        self.__config = config.get("server")
        self.__byte_order = self.__config.get("byteOrder")
        self.__configure_master()
        self.__devices = {}
        self.setName(self.__config.get("name",
                                       'Modbus Default ' + ''.join(choice(ascii_lowercase) for _ in range(5))))
        self.__load_converters()
        self.__connected = False
        self.__stopped = False
        self.daemon = True 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:19,代码来源:modbus_connector.py

示例8: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def __init__(self, gateway, config, connector_type):
        self.__connector_type = connector_type
        self.statistics = {'MessagesReceived': 0,
                           'MessagesSent': 0}
        super().__init__()
        self.__config = config
        self.setName(config.get('name', 'BACnet ' + ''.join(choice(ascii_lowercase) for _ in range(5))))
        self.__devices = []
        self.__device_indexes = {}
        self.__devices_address_name = {}
        self.__gateway = gateway
        self._application = TBBACnetApplication(self, self.__config)
        self.__bacnet_core_thread = Thread(target=run, name="BACnet core thread")
        self.__bacnet_core_thread.start()
        self.__stopped = False
        self.__config_devices = self.__config["devices"]
        self.default_converters = {"uplink_converter": TBUtility.check_and_import(self.__connector_type, "BACnetUplinkConverter"),
                                     "downlink_converter": TBUtility.check_and_import(self.__connector_type, "BACnetDownlinkConverter")}
        self.__request_functions = {"writeProperty": self._application.do_write_property,
                                    "readProperty": self._application.do_read_property}
        self.__available_object_resources = {}
        self.rpc_requests_in_progress = {}
        self.__connected = False
        self.daemon = True 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:26,代码来源:bacnet_connector.py

示例9: __init__

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def __init__(self, gateway, config, connector_type):
        super().__init__()
        self.__connector_type = connector_type
        self.__default_services = list(range(0x1800, 0x183A))
        self.statistics = {'MessagesReceived': 0,
                           'MessagesSent': 0}
        self.__gateway = gateway
        self.__config = config
        self.setName(self.__config.get("name",
                                       'BLE Connector ' + ''.join(choice(ascii_lowercase) for _ in range(5))))

        self._connected = False
        self.__stopped = False
        self.__previous_scan_time = time.time() - 10000
        self.__previous_read_time = time.time() - 10000
        self.__check_interval_seconds = self.__config['checkIntervalSeconds'] if self.__config.get(
            'checkIntervalSeconds') is not None else 10
        self.__rescan_time = self.__config['rescanIntervalSeconds'] if self.__config.get(
            'rescanIntervalSeconds') is not None else 10
        self.__scanner = Scanner().withDelegate(ScanDelegate(self))
        self.__devices_around = {}
        self.__available_converters = []
        self.__notify_delegators = {}
        self.__fill_interest_devices()
        self.daemon = True 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:27,代码来源:ble_connector.py

示例10: create_fake_students

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def create_fake_students():
    """
    Make a bunch of fake students so we can add them to classes later.
    """
    global all_students
    for lett in string.ascii_lowercase:
        for i in range(11):
            if i==10:
                userid = "0%sgrad" % (lett*3)
                fname = randname(8)
                lname = "Grad"
            else:
                userid = "0%s%i" % (lett*3, i)
                fname = randname(8)
                lname = "Student"
            p = Person(emplid=fake_emplid(), userid=userid, last_name=lname, first_name=fname, middle_name="", pref_first_name=fname[:4])
            p.save()
            all_students[userid] = p 
开发者ID:sfu-fas,项目名称:coursys,代码行数:20,代码来源:demodata_importer.py

示例11: generate_password

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def generate_password(length=16):
    while True:
        password = [random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(length)]
        password.insert(8, "-")
        if not any(c in string.ascii_uppercase for c in password):
            continue
        if not any(c in string.ascii_lowercase for c in password):
            continue
        if not any(c in string.digits for c in password):
            continue
        return ''.join(password) 
开发者ID:kislyuk,项目名称:aegea,代码行数:13,代码来源:iam.py

示例12: random

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def random(length: int = 8, chars: str = digits + ascii_lowercase) -> Iterator[str]:
    """
    A random string.

    Not unique, but has around 1 in a million chance of collision (with the default 8
    character length). e.g. 'fubui5e6'

    Args:
        length: Length of the random string.
        chars: The characters to randomly choose from.
    """
    while True:
        yield "".join([choice(chars) for _ in range(length)]) 
开发者ID:bcb,项目名称:jsonrpcclient,代码行数:15,代码来源:id_generators.py

示例13: _build_random_vocabulary

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def _build_random_vocabulary(vocab_size=100):
  """Builds and returns a dict<term, id>."""
  vocab = set()
  while len(vocab) < (vocab_size - 1):
    rand_word = ''.join(
        random.choice(string.ascii_lowercase)
        for _ in range(random.randint(1, 10)))
    vocab.add(rand_word)

  vocab_ids = dict([(word, i) for i, word in enumerate(vocab)])
  vocab_ids[data.EOS_TOKEN] = vocab_size - 1
  return vocab_ids 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:graphs_test.py

示例14: random_str

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def random_str(n):
    return ''.join(random.choice(string.ascii_lowercase) for _ in range(n)) 
开发者ID:ptrus,项目名称:suffix-trees,代码行数:4,代码来源:gen_vectors.py

示例15: _random_string

# 需要导入模块: import string [as 别名]
# 或者: from string import ascii_lowercase [as 别名]
def _random_string(length):
    return ''.join(
        random.choice(string.ascii_lowercase + string.digits)
        for _ in range(length)
    ) 
开发者ID:winkidney,项目名称:PickTrue,代码行数:7,代码来源:huaban.py


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