本文整理汇总了Python中schema.get_schema函数的典型用法代码示例。如果您正苦于以下问题:Python get_schema函数的具体用法?Python get_schema怎么用?Python get_schema使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_schema函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: load
def load(self):
tokens = self.path.split('/')[1:]
if tokens[0] == 'types' and len(tokens) == 1:
return {'id': 'types', 'itemtypes': schema.get_itemtypes(), 'selectable_itemtypes': schema.get_selectable_itemtypes()}
elif tokens[0] == 'types':
return schema.get_schema(tokens[1])
elif tokens[0] == 'sctypes':
return schema.get_schema(tokens[1], self_contained=True)
elif tokens[0] == 'properties':
return schema.get_property(tokens[1])
elif tokens[0] == 'datatypes':
return schema.get_datatype(tokens[1])
else:
return None
开发者ID:0hoo,项目名称:django-ecogwiki,代码行数:14,代码来源:resources.py
示例2: get_infobase
def get_infobase():
"""Creates infobase object."""
from infogami.infobase import infobase, dbstore, cache
web.config.db_printing = True
web.load()
# hack to make cache work for local infobase connections
cache.loadhook()
web.ctx.ip = '127.0.0.1'
store = dbstore.DBStore(schema.get_schema())
ib = infobase.Infobase(store, infobase.config.secret_key)
if config.writelog:
ib.add_event_listener(Logger(config.writelog))
ol = ib.get('openlibrary.org')
if ol and config.booklog:
global booklogger
booklogger = Logger(config.booklog)
ol.add_trigger('/type/edition', write_booklog)
ol.add_trigger('/type/author', write_booklog2)
if ol and config.http_listeners:
ol.add_event_listener(None, http_notify)
return ib
开发者ID:candeira,项目名称:openlibrary,代码行数:28,代码来源:ol.py
示例3: load
def load(self):
tokens = self.path.split("/")[1:]
if tokens[0] == "types" and len(tokens) == 1:
return {
"id": "types",
"itemtypes": schema.get_itemtypes(),
"selectable_itemtypes": schema.get_selectable_itemtypes(),
}
elif tokens[0] == "types":
return schema.get_schema(tokens[1])
elif tokens[0] == "sctypes":
return schema.get_schema(tokens[1], self_contained=True)
elif tokens[0] == "properties":
return schema.get_property(tokens[1])
elif tokens[0] == "datatypes":
return schema.get_datatype(tokens[1])
else:
return None
开发者ID:gcmcom,项目名称:ecogwiki,代码行数:18,代码来源:resources.py
示例4: setUp
def setUp(self):
super(CustomTypeAndPropertyTest, self).setUp()
schema.SCHEMA_TO_LOAD.append({
"datatypes": {
},
"properties": {
"politicalParty": {
"comment": "Political party.",
"comment_plain": "Political party.",
"domains": [
"Thing"
],
"id": "politicalParty",
"label": "Political Party",
"reversed_label": "%s",
"ranges": [
"Text"
]
}
},
"types": {
"Politician": {
"ancestors": [
"Thing",
"Person"
],
"comment": "",
"comment_plain": "",
"id": "Politician",
"label": "Politician",
"specific_properties": [
"politicalParty"
],
"subtypes": [],
"supertypes": [
"Person"
],
"url": "http://www.ecogwiki.com/sp.schema/types/Politician"
}
}
})
self.person = schema.get_schema('Person')
self.politician = schema.get_schema('Politician')
开发者ID:Sunsoo,项目名称:incodom,代码行数:43,代码来源:test_schema.py
示例5: load
def load(self):
tokens = self.path.split('/')[1:]
if tokens[0] == 'types' and len(tokens) == 1:
return {'id': 'types', 'values': schema.get_itemtypes()}
elif tokens[0] == 'types':
return schema.get_schema(tokens[1])
elif tokens[0] == 'properties':
return schema.get_property(tokens[1])
elif tokens[0] == 'datatypes':
return schema.get_datatype(tokens[1])
else:
return None
开发者ID:jangxyz,项目名称:ecogwiki,代码行数:12,代码来源:resources.py
示例6: parse_data
def parse_data(cls, title, body, itemtype=u'Article'):
body = body.replace('\r\n', '\n')
default_data = {'name': title, 'schema': schema.get_itemtype_path(itemtype)}
# collect
yaml_data = cls.parse_schema_yaml(body)
body_data = pairs_to_dict((m.group('name'), m.group('value')) for m in re.finditer(cls.re_data, body))
if itemtype == u'Article' or u'Article' in schema.get_schema(itemtype)[u'ancestors']:
default_section = u'articleBody'
else:
default_section = u'longDescription'
section_data = cls.parse_sections(body, default_section)
# merge
data = merge_dicts([default_data, yaml_data, body_data, section_data])
# validation and type conversion
typed = schema.SchemaConverter.convert(itemtype, data)
return typed
开发者ID:0hoo,项目名称:ecogwiki,代码行数:22,代码来源:page_operation_mixin.py
示例7: test_properties_should_contain_all_specific_properties
def test_properties_should_contain_all_specific_properties(self):
for t, _ in schema.get_itemtypes():
item = schema.get_schema(t)
self.assertEqual(set(), set(item['specific_properties']).difference(item['properties']))
开发者ID:Sunsoo,项目名称:incodom,代码行数:4,代码来源:test_schema.py
示例8: test_should_not_allow_legacy_spells
def test_should_not_allow_legacy_spells(self):
self.assertRaises(KeyError, schema.get_property, 'contactPoints')
self.assertTrue('awards' not in schema.get_schema('Person')['properties'])
开发者ID:Sunsoo,项目名称:incodom,代码行数:3,代码来源:test_schema.py
示例9: assertConformsToNamedSchema
def assertConformsToNamedSchema(self, obj, schema_name, strict=False):
schema = get_schema(schema_name)
if not schema:
raise AssertionError('Schema {0} is unknown'.format(schema_name))
self.assertConformsToSchema(obj, schema, strict)
开发者ID:erinix,项目名称:middleware,代码行数:5,代码来源:base.py
示例10: test_get_custom_plural_label_for_irregular_noun
def test_get_custom_plural_label_for_irregular_noun(self):
self.assertEqual(u'People', schema.get_schema('Person')['plural_label'])
开发者ID:Sunsoo,项目名称:incodom,代码行数:2,代码来源:test_schema.py
示例11: test_get_plural_label
def test_get_plural_label(self):
self.assertEqual(u'Creative Works', schema.get_schema('CreativeWork')['plural_label'])
self.assertEqual(u'Medical Entities', schema.get_schema('MedicalEntity')['plural_label'])
self.assertEqual(u'Local Businesses', schema.get_schema('LocalBusiness')['plural_label'])
self.assertEqual(u'Attorneys', schema.get_schema('Attorney')['plural_label'])
开发者ID:Sunsoo,项目名称:incodom,代码行数:5,代码来源:test_schema.py
示例12: Author
types.register_type('^/a/[^/]*$', '/type/author')
types.register_type('^/b/[^/]*$', '/type/edition')
types.register_type('^/l/[^/]*$', '/type/language')
types.register_type('^/works/[^/]*$', '/type/work')
types.register_type('^/subjects/[^/]*$', '/type/subject')
types.register_type('^/publishers/[^/]*$', '/type/publisher')
types.register_type('^/usergroup/[^/]*$', '/type/usergroup')
types.register_type('^/permission/[^/]*$', '/type/permision')
types.register_type('^/(css|js)/[^/]*$', '/type/rawtext')
# set up infobase schema. required when running in standalone mode.
import schema
dbstore.default_schema = schema.get_schema()
# this adds /show-marc/xxx page to infogami
import showmarc
# add zip and tuple to the list of public functions
public(zip)
public(tuple)
web.template.Template.globals['NEWLINE'] = "\n"
# Remove movefiles install hook. openlibrary manages its own files.
infogami._install_hooks = [h for h in infogami._install_hooks if h.__name__ != "movefiles"]
class Author(client.Thing):
photo_url_pattern = "%s?m=change_cover"
开发者ID:ziwar,项目名称:openlibrary,代码行数:30,代码来源:code.py
示例13: parse_content
def parse_content(parsed_feed):
"""Parses content"""
content_schema = schema.get_schema('content')
for feed in parsed_feed['entries']:
yield {key: feed.get(key) for key in content_schema}
开发者ID:jkrukowski,项目名称:rss,代码行数:5,代码来源:parsing.py
示例14: test_humane_labels
def test_humane_labels(self):
self.assertEqual(u'Politician', schema.get_schema('Politician')['label'])
self.assertEqual(u'Politicians', schema.humane_property('Politician', 'politicalParty', True))
self.assertEqual(u'Political Party', schema.humane_property('Politician', 'politicalParty'))
开发者ID:Sunsoo,项目名称:incodom,代码行数:4,代码来源:test_schema.py
示例15: test_properties_order_should_follow_that_of_source
def test_properties_order_should_follow_that_of_source(self):
article = schema.get_schema('Article')
self.assertEqual('additionalType', article['properties'][0])
self.assertEqual('longDescription', article['properties'][-1])
开发者ID:Sunsoo,项目名称:incodom,代码行数:4,代码来源:test_schema.py
示例16: setUp
def setUp(self):
super(CustomTypeAndPropertyTest, self).setUp()
schema.SCHEMA_TO_LOAD.append('schema-custom.json.sample')
self.person = schema.get_schema('Person')
self.politician = schema.get_schema('Politician')
开发者ID:Salada,项目名称:ecogwiki,代码行数:5,代码来源:test_schema.py
示例17: parse_feed
def parse_feed(feed_obj):
"""Parses feed"""
feed_schema = schema.get_schema('feed')
data = feedparser.parse(feed_obj.url, etag=feed_obj.etag,
modified=feed_obj.modified_parsed)
return {key: data.get(key) for key in feed_schema}
开发者ID:jkrukowski,项目名称:rss,代码行数:6,代码来源:parsing.py
示例18: test_self_contained_schema
def test_self_contained_schema(self):
s = schema.get_schema('Person', True)
url = s['properties']['url']
self.assertEqual(dict, type(url))
self.assertEqual([0, 0], url['cardinality'])
self.assertEqual(['URL'], url['type']['ranges'])
开发者ID:Sunsoo,项目名称:incodom,代码行数:6,代码来源:test_schema.py
示例19: get_schema
# -*- coding: utf-8 -*-
"""
Index
=====
Index constrói índices de documentos com base num esquema que defina
a sua estrutura.
"""
try:
from schema import get_schema
SCHEMA = get_schema()
except ImportError:
print "Ocorreu um erro ao importar o SCHEMA padrão."
raise
try:
import os
from whoosh import index
except ImportError:
print "Ocorreu um erro ao importar a biblioteca Whoosh."
raise
try:
from constants import INDEXDIR, INDEXNAME
开发者ID:phillipecavalcante,项目名称:storyline,代码行数:31,代码来源:index.py
示例20: test_property_inheritance
def test_property_inheritance(self):
person = set(schema.get_schema('Person')['properties'])
politician = set(schema.get_schema('Politician')['properties'])
self.assertEqual(set(), person.difference(politician))
self.assertEqual({u'politicalParty'}, politician.difference(person))
开发者ID:Sunsoo,项目名称:incodom,代码行数:5,代码来源:test_schema.py
注:本文中的schema.get_schema函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论