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


Python ExportBuilder.GROUP_DELIMITER方法代码示例

本文整理汇总了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()
开发者ID:MichaelRoethlin,项目名称:onadata,代码行数:27,代码来源:test_export_builder.py

示例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"])
开发者ID:CharaD7,项目名称:kobocat,代码行数:10,代码来源:test_export_builder.py

示例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"])
开发者ID:CharaD7,项目名称:kobocat,代码行数:14,代码来源:test_export_builder.py

示例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"])
开发者ID:CharaD7,项目名称:kobocat,代码行数:16,代码来源:test_export_builder.py

示例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'])
开发者ID:199212151746,项目名称:onadata,代码行数:22,代码来源:test_export_builder.py

示例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'])
开发者ID:199212151746,项目名称:onadata,代码行数:23,代码来源:test_export_builder.py

示例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'])
开发者ID:199212151746,项目名称:onadata,代码行数:23,代码来源:test_export_builder.py

示例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()
开发者ID:CharaD7,项目名称:kobocat,代码行数:38,代码来源:test_export_builder.py


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