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

Python uuid.uuid5函数代码示例

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

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



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

示例1: generate

	def generate(self, plist_path):
		"""
		Generates a boilerplate Safari Bookmarks plist at plist path.

		Raises:
			CalledProcessError if creation of plist fails.

		"""
		subprocess.check_call(["touch", plist_path])
		contents = dict(
			Children=list((
				dict(
					Title="History",
					WebBookmarkIdentifier="History",
					WebBookmarkType="WebBookmarkTypeProxy",
					WebBookmarkUUID=str(uuid.uuid5(uuid.NAMESPACE_DNS, "History")),
				),
				dict(
					Children=list(),
					Title="BookmarksBar",
					WebBookmarkType="WebBookmarkTypeList",
					WebBookmarkUUID=str(uuid.uuid5(uuid.NAMESPACE_DNS, "BookmarksBar")),
				),
				dict(
					Title="BookmarksMenu",
					WebBookmarkType="WebBookmarkTypeList",
					WebBookmarkUUID=str(uuid.uuid5(uuid.NAMESPACE_DNS, "BookmarksMenu")),
				),
			)),
			Title="",
			WebBookmarkFileVersion=1,
			WebBookmarkType="WebBookmarkTypeList",
			WebBookmarkUUID=str(uuid.uuid5(uuid.NAMESPACE_DNS, "")),
		)
		plistlib.writePlist(contents, plist_path)
开发者ID:robperc,项目名称:SafariBookmarkEditor,代码行数:35,代码来源:SafariBookmarkEditor.py


示例2: test_resource_uuid

    def test_resource_uuid(self):
        uuid_str = '536e28c2017e405e89b25a1ed777b952'
        self.assertEqual(uuid_str, common_utils.resource_uuid(uuid_str))

        # Exact 64 length string.
        uuid_str = ('536e28c2017e405e89b25a1ed777b952'
                    'f13de678ac714bb1b7d1e9a007c10db5')
        resource_id_namespace = common_utils.RESOURCE_ID_NAMESPACE
        transformed_id = uuid.uuid5(resource_id_namespace, uuid_str).hex
        self.assertEqual(transformed_id, common_utils.resource_uuid(uuid_str))

        # Non-ASCII character test.
        non_ascii_ = 'ß' * 32
        transformed_id = uuid.uuid5(resource_id_namespace, non_ascii_).hex
        self.assertEqual(transformed_id,
                         common_utils.resource_uuid(non_ascii_))

        # This input is invalid because it's length is more than 64.
        invalid_input = 'x' * 65
        self.assertRaises(ValueError, common_utils.resource_uuid,
                          invalid_input)

        # 64 length unicode string, to mimic what is returned from mapping_id
        # backend.
        uuid_str = six.text_type('536e28c2017e405e89b25a1ed777b952'
                                 'f13de678ac714bb1b7d1e9a007c10db5')
        resource_id_namespace = common_utils.RESOURCE_ID_NAMESPACE
        if six.PY2:
            uuid_str = uuid_str.encode('utf-8')
        transformed_id = uuid.uuid5(resource_id_namespace, uuid_str).hex
        self.assertEqual(transformed_id, common_utils.resource_uuid(uuid_str))
开发者ID:HoratiusTang,项目名称:keystone,代码行数:31,代码来源:test_utils.py


示例3: create_channel

def create_channel(name, description="", editors=None, language="en", bookmarkers=None, viewers=None, public=False):
    domain = uuid.uuid5(uuid.NAMESPACE_DNS, name)
    node_id = uuid.uuid5(domain, name)

    channel, _new = Channel.objects.get_or_create(pk=node_id.hex)

    channel.name = name
    channel.description = description
    channel.language_id = language
    channel.public = public
    channel.deleted = False

    editors = editors or []
    bookmarkers = bookmarkers or []
    viewers = viewers or []
    for e in editors:
        channel.editors.add(e)
    for b in bookmarkers:
        channel.bookmarked_by.add(b)
    for v in viewers:
        channel.viewers.add(v)

    channel.save()
    channel.main_tree.get_descendants().delete()
    channel.staging_tree and channel.staging_tree.get_descendants().delete()
    return channel
