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


Python Entity.create方法代码示例

本文整理汇总了Python中aleph.model.Entity.create方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.create方法的具体用法?Python Entity.create怎么用?Python Entity.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aleph.model.Entity的用法示例。


在下文中一共展示了Entity.create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
 def setUp(self):
     super(EntitiesTestCase, self).setUp()
     self.rolex = self.create_user(foreign_id='user_3')
     self.col = Collection()
     self.col.label = 'Original Collection'
     self.col.foreign_id = 'test_coll_entities'
     db.session.add(self.col)
     self.col_other = Collection()
     self.col_other.label = 'Other Collection'
     self.col_other.foreign_id = 'test_coll_entities_other'
     db.session.add(self.col_other)
     db.session.flush()
     self.ent = Entity.create({
         'schema': 'LegalEntity',
         'properties': {
             'name': 'Winnie the Pooh',
             'country': 'pa',
             'summary': 'a fictional teddy bear created by A. A. Milne',
             'alias': ['Puh der Bär', 'Pooh Bear']
         }
     }, self.col)
     self.other = Entity.create({
         'schema': 'LegalEntity',
         'properties': {
             'name': 'Pu der Bär',
             'country': 'de',
             'description': 'he is a bear',
             'alias': ['Puh der Bär']
         }
     }, self.col)
     db.session.commit()
开发者ID:pudo,项目名称:aleph,代码行数:33,代码来源:test_entities.py

示例2: load_fixture

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
def load_fixture(name):
    dir_name = os.path.join(fixtures_path, name)
    if not os.path.isdir(dir_name):
        raise ValueError("No such directory: %r" % dir_name)

    with open(os.path.join(dir_name, 'mapping.yaml'), 'rb') as fh:
        data = yaml.load(fh)

    lst = List.by_label(data.get('list'))
    selectors = set()
    if lst is not None:
        selectors = lst.terms
        lst.delete()
        db.session.commit()

    lst = List.create({
        'label': data.get('list'),
        'public': data.get('public'),
        'users': []
    }, None)
    log.info("Loading %r", lst)

    mapping = data.get('mapping')
    default_category = data.get('default_category')
    assert default_category in CATEGORIES, default_category

    entities = defaultdict(set)
    with open(os.path.join(dir_name, 'data.csv'), 'rb') as fh:
        for row in unicodecsv.DictReader(fh):
            label = row.get(mapping.get('label', 'label'))
            if label is None:
                continue

            category = row.get(mapping.get('category', 'category'))
            category = category or default_category

            selectors = [row.get(mapping.get('selector', 'selector'))]
            selectors = [s for s in selectors if s]
            entities[(label, category)].update(selectors)

    for (label, category), selectors in entities.items():
        data = {'label': label, 'category': category,
                'selectors': selectors, 'list': lst}
        try:
            Entity.create(data, None)
        except Invalid, inv:
            log.warn("Failed: %s", inv)
开发者ID:datastark,项目名称:aleph,代码行数:49,代码来源:fixtures.py

示例3: create

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
def create():
    data = EntityForm().deserialize(request_data())
    authz.require(data["list"])
    authz.require(authz.list_write(data["list"].id))
    entity = Entity.create(data, current_user)
    db.session.commit()
    refresh_selectors.delay(list(entity.terms))
    return view(entity.id)
开发者ID:nightsh,项目名称:aleph,代码行数:10,代码来源:entities_api.py

示例4: create

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
def create():
    data = EntityForm().deserialize(request_data())
    watchlist = data.get("watchlist")
    authz.require(watchlist)
    authz.require(authz.watchlist_write(watchlist.id))
    entity = Entity.create(data)
    watchlist.touch()
    db.session.commit()
    analyze_entity.delay(entity.id)
    return view(entity.id)
开发者ID:DavidLemayian,项目名称:aleph,代码行数:12,代码来源:entities_api.py

