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


Python uuid.uuid5函数代码示例

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


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


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