开发者ID:fle-internal,项目名称:content-curation,代码行数:26,代码来源:setup.py


示例4: hw_connect_event

    def hw_connect_event(self, device):
        namespace = uuid.uuid5(uuid.NAMESPACE_DNS, socket.getfqdn())
        device.uuid = uuid.uuid5(namespace, device.hw_info+"."+device.driver)

        printer = None
        self.__device_lock.acquire()
        try:
            if self.printers.has_key(device.uuid):
                printer = self.printers[device.uuid]
            else:
                driver_cpath = os.path.join("hardware/drivers", device.driver, "config.json")
                with open(driver_cpath, "r") as config_file:
                    config = json.load(config_file)
                printer_cpath = os.path.join("settings", str(device.uuid) + ".json")
                with open(printer_cpath, "w") as config_file:
                    json.dump(config, config_file)
                printer = VoxelpressPrinter(device.uuid)
        except IOError:
            print "Config file could not be opened."
            print "Either:", driver_cpath, "or", printer_cpath
        except ValueError:
            print "Config file contained invalid json..."
            print "Probably", driver_capth

        if printer:
            self.devices[device.hw_path] = device
            print "New device attached:"
            print "  driver:", device.driver
            print "    hwid:", device.hw_path
            print "    uuid:", device.uuid
            printer.on_connect(device)
        self.__device_lock.release()
开发者ID:Aeva,项目名称:voxelpress,代码行数:32,代码来源:vpd.py


示例5: register

    def register(self,boy,girl):
        encodeUtil = EncodeUtil()
        boyname = boy['username']
        girlname = girl['username']
        nowtime = datetime.datetime.now()
        boy['id'] = uuid.uuid5(uuid.NAMESPACE_DNS,uuid.uuid1().get_hex()).get_hex()
        boy['lover']    = girlname
        boy['time']    = nowtime
        boy['password'] = encodeUtil.md5hash(boy['password'])
        boy['birthday'] = self.InvalidDateTime
        boy['nickname'] = boyname
        boy['sex']    = '1'

        girl['id'] = uuid.uuid5(uuid.NAMESPACE_DNS,uuid.uuid1().get_hex()).get_hex()
        girl['lover']    = boyname
        girl['time']    = nowtime
        girl['password'] = encodeUtil.md5hash(girl['password'])
        girl['birthday'] = self.InvalidDateTime
        girl['nickname'] = girlname
        girl['sex']    = '2'

        if self.is_user_exist(boyname):
            return -1
        if self.is_user_exist(girlname):
            return -2
        self.uda.insert_user_info(boy)
        self.uda.insert_user_info(girl)
        return 0
开发者ID:hizzgdev,项目名称:walpw,代码行数:28,代码来源:user.py


示例6: __init__

    def __init__(self, inputs, 
                 outputs=OP_N_TO_1, 
                 tags=None):
        """
        :param inputs: list of uuids the operator examines
        """
        self.inputs = inputs
        self.tags = tags
        self._has_pending = False
        self._pending = [null] * len(inputs)

        uuids = map(operator.itemgetter('uuid'), inputs)

        # auto-construct output ids if requested
        if outputs == OP_N_TO_1:
            self.outputs = [util.dict_all(inputs)]
            self.outputs[0]['uuid'] = reduce(lambda x, y: str(uuid.uuid5(y, x)), 
                                             map(uuid.UUID, sorted(uuids)), 
                                             self.name)
        elif outputs == OP_N_TO_N:
            self.outputs = copy.deepcopy(inputs)
            for i, uid in enumerate(map(lambda x: str(uuid.uuid5(x, self.name)),
                                        map(uuid.UUID, uuids))):
                self.outputs[i]['uuid'] = uid
        else:
            self.outputs = copy.deepcopy(outputs)
开发者ID:ahaas,项目名称:smap,代码行数:26,代码来源:operators.py


示例7: make_uuid

    def make_uuid(self, firmware_name):
        """Deterministically generatse a uuid from this connection.
        Used by firmware drivers if the firmware doesn't specify one
        through other means."""

        namespace = uuid.uuid5(uuid.NAMESPACE_DNS, socket.getfqdn())
        return uuid.uuid5(namespace, firmware_name+"@"+self.__port)
