Generate and return a UUID.

        If the name parameter is provided, set the namespace to the provided
        name and generate a UUID.
14698
def uuid(self, name=None, pad_length=22):
        
        # If no name is given, generate a random 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)
1240631
def getbyuuid(self, uuid):
        
        if uuid not in self._schbyuuid:
            raise KeyError('uuid {0} not registered'.format(uuid))

        return self._schbyuuid[uuid]
766735
def generate_user(self):
    '''
    '''
    token = str(uuid.uuid4())
    return self.generate_subid(token=token, return_user=True)
343945
def generate(self, name: str, **kwargs):
        
        path = self.urlmapper.generate(name, **kwargs)
        return self.make_full_qualified_url(path)
541660
protected function createUuid($version, $namespace = null, $name = null)
    {
        switch ((int) $version) {
            case 1:
                $uuid = Uuid::uuid1();
                break;
            case 4:
                $uuid = Uuid::uuid4();
                break;
            case 3:
            case 5:
                $ns = $this->validateNamespace($namespace);
                if (empty($name)) {
                    throw new Exception('The name argument is required for version 3 or 5 UUIDs');
                }
                if ($version == 3) {
                    $uuid = Uuid::uuid3($ns, $name);
                } else {
                    $uuid = Uuid::uuid5($ns, $name);
                }
                break;
            default:
                throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
        }

        return $uuid;
    }
706238
def gen_unique_id():
    
    # Workaround for http://bugs.python.org/issue4607
    if ctypes and _uuid_generate_random:
        buffer = ctypes.create_string_buffer(16)
        _uuid_generate_random(buffer)
        return str(UUID(bytes=buffer.raw))
    return str(uuid4())
277531
def generate(self, vars=None, env=None):
        """"""
        def defined(v, default=None):
            _v = default
            if v in vars:
                _v = vars[v]
            elif v in env:
                _v = env[v]
            return _v

        namespace = {
            # __name__ and __loader__ allow the traceback mechanism to find
            # the generated source code.
            "defined": defined,
            #fix RuntimeWarning: Parent module 'a/b/c' not found while handling absolute import warning
            "__name__": self.name.replace('.', '_'),
            # "__name__": self.name,
            "__loader__": ObjectDict(get_source=lambda name: self.code),
        }
        namespace.update(default_namespace)
        namespace.update(env or {})
        namespace.update(self.namespace)
        namespace.update(vars or {})
        namespace['_vars'] = vars
        exec_in(self.compiled, namespace)
        execute = namespace["_tt_execute"]
        # Clear the traceback module's cache of source data now that
        # we've generated a new template (mainly for this module's
        # unittests, where different tests reuse the same name).
        linecache.clearcache()
        return execute()
240463
def id(cls):
        
        if cls.__uuid_primary_key__:
            return immutable(Column(UUIDType(binary=False), default=uuid_.uuid4, primary_key=True, nullable=False))
        else:
            return immutable(Column(Integer, primary_key=True, nullable=False))
237108
def generate_uuid(basedata=None):
    
    if basedata is None:
        return str(uuid.uuid4())
    elif isinstance(basedata, str):
        checksum = hashlib.md5(basedata).hexdigest()
        return '%8s-%4s-%4s-%4s-%12s' % (
            checksum[0:8], checksum[8:12], checksum[12:16], checksum[16:20], checksum[20:32])
753039
public function generateUuid()
    {
        $serialized = serialize($this->envInformations);
        $this->uuid = dechex($this->getDate()->format('Ymd')) . substr(sha1(implode([
            microtime(),
            $serialized,
            $this->configPath,
        ])), 0, -7);
    }
307067
def generate_uuid():
    """"""
    r_uuid = base64.urlsafe_b64encode(uuid.uuid4().bytes)
    return r_uuid.decode().replace('=', '')
682282
def generate_url(self, name: str, **kwargs) -> str:
        
        return self.urlmapper.generate(name, **kwargs)
70990
def set_uuid(obj, uuid=None):
    
    from uuid import uuid4, UUID
    if uuid is None:
        uuid = uuid4()
    elif isinstance(uuid, bytes):
        if len(uuid) == 16:
            uuid = UUID(bytes=uuid)
        else:
            uuid = UUID(hex=uuid)

    if "uuid" in obj.attrs:
        del obj.attrs["uuid"]
    obj.attrs.create("uuid", str(uuid).encode('ascii'), dtype="|S36")
655003
protected function generateUUID()
        {
        $uuid = null;
        if ($this->useUUIDs) {
            $sql    = 'SELECT UUID() as id';
            $result = $this->database->fetchAssoc($sql);
            $uuid   = $result['id'];
        }
        return $uuid;
    }
1224442
def generate_name(self, name=None):
        '''
        '''
        # If no name provided, use robot name
        if name == None:
            name = self.RobotNamer.generate()
        self.name = name.replace('-','_')
959819
def uuid(self):
        '''
        '''
        pk = self.pkvalue()
        if not pk:
            raise self.DoesNotExist(
                'Object not saved. Cannot obtain universally unique id')
        return self.get_uuid(pk)
654285
public function generateUUID()
    {
        $namespace = $this->urlInterface->getBaseUrl();

        $pid = getmypid();
        $time = ( string )microtime(true);
        $rand = ( string )mt_rand(1000000, 9999999);

        // calculate hash value
        $hash = sha1($namespace . '|' . $pid . '|' . $time . '|' . $rand);

        return $hash;
    }