本文整理汇总了Python中uuid.uuid3函数的典型用法代码示例。如果您正苦于以下问题:Python uuid3函数的具体用法?Python uuid3怎么用?Python uuid3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uuid3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create_mock_resource_temaplate
def create_mock_resource_temaplate():
### Resource to be reuqested for 'mock'
resource_requests = {'compute': {}, 'network': {}}
###### mycompute-0
msg = rmgryang.VDUEventData_RequestInfo()
msg.image_id = str(uuid.uuid3(uuid.NAMESPACE_DNS, 'image-0'))
msg.vm_flavor.vcpu_count = 4
msg.vm_flavor.memory_mb = 8192
msg.vm_flavor.storage_gb = 40
resource_requests['compute']['mycompute-0'] = msg
###### mycompute-1
msg = rmgryang.VDUEventData_RequestInfo()
msg.image_id = str(uuid.uuid3(uuid.NAMESPACE_DNS, 'image-1'))
msg.vm_flavor.vcpu_count = 2
msg.vm_flavor.memory_mb = 8192
msg.vm_flavor.storage_gb = 20
resource_requests['compute']['mycompute-1'] = msg
####### mynet-0
msg = rmgryang.VirtualLinkEventData_RequestInfo()
resource_requests['network']['mynet-0'] = msg
####### mynet-1
msg = rmgryang.VirtualLinkEventData_RequestInfo()
resource_requests['network']['mynet-1'] = msg
return resource_requests
开发者ID:agunturu,项目名称:RIFT.ware,代码行数:29,代码来源:rmmgr_test.py
示例2: initialize
def initialize(self):
root = {"role_name": "root"}
admin = {"username": "admin",
"password": "123456",
"status": 1,
"email": "[email protected]",
"role_code": str(uuid.uuid3(uuid.NAMESPACE_DNS, "root"))}
roles = AlchemyWrapper("roles")
users = AlchemyWrapper("users")
node = AlchemyWrapper("resource")
if len(roles.all(**root))==0:
roles.insert(root)
if len(users.all(username="admin"))==0:
users.insert(admin)
attribute = getattr(options, "attribute", "scarecrow")
for api in self.api_list.get("api"):
combinat = api.get("url") + attribute
node_code = str(uuid.uuid3(uuid.NAMESPACE_DNS, str(combinat)))
node_info = {"attribute": attribute,
"code": node_code,
"resource_name": api.get("name"),
"resource_URI": api.get("url")}
if len(node.all(**node_info))==0:
node.insert(node_info)
开发者ID:TokenUndefined,项目名称:scarecrow,代码行数:26,代码来源:__init__.py
示例3: migrate_standardpage_intro_and_body_to_streamfield
def migrate_standardpage_intro_and_body_to_streamfield(apps, schema_editor):
StandardPage = apps.get_model('torchbox.StandardPage')
stream_block = StandardPage._meta.get_field('streamfield').stream_block
# Append body to beginning of streamfield
for page in StandardPage.objects.exclude(body__in=['', '<p></p>', '<p><br/></p>']):
# Add body as first block so it appears in the same place on the template
page.streamfield = StreamValue(
stream_block,
[
('paragraph', RichText(page.body), str(uuid3(UUID_NAMESPACE, page.body))),
] + [
(child.block_type, child.value, child.id)
for child in page.streamfield
]
)
page.save()
# Append intro to beginning of streamfield
for page in StandardPage.objects.exclude(intro__in=['', '<p></p>', '<p><br/></p>']):
# Add intro as first block so it appears in the same place on the template
page.streamfield = StreamValue(
stream_block,
[
('paragraph', RichText(page.intro), str(uuid3(UUID_NAMESPACE, page.intro))),
] + [
(child.block_type, child.value, child.id)
for child in page.streamfield
]
)
page.save()
开发者ID:torchbox,项目名称:wagtail-torchbox,代码行数:33,代码来源:0118_remove_standardpage_intro_and_body.py
示例4: mock_data
def mock_data(fields):
result = {}
for f in fields:
fname = f["name"]
fval = f.get("default", NotImplemented)
if fval is not NotImplemented:
result[fname] = fval
continue
ftype = f.get("type", "string")
f_id = abs(id(f))
if ftype == "string":
result[fname] = uuid.uuid3(uuid.NAMESPACE_OID, str(f_id)).get_hex()[:8]
elif ftype == "integer":
result[fname] = f_id % 100
elif ftype == "float":
result[fname] = f_id % 100 / 1.0
elif ftype == "uuid":
result[fname] = uuid.uuid3(uuid.NAMESPACE_OID, str(f_id)).get_hex()
elif ftype == "date":
result[fname] = datetime.date.today().isoformat()
elif ftype == "datetime":
result[fname] = datetime.datetime.today().isoformat()
elif ftype == "boolean":
result[fname] = [True, False][f_id % 2]
elif ftype.endswith("list"):
result[fname] = []
return result
开发者ID:MrLYC,项目名称:restdoc,代码行数:28,代码来源:doc_tags.py
示例5: setup_app
def setup_app(command, conf, vars):
"""Place any commands to setup repository here"""
# Don't reload the app if it was loaded under the testing environment
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
Base.metadata.create_all(bind=Session.bind)
namespace = uuid.UUID(conf.global_conf['uuid_namespace'])
# Default groups
users = model.Group(name='users')
users.uuid = uuid.uuid3(namespace, 'GROUP'+'users').hex
Session.add(users)
Session.commit()
# add some users from a file into the db for testing
# each line of the file should be of the form name,email,dn
admin_file = conf.global_conf['admin_file']
f = open(path.expandvars(admin_file), 'r')
for line in f:
name, email, dn = line.rstrip('\n').split(',')
user = model.User(name=name, email=email, client_dn=dn)
user.uuid = uuid.uuid3(namespace, dn).hex
user.gobal_admin=True
user.suspended=False
user.groups.append(users)
Session.add(user)
Session.commit()
f.close()
开发者ID:dbharris,项目名称:repoman,代码行数:31,代码来源:websetup.py
示例6: init_process
def init_process(row):
uid = str(uuid.uuid3(uuid.NAMESPACE_OID, "Process/" + row[0]))
cat_id = get_category_id("PROCESS", row[4], row[3])
flow_id = str(uuid.uuid3(uuid.NAMESPACE_OID, "Flow/" + row[0]))
p = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "Process",
"@id": uid,
"name": row[2],
"processTyp": "UNIT_PROCESS",
"category": {"@type": "Category", "@id": cat_id},
"processDocumentation": {"copyright": False},
"exchanges": [
{
"@type": "Exchange",
"avoidedProduct": False,
"input": False,
"amount": 1.0,
"flow": {"@type": "Flow", "@id": flow_id},
"unit": {
"@type": "Unit",
"@id": "3f90ee51-c78b-4b15-a693-e7f320c1e894"
},
"flowProperty": {
"@type": "FlowProperty",
"@id": "b0682037-e878-4be4-a63a-a7a81053a691"
},
"quantitativeReference": True
}
]
}
return p
开发者ID:GreenDelta,项目名称:usio,代码行数:32,代码来源:jsonld.py
示例7: update_revisions
def update_revisions(page, content):
streamfield_json = content.get('streamfield', '')
if streamfield_json:
streamfield = json.loads(streamfield_json)
else:
streamfield = []
# Append body to beginning of streamfield
if content['body'] not in ['', '<p></p>', '<p><br/></p>']:
content['old_body'] = content['body']
streamfield.insert(0, {
"type": "paragraph",
"value": content['body'],
"id": str(uuid3(UUID_NAMESPACE, content['body'])),
})
# Append intro to beginning of streamfield
if content['intro'] not in ['', '<p></p>', '<p><br/></p>']:
streamfield.insert(0, {
"type": "paragraph",
"value": content['intro'],
"id": str(uuid3(UUID_NAMESPACE, content['intro'])),
})
# Save streamfield content with "body" key, as it was renamed as well in this migration
content['body'] = json.dumps(streamfield)
return content
开发者ID:torchbox,项目名称:wagtail-torchbox,代码行数:30,代码来源:0118_remove_standardpage_intro_and_body.py
示例8: parse
def parse(self,response):
global uuid
#生成uuid的namespace,和当前链接相关
namespace = uuid.uuid3(uuid.NAMESPACE_URL,response.url)
item = Baike_Qijia_Item()
split1 = '>'
split2 = ';'
item['title_id'] = response.url.split("-")[1][:-1] #取url中的id
item['title_url'] = response.url
item['title_name'] = Selector(response).xpath("//div[@class='artical-des atical-des1 fl']/h1/text()").extract()
item['title_introduction'] = Selector(response).xpath("//div[@class='artical-des atical-des1 fl']/div[1]/i/text()").extract()
#分类用>连接成为一个字符串
category = Selector(response).xpath("//div[@class='bk-nav clearfix']/a/text()").extract()
item['title_category'] = split1.join(category)
item['content_name'] = Selector(response).xpath("//div[@class='atical-floor']/div/h2/a/text()").extract()
#内容主键生成,标题表uuid_list生成
content_uuid = []
index = 1
while index <= len(item['content_name']):
con_id = uuid.uuid3(namespace,'%d'%index)
content_uuid.append(con_id.hex)
index = index + 1
item['content_uuid'] = content_uuid
item['content_uuid_list'] = split2.join(content_uuid)
#content_text得处理text里面的html标签
item['content_text'] = Selector(response).xpath("//div[@class='atical-floor']/div/div/div/p").extract()
item['image_urls'] = Selector(response).xpath("//div[@class='floor-content floor-content-ml clearfix']/div/img/@src").extract()
return item
开发者ID:lwbupt,项目名称:SuperSpider,代码行数:32,代码来源:Spider_Qijia.py
示例9: _memoize_make_version_hash
def _memoize_make_version_hash(self):
if self.namespace.startswith('http'):
UUID = uuid.uuid3(uuid.NAMESPACE_URL, self.namespace)
if self.namespace:
UUID = uuid.uuid3(uuid.NAMESPACE_DNS, self.namespace)
else:
UUID = uuid.uuid4()
return base64.b64encode(UUID.bytes)[:6].decode(ENCODING)
开发者ID:reubano,项目名称:mezmorize,代码行数:9,代码来源:__init__.py
示例10: _set_identifiers
def _set_identifiers(self):
self.identifiers = []
entry_uuid = None
if self.isbn is not None:
entry_uuid = uuid.uuid3(self.uuid_master, isbn)
self.identifiers.append('urn:isbn:%s' % isbn)
else:
entry_uuid = uuid.uuid3(self.uuid_master, ''.join(self.authors) + self.title)
self.urn = 'urn:uuid:%s' % entry_uuid
开发者ID:abdelazer,项目名称:opds-tools,代码行数:9,代码来源:entry.py
示例11: get_data
def get_data(self, index=None):
if index == None:
index = self.mutation_index
valuesize = self.valuesize_sequence[index % len(self.valuesize_sequence)]
if self.cache_data:
if not valuesize in self.data_cache:
self.data_cache[valuesize] = (str(uuid.uuid3(self.uuid,`index`)) * (1+valuesize/36))[:valuesize]
return `index` + self.data_cache[valuesize]
else:
return (str(uuid.uuid3(self.uuid,`index`)) * (1+valuesize/36))[:valuesize]
开发者ID:Boggypop,项目名称:testrunner,代码行数:11,代码来源:load_runner.py
示例12: save
def save(self, commit=True):
# Save the provided password in hashed format
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
user.userid = str(uuid.uuid3(uuid.uuid4(), str(time.time())).hex)
user.usignature = str(uuid.uuid3(uuid.uuid4(), str(time.time())).hex)
user.clientid = str(uuid.uuid3(uuid.uuid4(), str(time.time())).hex)
if commit:
user.save()
return user
开发者ID:gao7ios,项目名称:G7Platform,代码行数:11,代码来源:admin.py
示例13: get_json_data
def get_json_data(self, index=None):
if index == None:
index = self.mutation_index
valuesize = self.valuesize_sequence[index % len(self.valuesize_sequence)]
if self.cache_data:
if not valuesize in self.data_cache:
self.data_cache[valuesize] = (str(uuid3(self.uuid,`index`)) * (1+valuesize/36))[:valuesize]
return json.dumps({'index':index,'data':self.data_cache[valuesize],'size':valuesize})
else:
return json.dumps({'index':index,'data':(str(uuid3(self.uuid,`index`)) * (1+valuesize/36))[:valuesize],'size':valuesize})
开发者ID:kbatten,项目名称:load_runner,代码行数:11,代码来源:load_runner.py
示例14: tc_today
def tc_today(n=1):
"""
generate n table codes for today
"""
for i in range(0,n):
tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4]
if tcode == 'dba5':
tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4]
# insert this table code to use
tc = TableCode(code=tcode, date=date.today())
tc.save()
开发者ID:kwantopia,项目名称:socialsaver,代码行数:11,代码来源:initialize.py
示例15: get_uuid_code
def get_uuid_code():
"""
uuid模块生成随机码
:return: 随机码
"""
print(uuid.uuid3(uuid.NAMESPACE_DNS, 'practice_0001.py')) # 基于MD5值
print(uuid.uuid4()) # 随机uuid
print(uuid.uuid5(uuid.NAMESPACE_DNS, 'practice_0001.py')) # 基于SHA-1值
for ui in range(10):
print(uuid.uuid3(uuid.NAMESPACE_DNS, '{}'.format(ui)))
return uuid.uuid1()
开发者ID:CityManager,项目名称:show-me-the-code,代码行数:11,代码来源:practice_0001.py
示例16: generateUuid
def generateUuid(self, email_id, machine_name):
""" return a uuid which uniquely identifies machinename and email id """
uuidstr = None
if machine_name not in self.d:
myNamespace = uuid.uuid3(uuid.NAMESPACE_URL, machine_name)
uuidstr = str(uuid.uuid3(myNamespace, email_id))
self.d[machine_name] = (machine_name, uuidstr, email_id)
self.d[uuidstr] = (machine_name, uuidstr ,email_id)
else:
(machine_name, uuidstr, email_id) = self.d[machine_name]
return uuidstr
开发者ID:bhramoss,项目名称:code,代码行数:14,代码来源:recipe-501148.py
示例17: test_uuid3
def test_uuid3(self):
equal = self.assertEqual
# Test some known version-3 UUIDs.
for u, v in [
(uuid.uuid3(uuid.NAMESPACE_DNS, "python.org"), "6fa459ea-ee8a-3ca4-894e-db77e160355e"),
(uuid.uuid3(uuid.NAMESPACE_URL, "http://python.org/"), "9fe8e8c4-aaa8-32a9-a55c-4535a88b748d"),
(uuid.uuid3(uuid.NAMESPACE_OID, "1.3.6.1"), "dd1a1cef-13d5-368a-ad82-eca71acd4cd1"),
(uuid.uuid3(uuid.NAMESPACE_X500, "c=ca"), "658d3002-db6b-3040-a1d1-8ddd7d189a4d"),
]:
equal(u.variant, uuid.RFC_4122)
equal(u.version, 3)
equal(u, uuid.UUID(v))
equal(str(u), v)
开发者ID:xxxhycl2010,项目名称:Python-2.7.8,代码行数:14,代码来源:test_uuid.py
示例18: generate_id
def generate_id(self, email, password):
host_id = None
if email not in self.db:
name = uuid.uuid3(uuid.NAMESPACE_URL, email)
host_id = str(uuid.uuid3(name, email))
self.db[email] = (email, password, host_id)
self.db[host_id] = (email, password, host_id)
else:
(email, password, host_id) = self.db[email]
return host_id
开发者ID:sayradley,项目名称:XMLRPCServer,代码行数:14,代码来源:server.py
示例19: _key_to_id
def _key_to_id(self, key):
"""
Converts Ecospold01 "number" attributes to UUIDs using the internal UUID namespace.
:param key:
:return:
"""
if isinstance(key, int):
key = str(key)
u = to_uuid(key)
if u is not None:
return u
if six.PY2:
return uuid.uuid3(self._ns_uuid, key.encode('utf-8'))
else:
return uuid.uuid3(self._ns_uuid, key)
开发者ID:bkuczenski,项目名称:lca-tools,代码行数:15,代码来源:base.py
示例20: tc_days
def tc_days(n=30,per_day=10):
# generate table codes per day
for i in range(0,n):
valid_day = date.today()+timedelta(i)
tc = TableCode(code='dba5', date=valid_day)
tc.save()
for j in range(0,per_day):
# 10 table codes per day
tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4]
if tcode == 'dba5':
# regenerate since it collides with default
tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4]
# insert this table code to use
tc = TableCode(code=tcode, date=valid_day)
tc.save()
开发者ID:kwantopia,项目名称:socialsaver,代码行数:15,代码来源:initialize.py
注:本文中的uuid.uuid3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论