开发者ID:Aeva,项目名称:voxelpress,代码行数:7,代码来源:acm_device.py


示例8: small_uuid

def small_uuid(name=None):
    if name is None:
        uuid = _uu.uuid4()
    elif "http" not in name.lower():
        uuid = _uu.uuid5(_uu.NAMESPACE_DNS, name)
    else:
        uuid = _uu.uuid5(_uu.NAMESPACE_URL, name)
    return SmallUUID(int=uuid.int)
开发者ID:adamcharnock,项目名称:smalluuid,代码行数:8,代码来源:smalluuid.py


示例9: _set_system_uuid

 def _set_system_uuid(self):
     # start by creating the liota namespace, this is a globally unique uuid, and exactly the same for any instance of liota
     self.liotaNamespace = uuid.uuid5(uuid.NAMESPACE_URL, 'https://github.com/vmware/liota')
     log.info(str('liota namespace uuid: ' + str(self.liotaNamespace)))
     # we create a system uuid for the physical system on which this instance is running
     # we hash the interface name with the mac address in getMacAddrIfaceHash to avoid collision of
     #     mac addresses across potential different physical interfaces in the IoT space
     systemUUID.__UUID = uuid.uuid5(self.liotaNamespace, self._getMacAddrIfaceHash())
     log.info('system UUID: ' + str(systemUUID.__UUID))
开发者ID:hardik-vmware,项目名称:liota,代码行数:9,代码来源:utility.py


示例10: _set_groups

 def _set_groups(self, proj_dic):
     # each group needs to have own filter with UUID
     proj_dic['source_groups'] = {}
     proj_dic['include_groups'] = {}
     for key in SOURCE_KEYS:
         for group_name, files in proj_dic[key].items():
             proj_dic['source_groups'][group_name] = str(uuid.uuid5(uuid.NAMESPACE_URL, group_name)).upper()
     for k,v in proj_dic['include_files'].items():
         proj_dic['include_groups'][k] = str(uuid.uuid5(uuid.NAMESPACE_URL, k)).upper()
开发者ID:0xc0170,项目名称:project_generator,代码行数:9,代码来源:visual_studio.py


示例11: get_or_create_allocation_source

def get_or_create_allocation_source(api_allocation):
    try:
        source_name = "%s" % (api_allocation['project'], )
        source_id = api_allocation['id']
        compute_allowed = int(api_allocation['computeAllocated'])
    except (TypeError, KeyError, ValueError):
        raise TASAPIException(
            "Malformed API Allocation - Missing keys in dict: %s" %
            api_allocation
        )

    payload = {
        'allocation_source_name': source_name,
        'compute_allowed': compute_allowed,
        'start_date': api_allocation['start'],
        'end_date': api_allocation['end']
    }

    try:
        created_event_key = 'sn=%s,si=%s,ev=%s,dc=jetstream,dc=atmosphere' % (
            source_name, source_id, 'allocation_source_created_or_renewed'
        )
        created_event_uuid = uuid.uuid5(
            uuid.NAMESPACE_X500, str(created_event_key)
        )
        created_event = EventTable.objects.create(
            name='allocation_source_created_or_renewed',
            uuid=created_event_uuid,
            payload=payload
        )
        assert isinstance(created_event, EventTable)
    except IntegrityError:
        # This is totally fine. No really. This should fail if it already exists and we should ignore it.
        pass

    try:
        compute_event_key = 'ca=%s,sn=%s,si=%s,ev=%s,dc=jetstream,dc=atmosphere' % (
            compute_allowed, source_name, source_id,
            'allocation_source_compute_allowed_changed'
        )
        compute_event_uuid = uuid.uuid5(
            uuid.NAMESPACE_X500, str(compute_event_key)
        )
        compute_allowed_event = EventTable.objects.create(
            name='allocation_source_compute_allowed_changed',
            uuid=compute_event_uuid,
            payload=payload
        )
        assert isinstance(compute_allowed_event, EventTable)
    except IntegrityError:
        # This is totally fine. No really. This should fail if it already exists and we should ignore it.
        pass

    source = AllocationSource.objects.get(name__iexact=source_name)
    return source
