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


Python Stop.import_txt方法代码示例

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


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

示例1: test_import_stops_txt_bom

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_bom(self):
        if PY3:  # pragma: no cover
            text = (BOM_UTF8.decode('utf-8') + """\
stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,\
location_type,parent_station,stop_timezone
FUR_CREEK_RES,FC,Furnace Creek Resort,,36.425288,-117.133162,A,\
http://example.com/fcr,0,FUR_CREEK_STA,
FUR_CREEK_STA,,Furnace Creek Station,"Our Station",36.425288,-117.133162,A,\
http://example.com,1,,America/Los_Angeles
""")
        else:
            text = (BOM_UTF8 + b"""\
stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,\
location_type,parent_station,stop_timezone
FUR_CREEK_RES,FC,Furnace Creek Resort,,36.425288,-117.133162,A,\
http://example.com/fcr,0,FUR_CREEK_STA,
FUR_CREEK_STA,,Furnace Creek Station,"Our Station",36.425288,-117.133162,A,\
http://example.com,1,,America/Los_Angeles
""")
        stops_txt = StringIO(text)
        Stop.import_txt(stops_txt, self.feed)
        self.assertEqual(Stop.objects.count(), 2)
        station = Stop.objects.get(stop_id='FUR_CREEK_STA')
        stop = Stop.objects.get(stop_id='FUR_CREEK_RES')
        self.assertEqual(stop.parent_station, station)
开发者ID:derickl,项目名称:gtfs-server,代码行数:27,代码来源:stop.py

示例2: test_import_stops_txt_duplicate

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_duplicate(self):
        stops_txt = StringIO("""\
stop_id,stop_name,stop_desc,stop_lat,stop_lon
FUR_CREEK_RES,Furnace Creek Resort (Demo),,36.425288,-117.133162
FUR_CREEK_RES,Furnace Creek Resort,,36.42,-117.13
""")
        Stop.import_txt(stops_txt, self.feed)
        stop = Stop.objects.get()
        self.assertEqual(stop.feed, self.feed)
        self.assertEqual(stop.stop_id, 'FUR_CREEK_RES')
        self.assertEqual(stop.name, 'Furnace Creek Resort (Demo)')
开发者ID:derickl,项目名称:gtfs-server,代码行数:13,代码来源:stop.py

示例3: test_import_stops_txt_parent_is_space

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_parent_is_space(self):
        """If parent station is an empty string, then leave unset

        Issue #36
        """
        stops_txt = StringIO("""\
stop_id,stop_name,stop_desc,stop_lat,stop_lon,parent_station
FUR_CREEK_RES,Furnace Creek Resort (Demo),,36.425288,-117.133162," "
""")
        Stop.import_txt(stops_txt, self.feed)
        stop = Stop.objects.get()
        self.assertEqual(stop.parent_station, None)
开发者ID:derickl,项目名称:gtfs-server,代码行数:14,代码来源:stop.py

示例4: test_import_stops_txt_stop_before_station_plus_extra

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_stop_before_station_plus_extra(self):
        stops_txt = StringIO("""\
stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,\
location_type,parent_station,stop_timezone,extra
FUR_CREEK_RES,FC,Furnace Creek Resort,,36.425288,-117.133162,A,\
http://example.com/fcr,0,FUR_CREEK_STA,,a stop
FUR_CREEK_STA,,Furnace Creek Station,"Our Station",36.425288,-117.133162,A,\
http://example.com,1,,America/Los_Angeles,a station
""")
        Stop.import_txt(stops_txt, self.feed)
        self.assertEqual(Stop.objects.count(), 2)
        station = Stop.objects.get(stop_id='FUR_CREEK_STA')
        stop = Stop.objects.get(stop_id='FUR_CREEK_RES')
        self.assertEqual(stop.parent_station, station)
        self.assertEqual(stop.extra_data, {'extra': 'a stop'})
        self.assertEqual(station.extra_data, {'extra': 'a station'})
        expected = {'extra_columns': {'Stop': ['extra']}}
        self.assertEqual(expected, self.feed.meta)
开发者ID:derickl,项目名称:gtfs-server,代码行数:20,代码来源:stop.py

