本文整理汇总了Python中plenario.models.ShapeMetadata.add方法的典型用法代码示例。如果您正苦于以下问题:Python ShapeMetadata.add方法的具体用法?Python ShapeMetadata.add怎么用?Python ShapeMetadata.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plenario.models.ShapeMetadata
的用法示例。
在下文中一共展示了ShapeMetadata.add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_shape
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def test_delete_shape(self):
# Can we remove a shape that's fully ingested?
city_meta = postgres_session.query(ShapeMetadata).get(shape_fixtures['city'].table_name)
self.assertIsNotNone(city_meta)
city_meta.remove_table()
postgres_session.commit()
city_meta = postgres_session.query(ShapeMetadata).get(shape_fixtures['city'].table_name)
self.assertIsNone(city_meta)
# Can we remove a shape that's only in the metadata?
dummy_meta = postgres_session.query(ShapeMetadata).get(self.dummy_name)
self.assertIsNotNone(dummy_meta)
dummy_meta.remove_table()
postgres_session.commit()
dummy_meta = postgres_session.query(ShapeMetadata).get(self.dummy_name)
self.assertIsNone(dummy_meta)
# Add them back to return to original test state
ShapeTests.ingest_fixture(shape_fixtures['city'])
ShapeMetadata.add(human_name='Dummy Name',
source_url=None,
update_freq='yearly',
approved_status=False)
postgres_session.commit()
示例2: ingest_fixture
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def ingest_fixture(fixture):
# Add the fixture to the metadata first
shape_meta = ShapeMetadata.add(caller_session=session, human_name=fixture.human_name, source_url=None)
session.commit()
# Bypass the celery task and call on a ShapeETL directly
ShapeETL(meta=shape_meta, source_path=fixture.path).import_shapefile()
return shape_meta
示例3: ingest_fixture
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def ingest_fixture(fixture):
# Add the fixture to the metadata first
shape_meta = ShapeMetadata.add(human_name=fixture.human_name,
source_url=None,
update_freq=fixture.update_freq,
approved_status=False)
session.commit()
# Bypass the celery task and call on a ShapeETL directly
ShapeETL(meta=shape_meta, source_path=fixture.path).add()
return shape_meta
示例4: test_delete_shape
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def test_delete_shape(self):
# Can we remove a shape that's fully ingested?
city_meta = session.query(ShapeMetadata).get(fixtures["city"].table_name)
self.assertIsNotNone(city_meta)
city_meta.remove_table(caller_session=session)
session.commit()
city_meta = session.query(ShapeMetadata).get(fixtures["city"].table_name)
self.assertIsNone(city_meta)
# Can we remove a shape that's only in the metadata?
dummy_meta = session.query(ShapeMetadata).get(self.dummy_name)
self.assertIsNotNone(dummy_meta)
dummy_meta.remove_table(caller_session=session)
session.commit()
dummy_meta = session.query(ShapeMetadata).get(self.dummy_name)
self.assertIsNone(dummy_meta)
# Add them back to return to original test state
ShapeTests.ingest_fixture(fixtures["city"])
ShapeMetadata.add(caller_session=session, human_name=u"Dummy Name", source_url=None)
session.commit()
示例5: shape_meta_from_submit_form
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def shape_meta_from_submit_form(form, is_approved):
md = ShapeMetadata.add(
human_name=form['dataset_name'],
source_url=form['file_url'],
view_url=form.get('view_url'),
attribution=form.get('dataset_attribution'),
description=form.get('dataset_description'),
update_freq=form['update_frequency'],
contributor_name=form['contributor_name'],
contributor_organization=form.get('contributor_organization'),
contributor_email=form['contributor_email'],
approved_status=is_approved)
postgres_session.commit()
return md
示例6: ingest_shapes
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def ingest_shapes(cls):
fixtures = [f for k, f in shape_fixtures.items() if k != 'changed_neighborhoods']
fixture_table_names = [f.table_name for f in fixtures]
drop_tables(fixture_table_names)
postgres_session.commit()
for fixture in fixtures:
cls.ingest_fixture(fixture)
# Add a dummy dataset to the metadata without ingesting a shapefile for it
cls.dummy_name = ShapeMetadata.add(human_name='Dummy Name',
source_url=None,
update_freq='yearly',
approved_status=False).dataset_name
postgres_session.commit()
示例7: setUpClass
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def setUpClass(cls, shutdown=False):
# Remove tables that we're about to recreate.
# This doesn't happen in teardown because I find it helpful
# to inspect them in the DB after running the tests.
meta_table_names = ['meta_shape']
fixture_table_names = [fixture.table_name for key, fixture in fixtures.iteritems()]
drop_tables(meta_table_names + fixture_table_names)
# Re-add meta tables
init_meta()
# Fully ingest the fixtures
BasePlenarioTest.ingest_fixture(fixtures['city'])
BasePlenarioTest.ingest_fixture(fixtures['streets'])
BasePlenarioTest.ingest_fixture(fixtures['zips'])
BasePlenarioTest.ingest_fixture(fixtures['neighborhoods'])
# Add a dummy dataset to the metadata without ingesting a shapefile for it
cls.dummy_name = ShapeMetadata.add(human_name=u'Dummy Name',
source_url=None,
update_freq='yearly',
approved_status=False).dataset_name
session.commit()
tables_to_drop = [
'flu_shot_clinics',
'landmarks',
'crimes',
'meta_master'
]
drop_tables(tables_to_drop)
init_meta()
ingest_from_fixture(flu_shot_meta, flu_path)
ingest_from_fixture(landmarks_meta, landmarks_path)
ingest_from_fixture(crime_meta, crime_path)
cls.app = create_app().test_client()
'''/detail'''
示例8: setUpClass
# 需要导入模块: from plenario.models import ShapeMetadata [as 别名]
# 或者: from plenario.models.ShapeMetadata import add [as 别名]
def setUpClass(cls):
# Remove tables that we're about to recreate.
# This doesn't happen in teardown because I find it helpful to inspect them in the DB after running the tests.
meta_table_names = ["dat_master", "meta_shape", "meta_master", "plenario_user"]
fixture_table_names = [fixture.table_name for key, fixture in fixtures.iteritems()]
drop_tables(meta_table_names + fixture_table_names)
# Re-add meta tables
init_master_meta_user()
# Fully ingest the fixtures
ShapeTests.ingest_fixture(fixtures["city"])
ShapeTests.ingest_fixture(fixtures["streets"])
ShapeTests.ingest_fixture(fixtures["zips"])
# Add a dummy dataset to the metadata without ingesting a shapefile for it
cls.dummy_name = ShapeMetadata.add(
caller_session=session, human_name=u"Dummy Name", source_url=None
).dataset_name
session.commit()
cls.app = create_app().test_client()