开发者ID:iPlantCollaborativeOpenSource,项目名称:atmosphere,代码行数:55,代码来源:allocation.py


示例12: get_uuid

def get_uuid(s='default', bit=0):

    try:
        bit = int(bit)
    except ValueError:
        bit = 0

    if bit:
        return ''.join(random.sample(uuid.uuid5(uuid.uuid4(), s).get_hex(), bit))
    else:
        return uuid.uuid5(uuid.uuid4(), s).get_hex()
开发者ID:wndfly,项目名称:cmagic_demo,代码行数:11,代码来源:models.py


示例13: get_id

    def get_id(self, entry):
        if 'entryUUID' in entry:
            return entry['entryUUID.0']

        if 'uidNumber' in entry:
            return uuid.uuid5(LDAP_USER_UUID, entry['uidNumber.0'])

        if 'gidNumber' in entry:
            return uuid.uuid5(LDAP_GROUP_UUID, entry['gidNumber.0'])

        return uuid.uuid4()
开发者ID:650elx,项目名称:middleware,代码行数:11,代码来源:LDAPPlugin.py


示例14: generate_session_id

def generate_session_id(context):
    """ Generates a new session id. """

    membership = getToolByName(context, 'portal_membership')

    # anonymous users get random uuids
    if membership.isAnonymousUser():
        return uuid.uuid4()

    # logged in users get ids which are predictable for each plone site
    namespace = uuid.uuid5(root_namespace, str(getSite().id))
    return uuid.uuid5(namespace,
                      str(membership.getAuthenticatedMember().getId()))
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:13,代码来源:plone_session.py


示例15: uuid

 def uuid(self, name = None, pad_length = 22):
     """
     Generate and return a UUID.
     If the name parameter is provided, set the namespace to the provided
     name and generate a UUID.
     """
     if name is None:
         uuid = _uu.uuid4()
     elif 'http' not in name.lower():
         uuid = _uu.uuid5(_uu.NAMESPACE_DNS, name)
     else:
         uuid = _uu.uuid5(_uu.NAMESPACE_URL, name)
     return self.encode(uuid, pad_length)
开发者ID:mmallmann,项目名称:studiolibrary,代码行数:13,代码来源:shortuuid.py


示例16: __init__

 def __init__(self, module, name, alias, full_path=None, is_our=True):
     # from base.module import some_function as sf
     self.what = name                # e.g. some_function
     self.alias = alias              # e.g. sf
     self.who = full_path            # name of current module
     self.which_module = module      # e.g base.module
     self.is_our = is_our            # defines whether this code is from project or from 3rd party resources
     self._extra = (self.which_module + "." + self.what).lstrip('.')
     if self.who is not None:
         generated_id = uuid.uuid5(uuid.NAMESPACE_OID, self.who).get_hex()
     else:
         generated_id = uuid.uuid5(uuid.NAMESPACE_OID, self._extra).get_hex()
     self.id = generated_id
开发者ID:vwvolodya,项目名称:project,代码行数:13,代码来源:Node.py


示例17: __mapIDToBE

 def __mapIDToBE(self, xmlelem):
     """Maps a Redmine id to BE uuid"""
     if self.element.tag=="journal":
         self.__commentType=1
         self.redmine_id=int(self.element.attrib['id'])
         self.parentParser.journalids[self.redmine_id]=self
         ret=uuid.uuid5(self.uuid_namespace, str(self.redmine_id))
     elif self.element.tag=="issue":
         self.__commentType=0
         self.redmine_id=int(self.element.find("id").text)
         ret=uuid.uuid5(self.parentIssue.uuid_namespace, str(self.redmine_id))
     else:
         raise Exception("Unknown comment type '"+self.element.tag+"'")
     return ret
开发者ID:ned14,项目名称:BEXML,代码行数:14,代码来源:redmine_issues.py


