本文整理汇总了Python中couchexport.models.ExportSchema.get方法的典型用法代码示例。如果您正苦于以下问题:Python ExportSchema.get方法的具体用法?Python ExportSchema.get怎么用?Python ExportSchema.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchexport.models.ExportSchema
的用法示例。
在下文中一共展示了ExportSchema.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSaveAndLoad
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get [as 别名]
def testSaveAndLoad(self):
index = ["foo", 2]
schema = ExportSchema(seq=5, index=index)
inner = {"dict": {"bar": 1, "baz": [2,3]},
"list": ["foo", "bar"],
"dictlist": [{"bip": 1, "bop": "blah"},
{"bip": 2, "bop": "blah2"}],
"item": "yoyoyo"}
schema.schema = inner
schema.save()
back = ExportSchema.get(schema.get_id)
self.assertEqual(inner, back.schema)
self.assertEqual(index, back.index)
示例2: update_custom_export
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get [as 别名]
def update_custom_export(self):
"""
Updates custom_export object from the request
and saves to the db
"""
post_data = self.post_data
custom_export_json = post_data['custom_export']
SAFE_KEYS = ('default_format', 'is_safe', 'name', 'schema_id', 'transform_dates')
for key in SAFE_KEYS:
self.custom_export[key] = custom_export_json[key]
# update the custom export index (to stay in sync)
schema_id = self.custom_export.schema_id
schema = ExportSchema.get(schema_id)
self.custom_export.index = schema.index
self.presave = post_data['presave']
self.export_stock = post_data['export_stock']
self.custom_export.tables = [
ExportTable.wrap(table)
for table in custom_export_json['tables']
]
table_dict = dict((t.index, t) for t in self.custom_export.tables)
for table in self.custom_export.tables:
if table.index in table_dict:
table_dict[table.index].columns = table.columns
else:
self.custom_export.tables.append(
ExportTable(
index=table.index,
display=self.custom_export.name,
columns=table.columns
)
)
self.update_custom_params()
self.custom_export.custom_validate()
self.custom_export.save()
touch_exports(self.domain)
if self.presave:
HQGroupExportConfiguration.add_custom_export(self.domain, self.custom_export.get_id)
else:
HQGroupExportConfiguration.remove_custom_export(self.domain, self.custom_export.get_id)
return self.custom_export.get_id
示例3: testExportTokenMigration
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get [as 别名]
def testExportTokenMigration(self):
c = Client()
c.login(**{'username': 'test', 'password': 'foobar'})
_submit_form()
time.sleep(1)
resp = get_export_response(c)
self.assertEqual(200, resp.status_code)
self.assertTrue(_content(resp) is not None)
self.assertTrue("X-CommCareHQ-Export-Token" in resp)
# blow away the timestamp property to ensure we're testing the
# migration case
prev_token = resp["X-CommCareHQ-Export-Token"]
prev_checkpoint = ExportSchema.get(prev_token)
assert prev_checkpoint.timestamp
示例4: get_export_components
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get [as 别名]
def get_export_components(schema_index, previous_export_id=None, filter=None):
"""
Get all the components needed to build an export file.
"""
previous_export = ExportSchema.get(previous_export_id) if previous_export_id else None
database = get_db()
config = ExportConfiguration(database, schema_index, previous_export, filter)
# handle empty case
if not config.potentially_relevant_ids:
return None, None, None
# get and checkpoint the latest schema
updated_schema = config.get_latest_schema()
export_schema_checkpoint = config.create_new_checkpoint()
return config, updated_schema, export_schema_checkpoint
示例5: export
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get [as 别名]
def export(
schema_index,
file,
format=Format.XLS_2007,
previous_export_id=None,
filter=None,
max_column_size=2000,
separator="|",
):
"""
Exports data from couch documents matching a given tag to a file.
Returns true if it finds data, otherwise nothing
"""
previous_export = ExportSchema.get(previous_export_id) if previous_export_id else None
database = get_db()
config = ExportConfiguration(database, schema_index, previous_export, filter)
# handle empty case
if not config.potentially_relevant_ids:
return None
# get and checkpoint the latest schema
updated_schema = get_schema_new(config)
export_schema_checkpoint = ExportSchema(seq=config.current_seq, schema=updated_schema, index=config.schema_index)
export_schema_checkpoint.save()
# transform docs onto output and save
writer = get_writer(format)
# open the doc and the headers
formatted_headers = get_headers(updated_schema, separator=separator)
writer.open(formatted_headers, file)
for doc in config.get_docs():
writer.write(
format_tables(create_intermediate_tables(doc, updated_schema), include_headers=False, separator=separator)
)
writer.close()
return export_schema_checkpoint