def model_name_analysis(model): task_type = None struct = {} lst = model.split("_") if lst[-1] in model_types: task_type = lst[-1][:5] lst.pop(-1) else: task_type = "train" if len(lst) < 4 or len(lst) > 5: return None, None struct["trid"] = lst.pop(0) struct["xxyy"] = lst.pop(0) struct["name"] = lst.pop(0) struct["nn"] = lst.pop(0) try: int(struct["nn"]) except ValueError: if len(lst) == 0: lst.append(struct["nn"]) del struct["nn"] uuid = lst.pop(0) usplit = uuid.split('-') if len(usplit) > 1: struct["uuid"] = usplit[0] struct["parent_uuid"] = usplit[-1] else: struct["uuid"] = uuid return struct, task_type
def test_generate_uuid(self): uuid = generate_uuid() self.assertEqual(len(uuid), 36) uuid_part = uuid.split('-') self.assertEqual(len(uuid_part[0]), 8) self.assertEqual(len(uuid_part[1]), 4) self.assertEqual(len(uuid_part[2]), 4) self.assertEqual(len(uuid_part[3]), 4) self.assertEqual(len(uuid_part[4]), 12)
def isUUID(uuid): split = uuid.split("-") if len(split) != 5 \ or len(split[0]) != 8 \ or len(split[1]) != 4 \ or len(split[2]) != 4 \ or len(split[3]) != 4 \ or len(split[4]) != 12 : return False return True
def isUUID(uuid): """Return boolean of whether it's string representation of a UUID v4""" split = uuid.split("-") if len(split) != 5 \ or len(split[0]) != 8 \ or len(split[1]) != 4 \ or len(split[2]) != 4 \ or len(split[3]) != 4 \ or len(split[4]) != 12 : return False return True
def isUUID(uuid): split = uuid.split("-") if ( len(split) != 5 or len(split[0]) != 8 or len(split[1]) != 4 or len(split[2]) != 4 or len(split[3]) != 4 or len(split[4]) != 12 ): return False return True
def find_uuid(uuid=None, config=None): _grep_result = {} for _uuid in uuid.split(','): for grp, servers in config.items(): i = 0 for srv in servers: if srv['uuid'] == _uuid: try: _grep_result[grp].append(servers[i]) except KeyError: _grep_result[grp] = [servers[i]] return _grep_result if len(_grep_result) > 0 else None
def get_by_uuid(uuid): if uuid: split = uuid.split(".") try: app_label = split[0] object_name = split[1] uuid = split[2] model = get_model(app_label, object_name) instance = model.objects.get(uuid=uuid) return instance except Exception, err: if settings.DEBUG: print "Error getting object by uuid %s - %s" % (traceback.format_exc(), sys.exc_info()[0])
def get_by_uuid(uuid): if uuid: split = uuid.split('.') try: app_label = split[0] object_name = split[1] uuid = split[2] model = get_model(app_label, object_name) instance = model.objects.get(uuid=uuid) return instance except Exception, err: if settings.DEBUG: print 'Error getting object by uuid %s - %s' % ( traceback.format_exc(), sys.exc_info()[0])
def get_uuid(self): """ if mysql connection is available more fast way to use this method than global function - get_uuid() return id based on uuid """ if not self._uuid_cache: self._cursor.execute('SELECT %s;' % ','.join(['uuid()' for _ in range(100)])) for uuid in self._cursor.fetchone(): u = uuid.split('-') u.reverse() u = ("%040s" % ''.join(u)).replace(' ','0') self._uuid_cache.append(u) return self._uuid_cache.pop()
def dvportgroup_name(uuid, sg_set): """ Returns a dvportgroup name for the particular security group set in the context of the switch of the given uuid """ # There is an upper limit on managed object names in vCenter dvs_id = ''.join(uuid.split(' '))[:8] name = sg_set + "-" + dvs_id if len(name) > 80: # so we use a hash of the security group set hex = hashlib.sha224() hex.update(sg_set) name = hex.hexdigest() + "-" + dvs_id return name
def get_uuid(self): """ if mysql connection is available more fast way to use this method than global function - get_uuid() return id based on uuid """ if not self._uuid_cache: cursor = self.cursor() cursor.execute('SELECT %s;' % ','.join(['uuid()' for _ in range(100)])) for uuid in cursor.fetchone(): u = uuid.split('-') u.reverse() u = ("%040s" % ''.join(u)).replace(' ', '0') self._uuid_cache.append(u) return self._uuid_cache.pop()
def get_short(self, uuid: str): """ Returns the short type for a given UUID. That means that "0000006D-0000-1000-8000-0026BB765291" and "6D" both translates to "position.current" (after looking up "public.hap.characteristic.position.current"). if item in self._characteristics: return self._characteristics[item].split('.', 3)[3] :param uuid: the UUID in long form or the shortened version as defined in chapter 5.6.1 page 72. :return: the textual representation """ orig_item = uuid if uuid.endswith(self.baseUUID): uuid = uuid.split('-', 1)[0] uuid = uuid.lstrip('0') if uuid in self._characteristics: return self._characteristics[uuid].split('.', maxsplit=3)[3] return 'Unknown Characteristic {i}'.format(i=orig_item)
def trimUuid(uuid): segs = uuid.split("-") if (len(segs) != 5): return uuid return "%s%s%s%s%s" % (uuid[0:8], uuid[9:13], uuid[14:18], uuid[19:23], uuid[24:36])
def is_uuid(uuid): uuid_pattern = [8,4,4,4,12] uuid_split = uuid.split('-') result = [len(x) for x in uuid_split] == uuid_pattern return result
user_name = user_info_json["user_name"] pass_word = user_info_json["pass_word"] phone_number = user_info_json["phone_number"] nick_name = user_info_json["nick_name"] sex = user_info_json["sex"] birthday = user_info_json["birthday"] query_user_result = mUserUtil.query_to_user_by_user_name(user_name) if len(query_user_result) == 0: mUserBean = UserBean() # uuid = uuid.uuid5(uuid.NAMESPACE_DNS, 'weather') uuid = uuid.uuid4() uuid = str(uuid) uuid = ''.join(uuid.split('-')) print uuid print len(uuid) mUserBean.mUserId = uuid mUserBean.mUserName = user_name mUserBean.mPassWord = pass_word mUserBean.mPhoneNumber = phone_number mUserBean.mNickName = nick_name if sex is not None: mUserBean.mSex = sex else: mUserBean.mSex = UserBean.USER_SEX_MAN if birthday is not None: mUserBean.mBirthday = birthday else: mUserBean.mBirthday = ""