示例18: test_01_update

    def test_01_update(self, side_effect):
        uuid1 = '601d3b48-a44f-40f3-aa7a-35da4a10a099'
        uuid2 = '0be7d422-1635-11e7-a83f-68f728db19d3'
        hashed_uuid1 = str(uuid.uuid5(uuid.UUID(uuid1), USER_NAME))
        hashed_uuid2 = str(uuid.uuid5(uuid.UUID(uuid2), USER_NAME))

        #We add an existin connection to trigger an Update method
        self.settings.AddConnection(
          dbus.Dictionary({
            'connection': dbus.Dictionary({
                'id': 'test connection',
                'uuid': hashed_uuid1,
                'type': '802-11-wireless'}, signature='sv'),
            '802-11-wireless': dbus.Dictionary({
                'ssid': dbus.ByteArray('The_SSID'.encode('UTF-8'))}, signature='sv')
          })
        )

        ca = NetworkManagerConfigAdapter()
        ca.bootstrap(self.TEST_UID)
        ca.update(self.TEST_UID, self.TEST_DATA)

        path1 = self.settings.GetConnectionByUuid(hashed_uuid1)
        path2 = self.settings.GetConnectionByUuid(hashed_uuid2)

        conns = self.settings.ListConnections()
        self.assertEqual(len(conns), 2)

        self.assertIn(path1, conns)
        self.assertIn(path2, conns)

        conn1 = dbus.Interface(self.dbus_con.get_object(MANAGER_IFACE, path1),
                               'org.freedesktop.NetworkManager.Settings.Connection')
        conn2 = dbus.Interface(self.dbus_con.get_object(MANAGER_IFACE, path2),
                               'org.freedesktop.NetworkManager.Settings.Connection')

        conn1_sett = conn1.GetSettings()
        conn2_sett = conn2.GetSettings()

        self.assertEqual(conn1_sett['connection']['uuid'], hashed_uuid1)
        self.assertEqual(conn2_sett['connection']['uuid'], hashed_uuid2)

        self.assertEqual(conn1_sett['connection']['permissions'], ['user:%s:' % USER_NAME,])
        self.assertEqual(conn2_sett['connection']['permissions'], ['user:%s:' % USER_NAME,])

        self.assertEqual(conn1_sett['user']['data']['org.fleet-commander.connection'], 'true')
        self.assertEqual(conn1_sett['user']['data']['org.fleet-commander.connection.uuid'], uuid1)

        self.assertEqual(conn2_sett['user']['data']['org.fleet-commander.connection'], 'true')
        self.assertEqual(conn2_sett['user']['data']['org.fleet-commander.connection.uuid'], uuid2)
开发者ID:fleet-commander,项目名称:fc-client,代码行数:50,代码来源:04_configadapter_nm.py


示例19: test_uuid5

    def test_uuid5(self):
        equal = self.assertEqual

        # Test some known version-5 UUIDs.
        for u, v in [
            (uuid.uuid5(uuid.NAMESPACE_DNS, "python.org"), "886313e1-3b8a-5372-9b90-0c9aee199e5d"),
            (uuid.uuid5(uuid.NAMESPACE_URL, "http://python.org/"), "4c565f0d-3f5a-5890-b41b-20cf47701c5e"),
            (uuid.uuid5(uuid.NAMESPACE_OID, "1.3.6.1"), "1447fa61-5277-5fef-a9b3-fbc6e44f4af3"),
            (uuid.uuid5(uuid.NAMESPACE_X500, "c=ca"), "cc957dd1-a972-5349-98cd-874190002798"),
        ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 5)
            equal(u, uuid.UUID(v))
            equal(str(u), v)
开发者ID:xxxhycl2010,项目名称:Python-2.7.8,代码行数:14,代码来源:test_uuid.py


示例20: uuid

def uuid(name=None):
    """
    Generate and return a UUID.

    If the name parameter is provided, set the namespace to the provided
    name and generate a UUID.
    """
    # If no name is given, generate a random UUID.
    if name is None:
        uuid = _uu.uuid4()
    elif not "http" in name:
        uuid = _uu.uuid5(_uu.NAMESPACE_DNS, name)
    else:
        uuid = _uu.uuid5(_uu.NAMESPACE_URL, name)
    return encode(uuid)
开发者ID:lehrblogger,项目名称:shortuuid,代码行数:15,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python uuslug.slugify函数代码示例发布时间:2022-05-26
下一篇:
Python uuid.uuid4函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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