本文整理汇总了Python中onadata.libs.utils.export_tools.ExportBuilder.GROUP_DELIMITER方法的典型用法代码示例。如果您正苦于以下问题:Python ExportBuilder.GROUP_DELIMITER方法的具体用法?Python ExportBuilder.GROUP_DELIMITER怎么用?Python ExportBuilder.GROUP_DELIMITER使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onadata.libs.utils.export_tools.ExportBuilder
的用法示例。
在下文中一共展示了ExportBuilder.GROUP_DELIMITER方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_xls_export_respects_custom_field_delimiter
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_to_xls_export_respects_custom_field_delimiter(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = ExportBuilder.GROUP_DELIMITER_DOT
export_builder.set_survey(survey)
xls_file = NamedTemporaryFile(suffix='.xls')
filename = xls_file.name
export_builder.to_xls_export(filename, self.data)
xls_file.seek(0)
wb = load_workbook(filename)
# check header columns
main_sheet = wb.get_sheet_by_name('childrens_survey')
expected_column_headers = [
u'name', u'age', u'geo.geolocation', u'geo._geolocation_latitude',
u'geo._geolocation_longitude', u'geo._geolocation_altitude',
u'geo._geolocation_precision', u'tel.tel.office',
u'tel.tel.mobile', u'_id', u'meta.instanceID', u'_uuid',
u'_submission_time', u'_index', u'_parent_index',
u'_parent_table_name', u'_tags', '_notes', '_version',
'_duration', '_submitted_by']
column_headers = [c[0].value for c in main_sheet.columns]
self.assertEqual(sorted(column_headers),
sorted(expected_column_headers))
xls_file.close()
示例2: test_delimiter_replacement_works_existing_fields
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_delimiter_replacement_works_existing_fields(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = "."
export_builder.set_survey(survey)
expected_sections = [{"name": "children", "elements": [{"title": "children.name", "xpath": "children/name"}]}]
children_section = export_builder.section_by_name("children")
self.assertEqual(children_section["elements"][0]["title"], expected_sections[0]["elements"][0]["title"])
示例3: test_delimiter_replacement_works_for_generated_gps_fields
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_delimiter_replacement_works_for_generated_gps_fields(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = "."
export_builder.set_survey(survey)
expected_section = {
"name": "childrens_survey",
"elements": [{"title": "geo._geolocation_latitude", "xpath": "geo/_geolocation_latitude"}],
}
main_section = export_builder.section_by_name("childrens_survey")
match = filter(lambda x: (expected_section["elements"][0]["xpath"] == x["xpath"]), main_section["elements"])[0]
self.assertEqual(expected_section["elements"][0]["title"], match["title"])
示例4: test_delimiter_replacement_works_generated_multi_select_fields
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_delimiter_replacement_works_generated_multi_select_fields(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = "."
export_builder.set_survey(survey)
expected_section = {
"name": "children",
"elements": [{"title": "children.fav_colors.red", "xpath": "children/fav_colors/red"}],
}
childrens_section = export_builder.section_by_name("children")
match = filter(lambda x: expected_section["elements"][0]["xpath"] == x["xpath"], childrens_section["elements"])[
0
]
self.assertEqual(expected_section["elements"][0]["title"], match["title"])
示例5: test_delimiter_replacement_works_generated_multi_select_fields
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_delimiter_replacement_works_generated_multi_select_fields(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = "."
export_builder.set_survey(survey)
expected_section =\
{
'name': 'children',
'elements': [
{
'title': 'children.fav_colors.red',
'xpath': 'children/fav_colors/red'
}
]
}
childrens_section = export_builder.section_by_name('children')
match = filter(lambda x: expected_section['elements'][0]['xpath']
== x['xpath'], childrens_section['elements'])[0]
self.assertEqual(
expected_section['elements'][0]['title'], match['title'])
示例6: test_delimiter_replacement_works_for_generated_gps_fields
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_delimiter_replacement_works_for_generated_gps_fields(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = "."
export_builder.set_survey(survey)
expected_section = \
{
'name': 'childrens_survey',
'elements': [
{
'title': 'geo._geolocation_latitude',
'xpath': 'geo/_geolocation_latitude'
}
]
}
main_section = export_builder.section_by_name('childrens_survey')
match = filter(
lambda x: (expected_section['elements'][0]['xpath']
== x['xpath']), main_section['elements'])[0]
self.assertEqual(
expected_section['elements'][0]['title'], match['title'])
示例7: test_delimiter_replacement_works_existing_fields
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_delimiter_replacement_works_existing_fields(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = "."
export_builder.set_survey(survey)
expected_sections =\
[
{
'name': 'children',
'elements': [
{
'title': 'children.name',
'xpath': 'children/name'
}
]
}
]
children_section = export_builder.section_by_name('children')
self.assertEqual(
children_section['elements'][0]['title'],
expected_sections[0]['elements'][0]['title'])
示例8: test_to_xls_export_respects_custom_field_delimiter
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import GROUP_DELIMITER [as 别名]
def test_to_xls_export_respects_custom_field_delimiter(self):
survey = self._create_childrens_survey()
export_builder = ExportBuilder()
export_builder.GROUP_DELIMITER = ExportBuilder.GROUP_DELIMITER_DOT
export_builder.set_survey(survey)
xls_file = NamedTemporaryFile(suffix=".xls")
filename = xls_file.name
export_builder.to_xls_export(filename, self.data)
xls_file.seek(0)
wb = load_workbook(filename)
# check header columns
main_sheet = wb.get_sheet_by_name("childrens_survey")
expected_column_headers = [
u"name",
u"age",
u"geo.geolocation",
u"geo._geolocation_latitude",
u"geo._geolocation_longitude",
u"geo._geolocation_altitude",
u"geo._geolocation_precision",
u"tel.tel.office",
u"tel.tel.mobile",
u"_id",
u"meta.instanceID",
u"_uuid",
u"_submission_time",
u"_index",
u"_parent_index",
u"_parent_table_name",
u"_tags",
"_notes",
]
column_headers = [c[0].value for c in main_sheet.columns]
self.assertEqual(sorted(column_headers), sorted(expected_column_headers))
xls_file.close()