示例5: test_import_stops_txt_maximal

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_maximal(self):
        stops_txt = StringIO("""\
stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,\
location_type,parent_station,stop_timezone,wheelchair_boarding
FUR_CREEK_STA,,Furnace Creek Station,"Our Station",36.425288,-117.133162,A,\
http://example.com,1,,America/Los_Angeles,1
FUR_CREEK_RES,FC,Furnace Creek Resort,,36.425288,-117.133162,A,\
http://example.com/fcr,0,FUR_CREEK_STA,
FEZ_CREEK_STA,,Fez Creek Station,"Our Station",36.425288,-117.133162,A,\
http://example.com,1,,America/Los_Angeles
FEZ_CREEK_RES,FC,Fez Creek Resort,,36.425288,-117.133162,A,\
http://example.com/fcr,0,FEZ_CREEK_STA,
""")
        Stop.import_txt(stops_txt, self.feed)
        self.assertEqual(Stop.objects.count(), 4)

        station = Stop.objects.get(stop_id='FUR_CREEK_STA')
        zone = Zone.objects.get(feed=self.feed, zone_id='A')
        self.assertEqual(station.code, '')
        self.assertEqual(station.name, 'Furnace Creek Station')
        self.assertEqual(station.desc, 'Our Station')
        self.assertEqual(str(station.lat), '36.425288')
        self.assertEqual(str(station.lon), '-117.133162')
        self.assertEqual(station.zone, zone)
        self.assertEqual(station.url, 'http://example.com')
        self.assertEqual(station.location_type, '1')
        self.assertEqual(station.parent_station, None)
        self.assertEqual(station.timezone, 'America/Los_Angeles')
        self.assertEqual(station.wheelchair_boarding, '1')

        stop = Stop.objects.get(stop_id='FUR_CREEK_RES')
        self.assertEqual(stop.code, 'FC')
        self.assertEqual(stop.name, 'Furnace Creek Resort')
        self.assertEqual(stop.desc, '')
        self.assertEqual(str(stop.lat), '36.425288')
        self.assertEqual(str(stop.lon), '-117.133162')
        self.assertEqual(stop.zone, zone)
        self.assertEqual(stop.url, 'http://example.com/fcr')
        self.assertEqual(stop.location_type, '0')
        self.assertEqual(stop.parent_station, station)
        self.assertEqual(stop.timezone, '')

        stop2 = Stop.objects.get(stop_id='FEZ_CREEK_RES')
        self.assertEqual(stop2.parent_station.stop_id, 'FEZ_CREEK_STA')
开发者ID:derickl,项目名称:gtfs-server,代码行数:46,代码来源:stop.py

示例6: test_import_stops_txt_minimal

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_minimal(self):
        stops_txt = StringIO.StringIO("""\
stop_id,stop_name,stop_desc,stop_lat,stop_lon
FUR_CREEK_RES,Furnace Creek Resort (Demo),,36.425288,-117.133162
""")
        Stop.import_txt(stops_txt, self.feed)
        stop = Stop.objects.get()
        self.assertEqual(stop.feed, self.feed)
        self.assertEqual(stop.stop_id, 'FUR_CREEK_RES')
        self.assertEqual(stop.code, '')
        self.assertEqual(stop.name, 'Furnace Creek Resort (Demo)')
        self.assertEqual(stop.desc, '')
        self.assertEqual(str(stop.lat), '36.425288')
        self.assertEqual(str(stop.lon), '-117.133162')
        self.assertEqual(stop.zone, None)
        self.assertEqual(stop.url, '')
        self.assertEqual(stop.location_type, '')
        self.assertEqual(stop.parent_station, None)
        self.assertEqual(stop.timezone, '')
开发者ID:jgissend10,项目名称:django-multi-gtfs,代码行数:21,代码来源:stop.py

示例7: test_import_stops_txt_extra_columns

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_extra_columns(self):
        stops_txt = StringIO("""\
stop_id,stop_name,stop_desc,stop_lat,stop_lon,platform_code
FUR_CREEK_RES,Furnace Creek Resort (Demo),,36.425288,-117.133162,7
""")
        Stop.import_txt(stops_txt, self.feed)
        stop = Stop.objects.get()
        self.assertEqual(stop.feed, self.feed)
        self.assertEqual(stop.stop_id, 'FUR_CREEK_RES')
        self.assertEqual(stop.code, '')
        self.assertEqual(stop.name, 'Furnace Creek Resort (Demo)')
        self.assertEqual(stop.desc, '')
        self.assertEqual(str(stop.lat), '36.425288')
        self.assertEqual(str(stop.lon), '-117.133162')
        self.assertEqual(stop.zone, None)
        self.assertEqual(stop.url, '')
        self.assertEqual(stop.location_type, '')
        self.assertEqual(stop.parent_station, None)
        self.assertEqual(stop.timezone, '')
        self.assertEqual(stop.wheelchair_boarding, '')
        self.assertEqual({'platform_code': '7'}, stop.extra_data)
        expected = {'extra_columns': {'Stop': ['platform_code']}}
        self.assertEqual(expected, self.feed.meta)
开发者ID:derickl,项目名称:gtfs-server,代码行数:25,代码来源:stop.py

示例8: test_import_stops_txt_none

# 需要导入模块: from multigtfs.models import Stop [as 别名]
# 或者: from multigtfs.models.Stop import import_txt [as 别名]
    def test_import_stops_txt_none(self):
        stops_txt = StringIO.StringIO("""\
stop_id,stop_name,stop_desc,stop_lat,stop_lon
""")
        Stop.import_txt(stops_txt, self.feed)
        self.assertFalse(Stop.objects.exists())
开发者ID:jgissend10,项目名称:django-multi-gtfs,代码行数:8,代码来源:stop.py


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