示例5: create

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
def create():
    data = request_data()
    collection = data.get('collection')
    authz.require(collection)
    authz.require(authz.collection_write(collection.id))
    entity = Entity.create(data)
    collection.touch()
    db.session.commit()
    analyze_entity.delay(entity.id)
    return view(entity.id)
开发者ID:01-,项目名称:aleph,代码行数:12,代码来源:entities_api.py

示例6: setUp

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
 def setUp(self):
     super(EntitiesApiTestCase, self).setUp()
     self.rolex = self.create_user(foreign_id='user_3')
     self.col = self.create_collection()
     self.data = {
         'schema': 'LegalEntity',
         'properties': {
             'name': 'Winnie the Pooh',
             'country': 'pa',
         }
     }
     self.ent = Entity.create(self.data, self.col)
     db.session.commit()
     index_entity(self.ent)
开发者ID:pudo,项目名称:aleph,代码行数:16,代码来源:test_entities_api.py

示例7: setUp

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
 def setUp(self):
     super(CollectionsApiTestCase, self).setUp()
     self.rolex = self.create_user(foreign_id='user_3')
     self.col = self.create_collection(
         label='Test Collection',
         foreign_id='test_coll_entities_api',
         category='leak',
         countries=[]
     )
     self.ent = Entity.create({
         'schema': 'Person',
         'properties': {
             'name': 'Winnie the Pooh',
         }
     }, self.col)
     db.session.add(self.ent)
     db.session.commit()
开发者ID:pudo,项目名称:aleph,代码行数:19,代码来源:test_collections_api.py

示例8: create_entity

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
def create_entity(data, collection, role=None, sync=False):
    entity = Entity.create(data, collection)
    db.session.commit()
    data = index.index_entity(entity, sync=sync)
    refresh_entity(entity)
    return data
开发者ID:pudo,项目名称:aleph,代码行数:8,代码来源:__init__.py

示例9: setUp

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import create [as 别名]
    def setUp(self):
        super(XrefApiTestCase, self).setUp()
        self.creator = self.create_user(foreign_id='creator')
        self.outsider = self.create_user(foreign_id='outsider')

        # First public collection and entities
        self.residents = self.create_collection(
            label='Residents of Habitat Ring',
            foreign_id='test_residents',
            creator=self.creator
        )
        self.grant_publish(self.residents)

        self.ent = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'Elim Garak',
            }
        }, self.residents)
        db.session.add(self.ent)

        self.ent2 = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'Leeta',
            }
        }, self.residents)
        db.session.add(self.ent2)

        # Second public collection and entities
        self.dabo = self.create_collection(
            label='Dabo Girls',
            foreign_id='test_dabo',
            creator=self.creator
        )
        self.grant_publish(self.dabo)

        self.ent3 = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'MPella',
            }
        }, self.dabo)
        db.session.add(self.ent3)

        self.ent4 = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'Leeta',
            }
        }, self.dabo)
        db.session.add(self.ent4)

        self.ent5 = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'Mardah',
            }
        }, self.dabo)
        db.session.add(self.ent5)

        # Private collection and entities
        self.obsidian = self.create_collection(
            label='Obsidian Order',
            foreign_id='test_obsidian',
            creator=self.creator
        )

        self.ent6 = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'Elim Garak',
            }
        }, self.obsidian)
        db.session.add(self.ent6)

        self.ent7 = Entity.create({
            'schema': 'Person',
            'properties': {
                'name': 'Enabran Tain',
            }
        }, self.obsidian)
        db.session.add(self.ent7)

        db.session.commit()
        index_entity(self.ent)
        index_entity(self.ent2)
        index_entity(self.ent3)
        index_entity(self.ent4)
        index_entity(self.ent5)
        index_entity(self.ent6)
        index_entity(self.ent7)
开发者ID:pudo,项目名称:aleph,代码行数:94,代码来源:test_xref_api.py


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