repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._CalculateYLines
def _CalculateYLines(self, dists): """Builds a list with y-coordinates for the horizontal lines in the graph. Args: # One integer for each pair of stations # indicating the approximate distance dists: [0,33,140, ... ,X] Returns: # One integer y-coordinate for each station normalize...
python
def _CalculateYLines(self, dists): """Builds a list with y-coordinates for the horizontal lines in the graph. Args: # One integer for each pair of stations # indicating the approximate distance dists: [0,33,140, ... ,X] Returns: # One integer y-coordinate for each station normalize...
[ "def", "_CalculateYLines", "(", "self", ",", "dists", ")", ":", "tot_dist", "=", "sum", "(", "dists", ")", "if", "tot_dist", ">", "0", ":", "pixel_dist", "=", "[", "float", "(", "d", "*", "(", "self", ".", "_gheight", "-", "20", ")", ")", "/", "t...
Builds a list with y-coordinates for the horizontal lines in the graph. Args: # One integer for each pair of stations # indicating the approximate distance dists: [0,33,140, ... ,X] Returns: # One integer y-coordinate for each station normalized between # 0 and X, where X is the ...
[ "Builds", "a", "list", "with", "y", "-", "coordinates", "for", "the", "horizontal", "lines", "in", "the", "graph", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L236-L257
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._TravelTimes
def _TravelTimes(self,triplist,index=0): """ Calculate distances and plot stops. Uses a timetable to approximate distances between stations Args: # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] # (Optional) Index of Triplist prefered for timetable Calculation inde...
python
def _TravelTimes(self,triplist,index=0): """ Calculate distances and plot stops. Uses a timetable to approximate distances between stations Args: # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] # (Optional) Index of Triplist prefered for timetable Calculation inde...
[ "def", "_TravelTimes", "(", "self", ",", "triplist", ",", "index", "=", "0", ")", ":", "def", "DistanceInTravelTime", "(", "dep_secs", ",", "arr_secs", ")", ":", "t_dist", "=", "arr_secs", "-", "dep_secs", "if", "t_dist", "<", "0", ":", "t_dist", "=", ...
Calculate distances and plot stops. Uses a timetable to approximate distances between stations Args: # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] # (Optional) Index of Triplist prefered for timetable Calculation index: 3 Returns: # One integer for each pai...
[ "Calculate", "distances", "and", "plot", "stops", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L259-L293
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._DrawTrips
def _DrawTrips(self,triplist,colpar=""): """Generates svg polylines for each transit trip. Args: # Class Trip is defined in transitfeed.py [Trip, Trip, ...] Returns: # A string containing a polyline tag for each trip ' <polyline class="T" stroke="#336633" points="433,0 ...' """...
python
def _DrawTrips(self,triplist,colpar=""): """Generates svg polylines for each transit trip. Args: # Class Trip is defined in transitfeed.py [Trip, Trip, ...] Returns: # A string containing a polyline tag for each trip ' <polyline class="T" stroke="#336633" points="433,0 ...' """...
[ "def", "_DrawTrips", "(", "self", ",", "triplist", ",", "colpar", "=", "\"\"", ")", ":", "stations", "=", "[", "]", "if", "not", "self", ".", "_stations", "and", "triplist", ":", "self", ".", "_stations", "=", "self", ".", "_CalculateYLines", "(", "sel...
Generates svg polylines for each transit trip. Args: # Class Trip is defined in transitfeed.py [Trip, Trip, ...] Returns: # A string containing a polyline tag for each trip ' <polyline class="T" stroke="#336633" points="433,0 ...'
[ "Generates", "svg", "polylines", "for", "each", "transit", "trip", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L298-L354
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._Uniform
def _Uniform(self, triplist): """Fallback to assuming uniform distance between stations""" # This should not be neseccary, but we are in fallback mode longest = max([len(t.GetTimeStops()) for t in triplist]) return [100] * longest
python
def _Uniform(self, triplist): """Fallback to assuming uniform distance between stations""" # This should not be neseccary, but we are in fallback mode longest = max([len(t.GetTimeStops()) for t in triplist]) return [100] * longest
[ "def", "_Uniform", "(", "self", ",", "triplist", ")", ":", "# This should not be neseccary, but we are in fallback mode", "longest", "=", "max", "(", "[", "len", "(", "t", ".", "GetTimeStops", "(", ")", ")", "for", "t", "in", "triplist", "]", ")", "return", ...
Fallback to assuming uniform distance between stations
[ "Fallback", "to", "assuming", "uniform", "distance", "between", "stations" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L356-L360
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph._DrawHours
def _DrawHours(self): """Generates svg to show a vertical hour and sub-hour grid Returns: # A string containing a polyline tag for each grid line " <polyline class="FullHour" points="20,0 ..." """ tmpstrs = [] for i in range(0, self._gwidth, self._min_grid): if i % self._hour_grid...
python
def _DrawHours(self): """Generates svg to show a vertical hour and sub-hour grid Returns: # A string containing a polyline tag for each grid line " <polyline class="FullHour" points="20,0 ..." """ tmpstrs = [] for i in range(0, self._gwidth, self._min_grid): if i % self._hour_grid...
[ "def", "_DrawHours", "(", "self", ")", ":", "tmpstrs", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "self", ".", "_gwidth", ",", "self", ".", "_min_grid", ")", ":", "if", "i", "%", "self", ".", "_hour_grid", "==", "0", ":", "tmpstrs",...
Generates svg to show a vertical hour and sub-hour grid Returns: # A string containing a polyline tag for each grid line " <polyline class="FullHour" points="20,0 ..."
[ "Generates", "svg", "to", "show", "a", "vertical", "hour", "and", "sub", "-", "hour", "grid" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L380-L398
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph.AddStationDecoration
def AddStationDecoration(self, index, color="#f00"): """Flushes existing decorations and highlights the given station-line. Args: # Integer, index of stop to be highlighted. index: 4 # An optional string with a html color code color: "#fff" """ tmpstr = str() num_stations = ...
python
def AddStationDecoration(self, index, color="#f00"): """Flushes existing decorations and highlights the given station-line. Args: # Integer, index of stop to be highlighted. index: 4 # An optional string with a html color code color: "#fff" """ tmpstr = str() num_stations = ...
[ "def", "AddStationDecoration", "(", "self", ",", "index", ",", "color", "=", "\"#f00\"", ")", ":", "tmpstr", "=", "str", "(", ")", "num_stations", "=", "len", "(", "self", ".", "_stations", ")", "ind", "=", "int", "(", "index", ")", "if", "self", "."...
Flushes existing decorations and highlights the given station-line. Args: # Integer, index of stop to be highlighted. index: 4 # An optional string with a html color code color: "#fff"
[ "Flushes", "existing", "decorations", "and", "highlights", "the", "given", "station", "-", "line", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L400-L417
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph.AddTripDecoration
def AddTripDecoration(self, triplist, color="#f00"): """Flushes existing decorations and highlights the given trips. Args: # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] # An optional string with a html color code color: "#fff" """ tmpstr = self._DrawTrips...
python
def AddTripDecoration(self, triplist, color="#f00"): """Flushes existing decorations and highlights the given trips. Args: # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] # An optional string with a html color code color: "#fff" """ tmpstr = self._DrawTrips...
[ "def", "AddTripDecoration", "(", "self", ",", "triplist", ",", "color", "=", "\"#f00\"", ")", ":", "tmpstr", "=", "self", ".", "_DrawTrips", "(", "triplist", ",", "color", ")", "self", ".", "_decorators", ".", "append", "(", "tmpstr", ")" ]
Flushes existing decorations and highlights the given trips. Args: # Class Trip is defined in transitfeed.py triplist: [Trip, Trip, ...] # An optional string with a html color code color: "#fff"
[ "Flushes", "existing", "decorations", "and", "highlights", "the", "given", "trips", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L419-L429
train
google/transitfeed
gtfsscheduleviewer/marey_graph.py
MareyGraph.ChangeScaleFactor
def ChangeScaleFactor(self, newfactor): """Changes the zoom of the graph manually. 1.0 is the original canvas size. Args: # float value between 0.0 and 5.0 newfactor: 0.7 """ if float(newfactor) > 0 and float(newfactor) < self._MAX_ZOOM: self._zoomfactor = newfactor
python
def ChangeScaleFactor(self, newfactor): """Changes the zoom of the graph manually. 1.0 is the original canvas size. Args: # float value between 0.0 and 5.0 newfactor: 0.7 """ if float(newfactor) > 0 and float(newfactor) < self._MAX_ZOOM: self._zoomfactor = newfactor
[ "def", "ChangeScaleFactor", "(", "self", ",", "newfactor", ")", ":", "if", "float", "(", "newfactor", ")", ">", "0", "and", "float", "(", "newfactor", ")", "<", "self", ".", "_MAX_ZOOM", ":", "self", ".", "_zoomfactor", "=", "newfactor" ]
Changes the zoom of the graph manually. 1.0 is the original canvas size. Args: # float value between 0.0 and 5.0 newfactor: 0.7
[ "Changes", "the", "zoom", "of", "the", "graph", "manually", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/gtfsscheduleviewer/marey_graph.py#L431-L441
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateFolder
def _CreateFolder(self, parent, name, visible=True, description=None): """Create a KML Folder element. Args: parent: The parent ElementTree.Element instance. name: The folder name as a string. visible: Whether the folder is initially visible or not. description: A description string or ...
python
def _CreateFolder(self, parent, name, visible=True, description=None): """Create a KML Folder element. Args: parent: The parent ElementTree.Element instance. name: The folder name as a string. visible: Whether the folder is initially visible or not. description: A description string or ...
[ "def", "_CreateFolder", "(", "self", ",", "parent", ",", "name", ",", "visible", "=", "True", ",", "description", "=", "None", ")", ":", "folder", "=", "ET", ".", "SubElement", "(", "parent", ",", "'Folder'", ")", "name_tag", "=", "ET", ".", "SubElemen...
Create a KML Folder element. Args: parent: The parent ElementTree.Element instance. name: The folder name as a string. visible: Whether the folder is initially visible or not. description: A description string or None. Returns: The folder ElementTree.Element instance.
[ "Create", "a", "KML", "Folder", "element", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L132-L153
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateStyleForRoute
def _CreateStyleForRoute(self, doc, route): """Create a KML Style element for the route. The style sets the line colour if the route colour is specified. The line thickness is set depending on the vehicle type. Args: doc: The KML Document ElementTree.Element instance. route: The transitfee...
python
def _CreateStyleForRoute(self, doc, route): """Create a KML Style element for the route. The style sets the line colour if the route colour is specified. The line thickness is set depending on the vehicle type. Args: doc: The KML Document ElementTree.Element instance. route: The transitfee...
[ "def", "_CreateStyleForRoute", "(", "self", ",", "doc", ",", "route", ")", ":", "style_id", "=", "'route_%s'", "%", "route", ".", "route_id", "style", "=", "ET", ".", "SubElement", "(", "doc", ",", "'Style'", ",", "{", "'id'", ":", "style_id", "}", ")"...
Create a KML Style element for the route. The style sets the line colour if the route colour is specified. The line thickness is set depending on the vehicle type. Args: doc: The KML Document ElementTree.Element instance. route: The transitfeed.Route to create the style for. Returns: ...
[ "Create", "a", "KML", "Style", "element", "for", "the", "route", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L155-L183
train
google/transitfeed
kmlwriter.py
KMLWriter._CreatePlacemark
def _CreatePlacemark(self, parent, name, style_id=None, visible=True, description=None): """Create a KML Placemark element. Args: parent: The parent ElementTree.Element instance. name: The placemark name as a string. style_id: If not None, the id of a style to use for t...
python
def _CreatePlacemark(self, parent, name, style_id=None, visible=True, description=None): """Create a KML Placemark element. Args: parent: The parent ElementTree.Element instance. name: The placemark name as a string. style_id: If not None, the id of a style to use for t...
[ "def", "_CreatePlacemark", "(", "self", ",", "parent", ",", "name", ",", "style_id", "=", "None", ",", "visible", "=", "True", ",", "description", "=", "None", ")", ":", "placemark", "=", "ET", ".", "SubElement", "(", "parent", ",", "'Placemark'", ")", ...
Create a KML Placemark element. Args: parent: The parent ElementTree.Element instance. name: The placemark name as a string. style_id: If not None, the id of a style to use for the placemark. visible: Whether the placemark is initially visible or not. description: A description string...
[ "Create", "a", "KML", "Placemark", "element", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L185-L211
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateLineString
def _CreateLineString(self, parent, coordinate_list): """Create a KML LineString element. The points of the string are given in coordinate_list. Every element of coordinate_list should be one of a tuple (longitude, latitude) or a tuple (longitude, latitude, altitude). Args: parent: The paren...
python
def _CreateLineString(self, parent, coordinate_list): """Create a KML LineString element. The points of the string are given in coordinate_list. Every element of coordinate_list should be one of a tuple (longitude, latitude) or a tuple (longitude, latitude, altitude). Args: parent: The paren...
[ "def", "_CreateLineString", "(", "self", ",", "parent", ",", "coordinate_list", ")", ":", "if", "not", "coordinate_list", ":", "return", "None", "linestring", "=", "ET", ".", "SubElement", "(", "parent", ",", "'LineString'", ")", "tessellate", "=", "ET", "."...
Create a KML LineString element. The points of the string are given in coordinate_list. Every element of coordinate_list should be one of a tuple (longitude, latitude) or a tuple (longitude, latitude, altitude). Args: parent: The parent ElementTree.Element instance. coordinate_list: The li...
[ "Create", "a", "KML", "LineString", "element", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L213-L242
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateLineStringForShape
def _CreateLineStringForShape(self, parent, shape): """Create a KML LineString using coordinates from a shape. Args: parent: The parent ElementTree.Element instance. shape: The transitfeed.Shape instance. Returns: The LineString ElementTree.Element instance or None if coordinate_list is ...
python
def _CreateLineStringForShape(self, parent, shape): """Create a KML LineString using coordinates from a shape. Args: parent: The parent ElementTree.Element instance. shape: The transitfeed.Shape instance. Returns: The LineString ElementTree.Element instance or None if coordinate_list is ...
[ "def", "_CreateLineStringForShape", "(", "self", ",", "parent", ",", "shape", ")", ":", "coordinate_list", "=", "[", "(", "longitude", ",", "latitude", ")", "for", "(", "latitude", ",", "longitude", ",", "distance", ")", "in", "shape", ".", "points", "]", ...
Create a KML LineString using coordinates from a shape. Args: parent: The parent ElementTree.Element instance. shape: The transitfeed.Shape instance. Returns: The LineString ElementTree.Element instance or None if coordinate_list is empty.
[ "Create", "a", "KML", "LineString", "using", "coordinates", "from", "a", "shape", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L244-L257
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateStopsFolder
def _CreateStopsFolder(self, schedule, doc): """Create a KML Folder containing placemarks for each stop in the schedule. If there are no stops in the schedule then no folder is created. Args: schedule: The transitfeed.Schedule instance. doc: The KML Document ElementTree.Element instance. ...
python
def _CreateStopsFolder(self, schedule, doc): """Create a KML Folder containing placemarks for each stop in the schedule. If there are no stops in the schedule then no folder is created. Args: schedule: The transitfeed.Schedule instance. doc: The KML Document ElementTree.Element instance. ...
[ "def", "_CreateStopsFolder", "(", "self", ",", "schedule", ",", "doc", ")", ":", "if", "not", "schedule", ".", "GetStopList", "(", ")", ":", "return", "None", "stop_folder", "=", "self", ".", "_CreateFolder", "(", "doc", ",", "'Stops'", ")", "stop_folder_s...
Create a KML Folder containing placemarks for each stop in the schedule. If there are no stops in the schedule then no folder is created. Args: schedule: The transitfeed.Schedule instance. doc: The KML Document ElementTree.Element instance. Returns: The Folder ElementTree.Element instan...
[ "Create", "a", "KML", "Folder", "containing", "placemarks", "for", "each", "stop", "in", "the", "schedule", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L259-L291
train
google/transitfeed
kmlwriter.py
KMLWriter._StopFolderSelectionMethod
def _StopFolderSelectionMethod(self, stop_folder): """Create a method to determine which KML folder a stop should go in. Args: stop_folder: the parent folder element for all stops. Returns: A function that should accept a Stop argument and return a tuple of (stop KML folder, pathways KML...
python
def _StopFolderSelectionMethod(self, stop_folder): """Create a method to determine which KML folder a stop should go in. Args: stop_folder: the parent folder element for all stops. Returns: A function that should accept a Stop argument and return a tuple of (stop KML folder, pathways KML...
[ "def", "_StopFolderSelectionMethod", "(", "self", ",", "stop_folder", ")", ":", "if", "not", "self", ".", "show_stop_hierarchy", ":", "return", "lambda", "stop", ":", "(", "stop_folder", ",", "None", ")", "# Create the various sub-folders for showing the stop hierarchy"...
Create a method to determine which KML folder a stop should go in. Args: stop_folder: the parent folder element for all stops. Returns: A function that should accept a Stop argument and return a tuple of (stop KML folder, pathways KML folder). Given a Stop, we need to determine which fo...
[ "Create", "a", "method", "to", "determine", "which", "KML", "folder", "a", "stop", "should", "go", "in", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L293-L332
train
google/transitfeed
kmlwriter.py
KMLWriter._StopStyleSelectionMethod
def _StopStyleSelectionMethod(self, doc): """Create a method to determine which style to apply to a stop placemark. Args: doc: the KML document. Returns: A function that should accept a Stop argument and return a tuple of (stop placemark style id, pathway placemark style id). Either sty...
python
def _StopStyleSelectionMethod(self, doc): """Create a method to determine which style to apply to a stop placemark. Args: doc: the KML document. Returns: A function that should accept a Stop argument and return a tuple of (stop placemark style id, pathway placemark style id). Either sty...
[ "def", "_StopStyleSelectionMethod", "(", "self", ",", "doc", ")", ":", "if", "not", "self", ".", "show_stop_hierarchy", ":", "return", "lambda", "stop", ":", "(", "None", ",", "None", ")", "# Create the various styles for showing the stop hierarchy", "self", ".", ...
Create a method to determine which style to apply to a stop placemark. Args: doc: the KML document. Returns: A function that should accept a Stop argument and return a tuple of (stop placemark style id, pathway placemark style id). Either style id can be None, indicating no style shou...
[ "Create", "a", "method", "to", "determine", "which", "style", "to", "apply", "to", "a", "stop", "placemark", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L334-L383
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateRoutePatternsFolder
def _CreateRoutePatternsFolder(self, parent, route, style_id=None, visible=True): """Create a KML Folder containing placemarks for each pattern in the route. A pattern is a sequence of stops used by one of the trips in the route. If there are not patterns for the route t...
python
def _CreateRoutePatternsFolder(self, parent, route, style_id=None, visible=True): """Create a KML Folder containing placemarks for each pattern in the route. A pattern is a sequence of stops used by one of the trips in the route. If there are not patterns for the route t...
[ "def", "_CreateRoutePatternsFolder", "(", "self", ",", "parent", ",", "route", ",", "style_id", "=", "None", ",", "visible", "=", "True", ")", ":", "pattern_id_to_trips", "=", "route", ".", "GetPatternIdTripDict", "(", ")", "if", "not", "pattern_id_to_trips", ...
Create a KML Folder containing placemarks for each pattern in the route. A pattern is a sequence of stops used by one of the trips in the route. If there are not patterns for the route then no folder is created and None is returned. Args: parent: The parent ElementTree.Element instance. r...
[ "Create", "a", "KML", "Folder", "containing", "placemarks", "for", "each", "pattern", "in", "the", "route", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L438-L475
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateRouteShapesFolder
def _CreateRouteShapesFolder(self, schedule, parent, route, style_id=None, visible=True): """Create a KML Folder for the shapes of a route. The folder contains a placemark for each shape referenced by a trip in the route. If there are no such shapes, no folder is created and ...
python
def _CreateRouteShapesFolder(self, schedule, parent, route, style_id=None, visible=True): """Create a KML Folder for the shapes of a route. The folder contains a placemark for each shape referenced by a trip in the route. If there are no such shapes, no folder is created and ...
[ "def", "_CreateRouteShapesFolder", "(", "self", ",", "schedule", ",", "parent", ",", "route", ",", "style_id", "=", "None", ",", "visible", "=", "True", ")", ":", "shape_id_to_trips", "=", "{", "}", "for", "trip", "in", "route", ".", "trips", ":", "if", ...
Create a KML Folder for the shapes of a route. The folder contains a placemark for each shape referenced by a trip in the route. If there are no such shapes, no folder is created and None is returned. Args: schedule: The transitfeed.Schedule instance. parent: The parent ElementTree.Element...
[ "Create", "a", "KML", "Folder", "for", "the", "shapes", "of", "a", "route", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L477-L515
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateRouteTripsFolder
def _CreateRouteTripsFolder(self, parent, route, style_id=None, schedule=None): """Create a KML Folder containing all the trips in the route. The folder contains a placemark for each of these trips. If there are no trips in the route, no folder is created and None is returned. Args: parent: The ...
python
def _CreateRouteTripsFolder(self, parent, route, style_id=None, schedule=None): """Create a KML Folder containing all the trips in the route. The folder contains a placemark for each of these trips. If there are no trips in the route, no folder is created and None is returned. Args: parent: The ...
[ "def", "_CreateRouteTripsFolder", "(", "self", ",", "parent", ",", "route", ",", "style_id", "=", "None", ",", "schedule", "=", "None", ")", ":", "if", "not", "route", ".", "trips", ":", "return", "None", "trips", "=", "list", "(", "route", ".", "trips...
Create a KML Folder containing all the trips in the route. The folder contains a placemark for each of these trips. If there are no trips in the route, no folder is created and None is returned. Args: parent: The parent ElementTree.Element instance. route: The transitfeed.Route instance. ...
[ "Create", "a", "KML", "Folder", "containing", "all", "the", "trips", "in", "the", "route", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L517-L560
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateRoutesFolder
def _CreateRoutesFolder(self, schedule, doc, route_type=None): """Create a KML Folder containing routes in a schedule. The folder contains a subfolder for each route in the schedule of type route_type. If route_type is None, then all routes are selected. Each subfolder contains a flattened graph placem...
python
def _CreateRoutesFolder(self, schedule, doc, route_type=None): """Create a KML Folder containing routes in a schedule. The folder contains a subfolder for each route in the schedule of type route_type. If route_type is None, then all routes are selected. Each subfolder contains a flattened graph placem...
[ "def", "_CreateRoutesFolder", "(", "self", ",", "schedule", ",", "doc", ",", "route_type", "=", "None", ")", ":", "def", "GetRouteName", "(", "route", ")", ":", "\"\"\"Return a placemark name for the route.\n\n Args:\n route: The transitfeed.Route instance.\n\n ...
Create a KML Folder containing routes in a schedule. The folder contains a subfolder for each route in the schedule of type route_type. If route_type is None, then all routes are selected. Each subfolder contains a flattened graph placemark, a route shapes placemark and, if show_trips is True, a subfol...
[ "Create", "a", "KML", "Folder", "containing", "routes", "in", "a", "schedule", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L562-L648
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateShapesFolder
def _CreateShapesFolder(self, schedule, doc): """Create a KML Folder containing all the shapes in a schedule. The folder contains a placemark for each shape. If there are no shapes in the schedule then the folder is not created and None is returned. Args: schedule: The transitfeed.Schedule insta...
python
def _CreateShapesFolder(self, schedule, doc): """Create a KML Folder containing all the shapes in a schedule. The folder contains a placemark for each shape. If there are no shapes in the schedule then the folder is not created and None is returned. Args: schedule: The transitfeed.Schedule insta...
[ "def", "_CreateShapesFolder", "(", "self", ",", "schedule", ",", "doc", ")", ":", "if", "not", "schedule", ".", "GetShapeList", "(", ")", ":", "return", "None", "shapes_folder", "=", "self", ".", "_CreateFolder", "(", "doc", ",", "'Shapes'", ")", "shapes",...
Create a KML Folder containing all the shapes in a schedule. The folder contains a placemark for each shape. If there are no shapes in the schedule then the folder is not created and None is returned. Args: schedule: The transitfeed.Schedule instance. doc: The KML Document ElementTree.Element ...
[ "Create", "a", "KML", "Folder", "containing", "all", "the", "shapes", "in", "a", "schedule", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L650-L673
train
google/transitfeed
kmlwriter.py
KMLWriter._CreateShapePointFolder
def _CreateShapePointFolder(self, shapes_folder, shape): """Create a KML Folder containing all the shape points in a shape. The folder contains placemarks for each shapepoint. Args: shapes_folder: A KML Shape Folder ElementTree.Element instance shape: The shape to plot. Returns: The...
python
def _CreateShapePointFolder(self, shapes_folder, shape): """Create a KML Folder containing all the shape points in a shape. The folder contains placemarks for each shapepoint. Args: shapes_folder: A KML Shape Folder ElementTree.Element instance shape: The shape to plot. Returns: The...
[ "def", "_CreateShapePointFolder", "(", "self", ",", "shapes_folder", ",", "shape", ")", ":", "folder_name", "=", "shape", ".", "shape_id", "+", "' Shape Points'", "folder", "=", "self", ".", "_CreateFolder", "(", "shapes_folder", ",", "folder_name", ",", "visibl...
Create a KML Folder containing all the shape points in a shape. The folder contains placemarks for each shapepoint. Args: shapes_folder: A KML Shape Folder ElementTree.Element instance shape: The shape to plot. Returns: The Folder ElementTree.Element instance or None.
[ "Create", "a", "KML", "Folder", "containing", "all", "the", "shape", "points", "in", "a", "shape", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L675-L695
train
google/transitfeed
kmlwriter.py
KMLWriter.Write
def Write(self, schedule, output_file): """Writes out a feed as KML. Args: schedule: A transitfeed.Schedule object containing the feed to write. output_file: The name of the output KML file, or file object to use. """ # Generate the DOM to write root = ET.Element('kml') root.attrib[...
python
def Write(self, schedule, output_file): """Writes out a feed as KML. Args: schedule: A transitfeed.Schedule object containing the feed to write. output_file: The name of the output KML file, or file object to use. """ # Generate the DOM to write root = ET.Element('kml') root.attrib[...
[ "def", "Write", "(", "self", ",", "schedule", ",", "output_file", ")", ":", "# Generate the DOM to write", "root", "=", "ET", ".", "Element", "(", "'kml'", ")", "root", ".", "attrib", "[", "'xmlns'", "]", "=", "'http://earth.google.com/kml/2.1'", "doc", "=", ...
Writes out a feed as KML. Args: schedule: A transitfeed.Schedule object containing the feed to write. output_file: The name of the output KML file, or file object to use.
[ "Writes", "out", "a", "feed", "as", "KML", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L697-L732
train
google/transitfeed
feedvalidator.py
RunValidationOutputFromOptions
def RunValidationOutputFromOptions(feed, options): """Validate feed, output results per options and return an exit code.""" if options.output.upper() == "CONSOLE": return RunValidationOutputToConsole(feed, options) else: return RunValidationOutputToFilename(feed, options, options.output)
python
def RunValidationOutputFromOptions(feed, options): """Validate feed, output results per options and return an exit code.""" if options.output.upper() == "CONSOLE": return RunValidationOutputToConsole(feed, options) else: return RunValidationOutputToFilename(feed, options, options.output)
[ "def", "RunValidationOutputFromOptions", "(", "feed", ",", "options", ")", ":", "if", "options", ".", "output", ".", "upper", "(", ")", "==", "\"CONSOLE\"", ":", "return", "RunValidationOutputToConsole", "(", "feed", ",", "options", ")", "else", ":", "return",...
Validate feed, output results per options and return an exit code.
[ "Validate", "feed", "output", "results", "per", "options", "and", "return", "an", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L503-L508
train
google/transitfeed
feedvalidator.py
RunValidationOutputToFilename
def RunValidationOutputToFilename(feed, options, output_filename): """Validate feed, save HTML at output_filename and return an exit code.""" try: output_file = open(output_filename, 'w') exit_code = RunValidationOutputToFile(feed, options, output_file) output_file.close() except IOError as e: pri...
python
def RunValidationOutputToFilename(feed, options, output_filename): """Validate feed, save HTML at output_filename and return an exit code.""" try: output_file = open(output_filename, 'w') exit_code = RunValidationOutputToFile(feed, options, output_file) output_file.close() except IOError as e: pri...
[ "def", "RunValidationOutputToFilename", "(", "feed", ",", "options", ",", "output_filename", ")", ":", "try", ":", "output_file", "=", "open", "(", "output_filename", ",", "'w'", ")", "exit_code", "=", "RunValidationOutputToFile", "(", "feed", ",", "options", ",...
Validate feed, save HTML at output_filename and return an exit code.
[ "Validate", "feed", "save", "HTML", "at", "output_filename", "and", "return", "an", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L511-L525
train
google/transitfeed
feedvalidator.py
RunValidationOutputToFile
def RunValidationOutputToFile(feed, options, output_file): """Validate feed, write HTML to output_file and return an exit code.""" accumulator = HTMLCountingProblemAccumulator(options.limit_per_type, options.error_types_ignore_list) problems = transitfeed.ProblemRepo...
python
def RunValidationOutputToFile(feed, options, output_file): """Validate feed, write HTML to output_file and return an exit code.""" accumulator = HTMLCountingProblemAccumulator(options.limit_per_type, options.error_types_ignore_list) problems = transitfeed.ProblemRepo...
[ "def", "RunValidationOutputToFile", "(", "feed", ",", "options", ",", "output_file", ")", ":", "accumulator", "=", "HTMLCountingProblemAccumulator", "(", "options", ".", "limit_per_type", ",", "options", ".", "error_types_ignore_list", ")", "problems", "=", "transitfe...
Validate feed, write HTML to output_file and return an exit code.
[ "Validate", "feed", "write", "HTML", "to", "output_file", "and", "return", "an", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L528-L539
train
google/transitfeed
feedvalidator.py
RunValidationOutputToConsole
def RunValidationOutputToConsole(feed, options): """Validate feed, print reports and return an exit code.""" accumulator = CountingConsoleProblemAccumulator( options.error_types_ignore_list) problems = transitfeed.ProblemReporter(accumulator) _, exit_code = RunValidation(feed, options, problems) return ...
python
def RunValidationOutputToConsole(feed, options): """Validate feed, print reports and return an exit code.""" accumulator = CountingConsoleProblemAccumulator( options.error_types_ignore_list) problems = transitfeed.ProblemReporter(accumulator) _, exit_code = RunValidation(feed, options, problems) return ...
[ "def", "RunValidationOutputToConsole", "(", "feed", ",", "options", ")", ":", "accumulator", "=", "CountingConsoleProblemAccumulator", "(", "options", ".", "error_types_ignore_list", ")", "problems", "=", "transitfeed", ".", "ProblemReporter", "(", "accumulator", ")", ...
Validate feed, print reports and return an exit code.
[ "Validate", "feed", "print", "reports", "and", "return", "an", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L542-L548
train
google/transitfeed
feedvalidator.py
RunValidation
def RunValidation(feed, options, problems): """Validate feed, returning the loaded Schedule and exit code. Args: feed: GTFS file, either path of the file as a string or a file object options: options object returned by optparse problems: transitfeed.ProblemReporter instance Returns: a transitfee...
python
def RunValidation(feed, options, problems): """Validate feed, returning the loaded Schedule and exit code. Args: feed: GTFS file, either path of the file as a string or a file object options: options object returned by optparse problems: transitfeed.ProblemReporter instance Returns: a transitfee...
[ "def", "RunValidation", "(", "feed", ",", "options", ",", "problems", ")", ":", "util", ".", "CheckVersion", "(", "problems", ",", "options", ".", "latest_version", ")", "# TODO: Add tests for this flag in testfeedvalidator.py", "if", "options", ".", "extension", ":...
Validate feed, returning the loaded Schedule and exit code. Args: feed: GTFS file, either path of the file as a string or a file object options: options object returned by optparse problems: transitfeed.ProblemReporter instance Returns: a transitfeed.Schedule object, exit code and plain text strin...
[ "Validate", "feed", "returning", "the", "loaded", "Schedule", "and", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L551-L605
train
google/transitfeed
feedvalidator.py
RunValidationFromOptions
def RunValidationFromOptions(feed, options): """Validate feed, run in profiler if in options, and return an exit code.""" if options.performance: return ProfileRunValidationOutputFromOptions(feed, options) else: return RunValidationOutputFromOptions(feed, options)
python
def RunValidationFromOptions(feed, options): """Validate feed, run in profiler if in options, and return an exit code.""" if options.performance: return ProfileRunValidationOutputFromOptions(feed, options) else: return RunValidationOutputFromOptions(feed, options)
[ "def", "RunValidationFromOptions", "(", "feed", ",", "options", ")", ":", "if", "options", ".", "performance", ":", "return", "ProfileRunValidationOutputFromOptions", "(", "feed", ",", "options", ")", "else", ":", "return", "RunValidationOutputFromOptions", "(", "fe...
Validate feed, run in profiler if in options, and return an exit code.
[ "Validate", "feed", "run", "in", "profiler", "if", "in", "options", "and", "return", "an", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L700-L705
train
google/transitfeed
feedvalidator.py
ProfileRunValidationOutputFromOptions
def ProfileRunValidationOutputFromOptions(feed, options): """Run RunValidationOutputFromOptions, print profile and return exit code.""" import cProfile import pstats # runctx will modify a dict, but not locals(). We need a way to get rv back. locals_for_exec = locals() cProfile.runctx('rv = RunValidationOut...
python
def ProfileRunValidationOutputFromOptions(feed, options): """Run RunValidationOutputFromOptions, print profile and return exit code.""" import cProfile import pstats # runctx will modify a dict, but not locals(). We need a way to get rv back. locals_for_exec = locals() cProfile.runctx('rv = RunValidationOut...
[ "def", "ProfileRunValidationOutputFromOptions", "(", "feed", ",", "options", ")", ":", "import", "cProfile", "import", "pstats", "# runctx will modify a dict, but not locals(). We need a way to get rv back.", "locals_for_exec", "=", "locals", "(", ")", "cProfile", ".", "runct...
Run RunValidationOutputFromOptions, print profile and return exit code.
[ "Run", "RunValidationOutputFromOptions", "print", "profile", "and", "return", "exit", "code", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L708-L762
train
google/transitfeed
feedvalidator.py
HTMLCountingProblemAccumulator.FormatType
def FormatType(self, level_name, class_problist): """Write the HTML dumping all problems of one type. Args: level_name: string such as "Error" or "Warning" class_problist: sequence of tuples (class name, BoundedProblemList object) Returns: HTML in a string """ class_pro...
python
def FormatType(self, level_name, class_problist): """Write the HTML dumping all problems of one type. Args: level_name: string such as "Error" or "Warning" class_problist: sequence of tuples (class name, BoundedProblemList object) Returns: HTML in a string """ class_pro...
[ "def", "FormatType", "(", "self", ",", "level_name", ",", "class_problist", ")", ":", "class_problist", ".", "sort", "(", ")", "output", "=", "[", "]", "for", "classname", ",", "problist", "in", "class_problist", ":", "output", ".", "append", "(", "'<h4 cl...
Write the HTML dumping all problems of one type. Args: level_name: string such as "Error" or "Warning" class_problist: sequence of tuples (class name, BoundedProblemList object) Returns: HTML in a string
[ "Write", "the", "HTML", "dumping", "all", "problems", "of", "one", "type", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L254-L276
train
google/transitfeed
feedvalidator.py
HTMLCountingProblemAccumulator.FormatTypeSummaryTable
def FormatTypeSummaryTable(self, level_name, name_to_problist): """Return an HTML table listing the number of problems by class name. Args: level_name: string such as "Error" or "Warning" name_to_problist: dict mapping class name to an BoundedProblemList object Returns: HTML in a string ...
python
def FormatTypeSummaryTable(self, level_name, name_to_problist): """Return an HTML table listing the number of problems by class name. Args: level_name: string such as "Error" or "Warning" name_to_problist: dict mapping class name to an BoundedProblemList object Returns: HTML in a string ...
[ "def", "FormatTypeSummaryTable", "(", "self", ",", "level_name", ",", "name_to_problist", ")", ":", "output", "=", "[", "]", "output", ".", "append", "(", "'<table>'", ")", "for", "classname", "in", "sorted", "(", "name_to_problist", ".", "keys", "(", ")", ...
Return an HTML table listing the number of problems by class name. Args: level_name: string such as "Error" or "Warning" name_to_problist: dict mapping class name to an BoundedProblemList object Returns: HTML in a string
[ "Return", "an", "HTML", "table", "listing", "the", "number", "of", "problems", "by", "class", "name", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L278-L296
train
google/transitfeed
feedvalidator.py
HTMLCountingProblemAccumulator.FormatException
def FormatException(self, e, output): """Append HTML version of e to list output.""" d = e.GetDictToFormat() for k in ('file_name', 'feedname', 'column_name'): if k in d.keys(): d[k] = '<code>%s</code>' % d[k] if 'url' in d.keys(): d['url'] = '<a href="%(url)s">%(url)s</a>' % d ...
python
def FormatException(self, e, output): """Append HTML version of e to list output.""" d = e.GetDictToFormat() for k in ('file_name', 'feedname', 'column_name'): if k in d.keys(): d[k] = '<code>%s</code>' % d[k] if 'url' in d.keys(): d['url'] = '<a href="%(url)s">%(url)s</a>' % d ...
[ "def", "FormatException", "(", "self", ",", "e", ",", "output", ")", ":", "d", "=", "e", ".", "GetDictToFormat", "(", ")", "for", "k", "in", "(", "'file_name'", ",", "'feedname'", ",", "'column_name'", ")", ":", "if", "k", "in", "d", ".", "keys", "...
Append HTML version of e to list output.
[ "Append", "HTML", "version", "of", "e", "to", "list", "output", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/feedvalidator.py#L298-L339
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.GetDateRange
def GetDateRange(self): """Return the range over which this ServicePeriod is valid. The range includes exception dates that add service outside of (start_date, end_date), but doesn't shrink the range if exception dates take away service at the edges of the range. Returns: A tuple of "YYYYMMD...
python
def GetDateRange(self): """Return the range over which this ServicePeriod is valid. The range includes exception dates that add service outside of (start_date, end_date), but doesn't shrink the range if exception dates take away service at the edges of the range. Returns: A tuple of "YYYYMMD...
[ "def", "GetDateRange", "(", "self", ")", ":", "start", "=", "self", ".", "start_date", "end", "=", "self", ".", "end_date", "for", "date", ",", "(", "exception_type", ",", "_", ")", "in", "self", ".", "date_exceptions", ".", "items", "(", ")", ":", "...
Return the range over which this ServicePeriod is valid. The range includes exception dates that add service outside of (start_date, end_date), but doesn't shrink the range if exception dates take away service at the edges of the range. Returns: A tuple of "YYYYMMDD" strings, (start date, end da...
[ "Return", "the", "range", "over", "which", "this", "ServicePeriod", "is", "valid", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L78-L104
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.GetCalendarFieldValuesTuple
def GetCalendarFieldValuesTuple(self): """Return the tuple of calendar.txt values or None if this ServicePeriod should not be in calendar.txt .""" if self.start_date and self.end_date: return [getattr(self, fn) for fn in self._FIELD_NAMES]
python
def GetCalendarFieldValuesTuple(self): """Return the tuple of calendar.txt values or None if this ServicePeriod should not be in calendar.txt .""" if self.start_date and self.end_date: return [getattr(self, fn) for fn in self._FIELD_NAMES]
[ "def", "GetCalendarFieldValuesTuple", "(", "self", ")", ":", "if", "self", ".", "start_date", "and", "self", ".", "end_date", ":", "return", "[", "getattr", "(", "self", ",", "fn", ")", "for", "fn", "in", "self", ".", "_FIELD_NAMES", "]" ]
Return the tuple of calendar.txt values or None if this ServicePeriod should not be in calendar.txt .
[ "Return", "the", "tuple", "of", "calendar", ".", "txt", "values", "or", "None", "if", "this", "ServicePeriod", "should", "not", "be", "in", "calendar", ".", "txt", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L106-L110
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.GenerateCalendarDatesFieldValuesTuples
def GenerateCalendarDatesFieldValuesTuples(self): """Generates tuples of calendar_dates.txt values. Yield zero tuples if this ServicePeriod should not be in calendar_dates.txt .""" for date, (exception_type, _) in self.date_exceptions.items(): yield (self.service_id, date, unicode(exception_type))
python
def GenerateCalendarDatesFieldValuesTuples(self): """Generates tuples of calendar_dates.txt values. Yield zero tuples if this ServicePeriod should not be in calendar_dates.txt .""" for date, (exception_type, _) in self.date_exceptions.items(): yield (self.service_id, date, unicode(exception_type))
[ "def", "GenerateCalendarDatesFieldValuesTuples", "(", "self", ")", ":", "for", "date", ",", "(", "exception_type", ",", "_", ")", "in", "self", ".", "date_exceptions", ".", "items", "(", ")", ":", "yield", "(", "self", ".", "service_id", ",", "date", ",", ...
Generates tuples of calendar_dates.txt values. Yield zero tuples if this ServicePeriod should not be in calendar_dates.txt .
[ "Generates", "tuples", "of", "calendar_dates", ".", "txt", "values", ".", "Yield", "zero", "tuples", "if", "this", "ServicePeriod", "should", "not", "be", "in", "calendar_dates", ".", "txt", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L112-L116
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.GetCalendarDatesFieldValuesTuples
def GetCalendarDatesFieldValuesTuples(self): """Return a list of date execeptions""" result = [] for date_tuple in self.GenerateCalendarDatesFieldValuesTuples(): result.append(date_tuple) result.sort() # helps with __eq__ return result
python
def GetCalendarDatesFieldValuesTuples(self): """Return a list of date execeptions""" result = [] for date_tuple in self.GenerateCalendarDatesFieldValuesTuples(): result.append(date_tuple) result.sort() # helps with __eq__ return result
[ "def", "GetCalendarDatesFieldValuesTuples", "(", "self", ")", ":", "result", "=", "[", "]", "for", "date_tuple", "in", "self", ".", "GenerateCalendarDatesFieldValuesTuples", "(", ")", ":", "result", ".", "append", "(", "date_tuple", ")", "result", ".", "sort", ...
Return a list of date execeptions
[ "Return", "a", "list", "of", "date", "execeptions" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L118-L124
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.HasDateExceptionOn
def HasDateExceptionOn(self, date, exception_type=_EXCEPTION_TYPE_ADD): """Test if this service period has a date exception of the given type. Args: date: a string of form "YYYYMMDD" exception_type: the exception type the date should have. Defaults to _EXCEPTION_TYPE_ADD ...
python
def HasDateExceptionOn(self, date, exception_type=_EXCEPTION_TYPE_ADD): """Test if this service period has a date exception of the given type. Args: date: a string of form "YYYYMMDD" exception_type: the exception type the date should have. Defaults to _EXCEPTION_TYPE_ADD ...
[ "def", "HasDateExceptionOn", "(", "self", ",", "date", ",", "exception_type", "=", "_EXCEPTION_TYPE_ADD", ")", ":", "if", "date", "in", "self", ".", "date_exceptions", ":", "return", "exception_type", "==", "self", ".", "date_exceptions", "[", "date", "]", "["...
Test if this service period has a date exception of the given type. Args: date: a string of form "YYYYMMDD" exception_type: the exception type the date should have. Defaults to _EXCEPTION_TYPE_ADD Returns: True iff this service has service exception of specified type at...
[ "Test", "if", "this", "service", "period", "has", "a", "date", "exception", "of", "the", "given", "type", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L177-L190
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.IsActiveOn
def IsActiveOn(self, date, date_object=None): """Test if this service period is active on a date. Args: date: a string of form "YYYYMMDD" date_object: a date object representing the same date as date. This parameter is optional, and present only for performance ...
python
def IsActiveOn(self, date, date_object=None): """Test if this service period is active on a date. Args: date: a string of form "YYYYMMDD" date_object: a date object representing the same date as date. This parameter is optional, and present only for performance ...
[ "def", "IsActiveOn", "(", "self", ",", "date", ",", "date_object", "=", "None", ")", ":", "if", "date", "in", "self", ".", "date_exceptions", ":", "exception_type", ",", "_", "=", "self", ".", "date_exceptions", "[", "date", "]", "if", "exception_type", ...
Test if this service period is active on a date. Args: date: a string of form "YYYYMMDD" date_object: a date object representing the same date as date. This parameter is optional, and present only for performance reasons. If the caller constructs...
[ "Test", "if", "this", "service", "period", "is", "active", "on", "a", "date", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L192-L218
train
google/transitfeed
transitfeed/serviceperiod.py
ServicePeriod.ActiveDates
def ActiveDates(self): """Return dates this service period is active as a list of "YYYYMMDD".""" (earliest, latest) = self.GetDateRange() if earliest is None: return [] dates = [] date_it = util.DateStringToDateObject(earliest) date_end = util.DateStringToDateObject(latest) delta = dat...
python
def ActiveDates(self): """Return dates this service period is active as a list of "YYYYMMDD".""" (earliest, latest) = self.GetDateRange() if earliest is None: return [] dates = [] date_it = util.DateStringToDateObject(earliest) date_end = util.DateStringToDateObject(latest) delta = dat...
[ "def", "ActiveDates", "(", "self", ")", ":", "(", "earliest", ",", "latest", ")", "=", "self", ".", "GetDateRange", "(", ")", "if", "earliest", "is", "None", ":", "return", "[", "]", "dates", "=", "[", "]", "date_it", "=", "util", ".", "DateStringToD...
Return dates this service period is active as a list of "YYYYMMDD".
[ "Return", "dates", "this", "service", "period", "is", "active", "as", "a", "list", "of", "YYYYMMDD", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/serviceperiod.py#L220-L234
train
google/transitfeed
transitfeed/agency.py
Agency.Validate
def Validate(self, problems=default_problem_reporter): """Validate attribute values and this object's internal consistency. Returns: True iff all validation checks passed. """ found_problem = False found_problem = ((not util.ValidateRequiredFieldsAreNotEmpty( self, s...
python
def Validate(self, problems=default_problem_reporter): """Validate attribute values and this object's internal consistency. Returns: True iff all validation checks passed. """ found_problem = False found_problem = ((not util.ValidateRequiredFieldsAreNotEmpty( self, s...
[ "def", "Validate", "(", "self", ",", "problems", "=", "default_problem_reporter", ")", ":", "found_problem", "=", "False", "found_problem", "=", "(", "(", "not", "util", ".", "ValidateRequiredFieldsAreNotEmpty", "(", "self", ",", "self", ".", "_REQUIRED_FIELD_NAME...
Validate attribute values and this object's internal consistency. Returns: True iff all validation checks passed.
[ "Validate", "attribute", "values", "and", "this", "object", "s", "internal", "consistency", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/agency.py#L88-L104
train
google/transitfeed
misc/import_ch_zurich.py
ConvertCH1903
def ConvertCH1903(x, y): "Converts coordinates from the 1903 Swiss national grid system to WGS-84." yb = (x - 600000.0) / 1e6; xb = (y - 200000.0) / 1e6; lam = 2.6779094 \ + 4.728982 * yb \ + 0.791484 * yb * xb \ + 0.1306 * yb * xb * xb \ - 0.0436 * yb * yb * yb phi = 16.9023892 \ + 3...
python
def ConvertCH1903(x, y): "Converts coordinates from the 1903 Swiss national grid system to WGS-84." yb = (x - 600000.0) / 1e6; xb = (y - 200000.0) / 1e6; lam = 2.6779094 \ + 4.728982 * yb \ + 0.791484 * yb * xb \ + 0.1306 * yb * xb * xb \ - 0.0436 * yb * yb * yb phi = 16.9023892 \ + 3...
[ "def", "ConvertCH1903", "(", "x", ",", "y", ")", ":", "yb", "=", "(", "x", "-", "600000.0", ")", "/", "1e6", "xb", "=", "(", "y", "-", "200000.0", ")", "/", "1e6", "lam", "=", "2.6779094", "+", "4.728982", "*", "yb", "+", "0.791484", "*", "yb",...
Converts coordinates from the 1903 Swiss national grid system to WGS-84.
[ "Converts", "coordinates", "from", "the", "1903", "Swiss", "national", "grid", "system", "to", "WGS", "-", "84", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L96-L111
train
google/transitfeed
misc/import_ch_zurich.py
EncodeForCSV
def EncodeForCSV(x): "Encodes one value for CSV." k = x.encode('utf-8') if ',' in k or '"' in k: return '"%s"' % k.replace('"', '""') else: return k
python
def EncodeForCSV(x): "Encodes one value for CSV." k = x.encode('utf-8') if ',' in k or '"' in k: return '"%s"' % k.replace('"', '""') else: return k
[ "def", "EncodeForCSV", "(", "x", ")", ":", "k", "=", "x", ".", "encode", "(", "'utf-8'", ")", "if", "','", "in", "k", "or", "'\"'", "in", "k", ":", "return", "'\"%s\"'", "%", "k", ".", "replace", "(", "'\"'", ",", "'\"\"'", ")", "else", ":", "r...
Encodes one value for CSV.
[ "Encodes", "one", "value", "for", "CSV", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L114-L120
train
google/transitfeed
misc/import_ch_zurich.py
WriteRow
def WriteRow(stream, values): "Writes one row of comma-separated values to stream." stream.write(','.join([EncodeForCSV(val) for val in values])) stream.write('\n')
python
def WriteRow(stream, values): "Writes one row of comma-separated values to stream." stream.write(','.join([EncodeForCSV(val) for val in values])) stream.write('\n')
[ "def", "WriteRow", "(", "stream", ",", "values", ")", ":", "stream", ".", "write", "(", "','", ".", "join", "(", "[", "EncodeForCSV", "(", "val", ")", "for", "val", "in", "values", "]", ")", ")", "stream", ".", "write", "(", "'\\n'", ")" ]
Writes one row of comma-separated values to stream.
[ "Writes", "one", "row", "of", "comma", "-", "separated", "values", "to", "stream", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L123-L126
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportStations
def ImportStations(self, station_file, adv_file): "Imports the rec_ort.mdv file." for id, name, x, y, uic_code in \ ReadCSV(station_file, ['ORT_NR', 'ORT_NAME', 'ORT_POS_X', 'ORT_POS_Y', 'ORT_NR_NATIONAL']): station = Station() station.id = id station.position = self.coord...
python
def ImportStations(self, station_file, adv_file): "Imports the rec_ort.mdv file." for id, name, x, y, uic_code in \ ReadCSV(station_file, ['ORT_NR', 'ORT_NAME', 'ORT_POS_X', 'ORT_POS_Y', 'ORT_NR_NATIONAL']): station = Station() station.id = id station.position = self.coord...
[ "def", "ImportStations", "(", "self", ",", "station_file", ",", "adv_file", ")", ":", "for", "id", ",", "name", ",", "x", ",", "y", ",", "uic_code", "in", "ReadCSV", "(", "station_file", ",", "[", "'ORT_NR'", ",", "'ORT_NAME'", ",", "'ORT_POS_X'", ",", ...
Imports the rec_ort.mdv file.
[ "Imports", "the", "rec_ort", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L207-L230
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportRoutes
def ImportRoutes(self, s): "Imports the rec_lin_ber.mdv file." # the line id is really qualified with an area_id (BEREICH_NR), but the # table of advertised lines does not include area. Fortunately, it seems # that line ids are unique across all areas, so we can just throw it away. for line_id, name...
python
def ImportRoutes(self, s): "Imports the rec_lin_ber.mdv file." # the line id is really qualified with an area_id (BEREICH_NR), but the # table of advertised lines does not include area. Fortunately, it seems # that line ids are unique across all areas, so we can just throw it away. for line_id, name...
[ "def", "ImportRoutes", "(", "self", ",", "s", ")", ":", "# the line id is really qualified with an area_id (BEREICH_NR), but the", "# table of advertised lines does not include area. Fortunately, it seems", "# that line ids are unique across all areas, so we can just throw it away.", "for", ...
Imports the rec_lin_ber.mdv file.
[ "Imports", "the", "rec_lin_ber", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L232-L253
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportPatterns
def ImportPatterns(self, s): "Imports the lid_verlauf.mdv file." for line, strli, direction, seq, station_id in \ ReadCSV(s, ['LI_NR', 'STR_LI_VAR', 'LI_RI_NR', 'LI_LFD_NR', 'ORT_NR']): pattern_id = u'Pat.%s.%s.%s' % (line, strli, direction) pattern = self.patterns.get(pattern_id, None) i...
python
def ImportPatterns(self, s): "Imports the lid_verlauf.mdv file." for line, strli, direction, seq, station_id in \ ReadCSV(s, ['LI_NR', 'STR_LI_VAR', 'LI_RI_NR', 'LI_LFD_NR', 'ORT_NR']): pattern_id = u'Pat.%s.%s.%s' % (line, strli, direction) pattern = self.patterns.get(pattern_id, None) i...
[ "def", "ImportPatterns", "(", "self", ",", "s", ")", ":", "for", "line", ",", "strli", ",", "direction", ",", "seq", ",", "station_id", "in", "ReadCSV", "(", "s", ",", "[", "'LI_NR'", ",", "'STR_LI_VAR'", ",", "'LI_RI_NR'", ",", "'LI_LFD_NR'", ",", "'O...
Imports the lid_verlauf.mdv file.
[ "Imports", "the", "lid_verlauf", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L255-L270
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportBoarding
def ImportBoarding(self, drop_off_file): "Reads the bedverb.mdv file." for trip_id, seq, code in \ ReadCSV(drop_off_file, ['FRT_FID', 'LI_LFD_NR', 'BEDVERB_CODE']): key = (trip_id, int(seq) - 1) if code == 'A': self.pickup_type[key] = '1' # '1' = no pick-up elif code == 'E': ...
python
def ImportBoarding(self, drop_off_file): "Reads the bedverb.mdv file." for trip_id, seq, code in \ ReadCSV(drop_off_file, ['FRT_FID', 'LI_LFD_NR', 'BEDVERB_CODE']): key = (trip_id, int(seq) - 1) if code == 'A': self.pickup_type[key] = '1' # '1' = no pick-up elif code == 'E': ...
[ "def", "ImportBoarding", "(", "self", ",", "drop_off_file", ")", ":", "for", "trip_id", ",", "seq", ",", "code", "in", "ReadCSV", "(", "drop_off_file", ",", "[", "'FRT_FID'", ",", "'LI_LFD_NR'", ",", "'BEDVERB_CODE'", "]", ")", ":", "key", "=", "(", "tri...
Reads the bedverb.mdv file.
[ "Reads", "the", "bedverb", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L272-L287
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportTrafficRestrictions
def ImportTrafficRestrictions(self, restrictions_file): "Reads the vb_regio.mdv file." ParseDate = lambda x: datetime.date(int(x[:4]), int(x[4:6]), int(x[6:8])) MonthNr = lambda x: int(x[:4]) * 12 + int(x[4:6]) for schedule, id, bitmask, start_date, end_date in \ ReadCSV(restrictions_file, ...
python
def ImportTrafficRestrictions(self, restrictions_file): "Reads the vb_regio.mdv file." ParseDate = lambda x: datetime.date(int(x[:4]), int(x[4:6]), int(x[6:8])) MonthNr = lambda x: int(x[:4]) * 12 + int(x[4:6]) for schedule, id, bitmask, start_date, end_date in \ ReadCSV(restrictions_file, ...
[ "def", "ImportTrafficRestrictions", "(", "self", ",", "restrictions_file", ")", ":", "ParseDate", "=", "lambda", "x", ":", "datetime", ".", "date", "(", "int", "(", "x", "[", ":", "4", "]", ")", ",", "int", "(", "x", "[", "4", ":", "6", "]", ")", ...
Reads the vb_regio.mdv file.
[ "Reads", "the", "vb_regio", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L310-L338
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportStopTimes
def ImportStopTimes(self, stoptimes_file): "Imports the lid_fahrzeitart.mdv file." for line, strli, direction, seq, stoptime_id, drive_secs, wait_secs in \ ReadCSV(stoptimes_file, ['LI_NR', 'STR_LI_VAR', 'LI_RI_NR', 'LI_LFD_NR', 'FGR_NR', 'FZT_REL', 'HZEIT']): pattern = self.p...
python
def ImportStopTimes(self, stoptimes_file): "Imports the lid_fahrzeitart.mdv file." for line, strli, direction, seq, stoptime_id, drive_secs, wait_secs in \ ReadCSV(stoptimes_file, ['LI_NR', 'STR_LI_VAR', 'LI_RI_NR', 'LI_LFD_NR', 'FGR_NR', 'FZT_REL', 'HZEIT']): pattern = self.p...
[ "def", "ImportStopTimes", "(", "self", ",", "stoptimes_file", ")", ":", "for", "line", ",", "strli", ",", "direction", ",", "seq", ",", "stoptime_id", ",", "drive_secs", ",", "wait_secs", "in", "ReadCSV", "(", "stoptimes_file", ",", "[", "'LI_NR'", ",", "'...
Imports the lid_fahrzeitart.mdv file.
[ "Imports", "the", "lid_fahrzeitart", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L340-L352
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.ImportTrips
def ImportTrips(self, trips_file): "Imports the rec_frt.mdv file." for trip_id, trip_starttime, line, strli, direction, \ stoptime_id, schedule_id, daytype_id, restriction_id, \ dest_station_id, dest_stop_id, trip_type in \ ReadCSV(trips_file, ['FRT_FID', 'FRT_START', 'LI_...
python
def ImportTrips(self, trips_file): "Imports the rec_frt.mdv file." for trip_id, trip_starttime, line, strli, direction, \ stoptime_id, schedule_id, daytype_id, restriction_id, \ dest_station_id, dest_stop_id, trip_type in \ ReadCSV(trips_file, ['FRT_FID', 'FRT_START', 'LI_...
[ "def", "ImportTrips", "(", "self", ",", "trips_file", ")", ":", "for", "trip_id", ",", "trip_starttime", ",", "line", ",", "strli", ",", "direction", ",", "stoptime_id", ",", "schedule_id", ",", "daytype_id", ",", "restriction_id", ",", "dest_station_id", ",",...
Imports the rec_frt.mdv file.
[ "Imports", "the", "rec_frt", ".", "mdv", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L354-L385
train
google/transitfeed
misc/import_ch_zurich.py
DivaImporter.Write
def Write(self, outpath): "Writes a .zip file in Google Transit format." out = zipfile.ZipFile(outpath, mode="w", compression=zipfile.ZIP_DEFLATED) for filename, func in [('agency.txt', self.WriteAgency), ('calendar.txt', self.WriteCalendar), ('calendar_...
python
def Write(self, outpath): "Writes a .zip file in Google Transit format." out = zipfile.ZipFile(outpath, mode="w", compression=zipfile.ZIP_DEFLATED) for filename, func in [('agency.txt', self.WriteAgency), ('calendar.txt', self.WriteCalendar), ('calendar_...
[ "def", "Write", "(", "self", ",", "outpath", ")", ":", "out", "=", "zipfile", ".", "ZipFile", "(", "outpath", ",", "mode", "=", "\"w\"", ",", "compression", "=", "zipfile", ".", "ZIP_DEFLATED", ")", "for", "filename", ",", "func", "in", "[", "(", "'a...
Writes a .zip file in Google Transit format.
[ "Writes", "a", ".", "zip", "file", "in", "Google", "Transit", "format", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/import_ch_zurich.py#L387-L400
train
google/transitfeed
examples/table.py
TransposeTable
def TransposeTable(table): """Transpose a list of lists, using None to extend all input lists to the same length. For example: >>> TransposeTable( [ [11, 12, 13], [21, 22], [31, 32, 33, 34]]) [ [11, 21, 31], [12, 22, 32], [13, None, 33], [None, None, 34]] """ ...
python
def TransposeTable(table): """Transpose a list of lists, using None to extend all input lists to the same length. For example: >>> TransposeTable( [ [11, 12, 13], [21, 22], [31, 32, 33, 34]]) [ [11, 21, 31], [12, 22, 32], [13, None, 33], [None, None, 34]] """ ...
[ "def", "TransposeTable", "(", "table", ")", ":", "transposed", "=", "[", "]", "rows", "=", "len", "(", "table", ")", "cols", "=", "max", "(", "len", "(", "row", ")", "for", "row", "in", "table", ")", "for", "x", "in", "range", "(", "cols", ")", ...
Transpose a list of lists, using None to extend all input lists to the same length. For example: >>> TransposeTable( [ [11, 12, 13], [21, 22], [31, 32, 33, 34]]) [ [11, 21, 31], [12, 22, 32], [13, None, 33], [None, None, 34]]
[ "Transpose", "a", "list", "of", "lists", "using", "None", "to", "extend", "all", "input", "lists", "to", "the", "same", "length", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/examples/table.py#L65-L90
train
google/transitfeed
transitfeed/util.py
CheckVersion
def CheckVersion(problems, latest_version=None): """ Check if there is a newer version of transitfeed available. Args: problems: if a new version is available, a NewVersionAvailable problem will be added latest_version: if specified, override the latest version read from the project page ""...
python
def CheckVersion(problems, latest_version=None): """ Check if there is a newer version of transitfeed available. Args: problems: if a new version is available, a NewVersionAvailable problem will be added latest_version: if specified, override the latest version read from the project page ""...
[ "def", "CheckVersion", "(", "problems", ",", "latest_version", "=", "None", ")", ":", "if", "not", "latest_version", ":", "timeout", "=", "20", "socket", ".", "setdefaulttimeout", "(", "timeout", ")", "request", "=", "urllib2", ".", "Request", "(", "LATEST_R...
Check if there is a newer version of transitfeed available. Args: problems: if a new version is available, a NewVersionAvailable problem will be added latest_version: if specified, override the latest version read from the project page
[ "Check", "if", "there", "is", "a", "newer", "version", "of", "transitfeed", "available", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L180-L225
train
google/transitfeed
transitfeed/util.py
EncodeUnicode
def EncodeUnicode(text): """ Optionally encode text and return it. The result should be safe to print. """ if type(text) == type(u''): return text.encode(OUTPUT_ENCODING) else: return text
python
def EncodeUnicode(text): """ Optionally encode text and return it. The result should be safe to print. """ if type(text) == type(u''): return text.encode(OUTPUT_ENCODING) else: return text
[ "def", "EncodeUnicode", "(", "text", ")", ":", "if", "type", "(", "text", ")", "==", "type", "(", "u''", ")", ":", "return", "text", ".", "encode", "(", "OUTPUT_ENCODING", ")", "else", ":", "return", "text" ]
Optionally encode text and return it. The result should be safe to print.
[ "Optionally", "encode", "text", "and", "return", "it", ".", "The", "result", "should", "be", "safe", "to", "print", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L238-L245
train
google/transitfeed
transitfeed/util.py
ValidateYesNoUnknown
def ValidateYesNoUnknown(value, column_name=None, problems=None): """Validates a value "0" for uknown, "1" for yes, and "2" for no.""" if IsEmpty(value) or IsValidYesNoUnknown(value): return True else: if problems: problems.InvalidValue(column_name, value) return False
python
def ValidateYesNoUnknown(value, column_name=None, problems=None): """Validates a value "0" for uknown, "1" for yes, and "2" for no.""" if IsEmpty(value) or IsValidYesNoUnknown(value): return True else: if problems: problems.InvalidValue(column_name, value) return False
[ "def", "ValidateYesNoUnknown", "(", "value", ",", "column_name", "=", "None", ",", "problems", "=", "None", ")", ":", "if", "IsEmpty", "(", "value", ")", "or", "IsValidYesNoUnknown", "(", "value", ")", ":", "return", "True", "else", ":", "if", "problems", ...
Validates a value "0" for uknown, "1" for yes, and "2" for no.
[ "Validates", "a", "value", "0", "for", "uknown", "1", "for", "yes", "and", "2", "for", "no", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L437-L444
train
google/transitfeed
transitfeed/util.py
FindUniqueId
def FindUniqueId(dic): """Return a string not used as a key in the dictionary dic""" name = str(len(dic)) while name in dic: # Use bigger numbers so it is obvious when an id is picked randomly. name = str(random.randint(1000000, 999999999)) return name
python
def FindUniqueId(dic): """Return a string not used as a key in the dictionary dic""" name = str(len(dic)) while name in dic: # Use bigger numbers so it is obvious when an id is picked randomly. name = str(random.randint(1000000, 999999999)) return name
[ "def", "FindUniqueId", "(", "dic", ")", ":", "name", "=", "str", "(", "len", "(", "dic", ")", ")", "while", "name", "in", "dic", ":", "# Use bigger numbers so it is obvious when an id is picked randomly.", "name", "=", "str", "(", "random", ".", "randint", "("...
Return a string not used as a key in the dictionary dic
[ "Return", "a", "string", "not", "used", "as", "a", "key", "in", "the", "dictionary", "dic" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L449-L455
train
google/transitfeed
transitfeed/util.py
DateStringToDateObject
def DateStringToDateObject(date_string): """Return a date object for a string "YYYYMMDD".""" # If this becomes a bottleneck date objects could be cached if re.match('^\d{8}$', date_string) == None: return None try: return datetime.date(int(date_string[0:4]), int(date_string[4:6]), ...
python
def DateStringToDateObject(date_string): """Return a date object for a string "YYYYMMDD".""" # If this becomes a bottleneck date objects could be cached if re.match('^\d{8}$', date_string) == None: return None try: return datetime.date(int(date_string[0:4]), int(date_string[4:6]), ...
[ "def", "DateStringToDateObject", "(", "date_string", ")", ":", "# If this becomes a bottleneck date objects could be cached", "if", "re", ".", "match", "(", "'^\\d{8}$'", ",", "date_string", ")", "==", "None", ":", "return", "None", "try", ":", "return", "datetime", ...
Return a date object for a string "YYYYMMDD".
[ "Return", "a", "date", "object", "for", "a", "string", "YYYYMMDD", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L473-L482
train
google/transitfeed
transitfeed/util.py
FloatStringToFloat
def FloatStringToFloat(float_string, problems=None): """Convert a float as a string to a float or raise an exception""" # Will raise TypeError unless a string match = re.match(r"^[+-]?\d+(\.\d+)?$", float_string) # Will raise TypeError if the string can't be parsed parsed_value = float(float_string) if "x"...
python
def FloatStringToFloat(float_string, problems=None): """Convert a float as a string to a float or raise an exception""" # Will raise TypeError unless a string match = re.match(r"^[+-]?\d+(\.\d+)?$", float_string) # Will raise TypeError if the string can't be parsed parsed_value = float(float_string) if "x"...
[ "def", "FloatStringToFloat", "(", "float_string", ",", "problems", "=", "None", ")", ":", "# Will raise TypeError unless a string", "match", "=", "re", ".", "match", "(", "r\"^[+-]?\\d+(\\.\\d+)?$\"", ",", "float_string", ")", "# Will raise TypeError if the string can't be ...
Convert a float as a string to a float or raise an exception
[ "Convert", "a", "float", "as", "a", "string", "to", "a", "float", "or", "raise", "an", "exception" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L484-L499
train
google/transitfeed
transitfeed/util.py
NonNegIntStringToInt
def NonNegIntStringToInt(int_string, problems=None): """Convert an non-negative integer string to an int or raise an exception""" # Will raise TypeError unless a string match = re.match(r"^(?:0|[1-9]\d*)$", int_string) # Will raise ValueError if the string can't be parsed parsed_value = int(int_string) if ...
python
def NonNegIntStringToInt(int_string, problems=None): """Convert an non-negative integer string to an int or raise an exception""" # Will raise TypeError unless a string match = re.match(r"^(?:0|[1-9]\d*)$", int_string) # Will raise ValueError if the string can't be parsed parsed_value = int(int_string) if ...
[ "def", "NonNegIntStringToInt", "(", "int_string", ",", "problems", "=", "None", ")", ":", "# Will raise TypeError unless a string", "match", "=", "re", ".", "match", "(", "r\"^(?:0|[1-9]\\d*)$\"", ",", "int_string", ")", "# Will raise ValueError if the string can't be parse...
Convert an non-negative integer string to an int or raise an exception
[ "Convert", "an", "non", "-", "negative", "integer", "string", "to", "an", "int", "or", "raise", "an", "exception" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L501-L514
train
google/transitfeed
transitfeed/util.py
ApproximateDistance
def ApproximateDistance(degree_lat1, degree_lng1, degree_lat2, degree_lng2): """Compute approximate distance between two points in meters. Assumes the Earth is a sphere.""" # TODO: change to ellipsoid approximation, such as # http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115/ lat1 = math.radians(de...
python
def ApproximateDistance(degree_lat1, degree_lng1, degree_lat2, degree_lng2): """Compute approximate distance between two points in meters. Assumes the Earth is a sphere.""" # TODO: change to ellipsoid approximation, such as # http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115/ lat1 = math.radians(de...
[ "def", "ApproximateDistance", "(", "degree_lat1", ",", "degree_lng1", ",", "degree_lat2", ",", "degree_lng2", ")", ":", "# TODO: change to ellipsoid approximation, such as", "# http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115/", "lat1", "=", "math", ".", "radians", ...
Compute approximate distance between two points in meters. Assumes the Earth is a sphere.
[ "Compute", "approximate", "distance", "between", "two", "points", "in", "meters", ".", "Assumes", "the", "Earth", "is", "a", "sphere", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L517-L530
train
google/transitfeed
transitfeed/util.py
ApproximateDistanceBetweenStops
def ApproximateDistanceBetweenStops(stop1, stop2): """Compute approximate distance between two stops in meters. Assumes the Earth is a sphere.""" if (stop1.stop_lat is None or stop1.stop_lon is None or stop2.stop_lat is None or stop2.stop_lon is None): return None return ApproximateDistance(stop1.stop...
python
def ApproximateDistanceBetweenStops(stop1, stop2): """Compute approximate distance between two stops in meters. Assumes the Earth is a sphere.""" if (stop1.stop_lat is None or stop1.stop_lon is None or stop2.stop_lat is None or stop2.stop_lon is None): return None return ApproximateDistance(stop1.stop...
[ "def", "ApproximateDistanceBetweenStops", "(", "stop1", ",", "stop2", ")", ":", "if", "(", "stop1", ".", "stop_lat", "is", "None", "or", "stop1", ".", "stop_lon", "is", "None", "or", "stop2", ".", "stop_lat", "is", "None", "or", "stop2", ".", "stop_lon", ...
Compute approximate distance between two stops in meters. Assumes the Earth is a sphere.
[ "Compute", "approximate", "distance", "between", "two", "stops", "in", "meters", ".", "Assumes", "the", "Earth", "is", "a", "sphere", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L532-L539
train
google/transitfeed
transitfeed/util.py
CsvUnicodeWriter.writerow
def writerow(self, row): """Write row to the csv file. Any unicode strings in row are encoded as utf-8.""" encoded_row = [] for s in row: if isinstance(s, unicode): encoded_row.append(s.encode("utf-8")) else: encoded_row.append(s) try: self.writer.writerow(encoded_r...
python
def writerow(self, row): """Write row to the csv file. Any unicode strings in row are encoded as utf-8.""" encoded_row = [] for s in row: if isinstance(s, unicode): encoded_row.append(s.encode("utf-8")) else: encoded_row.append(s) try: self.writer.writerow(encoded_r...
[ "def", "writerow", "(", "self", ",", "row", ")", ":", "encoded_row", "=", "[", "]", "for", "s", "in", "row", ":", "if", "isinstance", "(", "s", ",", "unicode", ")", ":", "encoded_row", ".", "append", "(", "s", ".", "encode", "(", "\"utf-8\"", ")", ...
Write row to the csv file. Any unicode strings in row are encoded as utf-8.
[ "Write", "row", "to", "the", "csv", "file", ".", "Any", "unicode", "strings", "in", "row", "are", "encoded", "as", "utf", "-", "8", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L549-L562
train
google/transitfeed
transitfeed/util.py
EndOfLineChecker.next
def next(self): """Return next line without end of line marker or raise StopIteration.""" try: next_line = next(self._f) except StopIteration: self._FinalCheck() raise self._line_number += 1 m_eol = re.search(r"[\x0a\x0d]*$", next_line) if m_eol.group() == "\x0d\x0a": se...
python
def next(self): """Return next line without end of line marker or raise StopIteration.""" try: next_line = next(self._f) except StopIteration: self._FinalCheck() raise self._line_number += 1 m_eol = re.search(r"[\x0a\x0d]*$", next_line) if m_eol.group() == "\x0d\x0a": se...
[ "def", "next", "(", "self", ")", ":", "try", ":", "next_line", "=", "next", "(", "self", ".", "_f", ")", "except", "StopIteration", ":", "self", ".", "_FinalCheck", "(", ")", "raise", "self", ".", "_line_number", "+=", "1", "m_eol", "=", "re", ".", ...
Return next line without end of line marker or raise StopIteration.
[ "Return", "next", "line", "without", "end", "of", "line", "marker", "or", "raise", "StopIteration", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L610-L646
train
google/transitfeed
upgrade_translations.py
read_first_available_value
def read_first_available_value(filename, field_name): """Reads the first assigned value of the given field in the CSV table. """ if not os.path.exists(filename): return None with open(filename, 'rb') as csvfile: reader = csv.DictReader(csvfile) for row in reader: valu...
python
def read_first_available_value(filename, field_name): """Reads the first assigned value of the given field in the CSV table. """ if not os.path.exists(filename): return None with open(filename, 'rb') as csvfile: reader = csv.DictReader(csvfile) for row in reader: valu...
[ "def", "read_first_available_value", "(", "filename", ",", "field_name", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "return", "None", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "csvfile", ":", "reade...
Reads the first assigned value of the given field in the CSV table.
[ "Reads", "the", "first", "assigned", "value", "of", "the", "given", "field", "in", "the", "CSV", "table", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/upgrade_translations.py#L162-L173
train
google/transitfeed
upgrade_translations.py
OldTranslations._find_feed_language
def _find_feed_language(self): """Find feed language based specified feed_info.txt or agency.txt. """ self.feed_language = ( read_first_available_value( os.path.join(self.src_dir, 'feed_info.txt'), 'feed_lang') or read_first_available_value( ...
python
def _find_feed_language(self): """Find feed language based specified feed_info.txt or agency.txt. """ self.feed_language = ( read_first_available_value( os.path.join(self.src_dir, 'feed_info.txt'), 'feed_lang') or read_first_available_value( ...
[ "def", "_find_feed_language", "(", "self", ")", ":", "self", ".", "feed_language", "=", "(", "read_first_available_value", "(", "os", ".", "path", ".", "join", "(", "self", ".", "src_dir", ",", "'feed_info.txt'", ")", ",", "'feed_lang'", ")", "or", "read_fir...
Find feed language based specified feed_info.txt or agency.txt.
[ "Find", "feed", "language", "based", "specified", "feed_info", ".", "txt", "or", "agency", ".", "txt", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/upgrade_translations.py#L196-L207
train
google/transitfeed
upgrade_translations.py
OldTranslations._read_translations
def _read_translations(self): """Read from the old translations.txt. """ print('Reading original translations') self.translations_map = {} n_translations = 0 with open(os.path.join(self.src_dir, 'translations.txt'), 'rb') as csvfile: reader =...
python
def _read_translations(self): """Read from the old translations.txt. """ print('Reading original translations') self.translations_map = {} n_translations = 0 with open(os.path.join(self.src_dir, 'translations.txt'), 'rb') as csvfile: reader =...
[ "def", "_read_translations", "(", "self", ")", ":", "print", "(", "'Reading original translations'", ")", "self", ".", "translations_map", "=", "{", "}", "n_translations", "=", "0", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "sr...
Read from the old translations.txt.
[ "Read", "from", "the", "old", "translations", ".", "txt", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/upgrade_translations.py#L209-L222
train
google/transitfeed
upgrade_translations.py
OldTranslations._find_context_dependent_names
def _find_context_dependent_names(self): """Finds texts whose translation depends on context. Example. Here the word "Palacio" is translated from Spanish to English in multiple ways. Feed language is es (Spanish). trans_id,lang,translation stop-name-1,es,Palacio...
python
def _find_context_dependent_names(self): """Finds texts whose translation depends on context. Example. Here the word "Palacio" is translated from Spanish to English in multiple ways. Feed language is es (Spanish). trans_id,lang,translation stop-name-1,es,Palacio...
[ "def", "_find_context_dependent_names", "(", "self", ")", ":", "n_occurences_of_original", "=", "{", "}", "for", "trans_id", ",", "translations", "in", "self", ".", "translations_map", ".", "items", "(", ")", ":", "try", ":", "original_name", "=", "translations"...
Finds texts whose translation depends on context. Example. Here the word "Palacio" is translated from Spanish to English in multiple ways. Feed language is es (Spanish). trans_id,lang,translation stop-name-1,es,Palacio stop-name-1,en,Palace headsign-...
[ "Finds", "texts", "whose", "translation", "depends", "on", "context", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/upgrade_translations.py#L224-L254
train
google/transitfeed
upgrade_translations.py
TranslationsConverter.convert_translations
def convert_translations(self, dest_dir): """ Converts translations to the new format and stores at dest_dir. """ if not os.path.isdir(dest_dir): os.makedirs(dest_dir) total_translation_rows = 0 with open(os.path.join(dest_dir, 'translations.txt'), ...
python
def convert_translations(self, dest_dir): """ Converts translations to the new format and stores at dest_dir. """ if not os.path.isdir(dest_dir): os.makedirs(dest_dir) total_translation_rows = 0 with open(os.path.join(dest_dir, 'translations.txt'), ...
[ "def", "convert_translations", "(", "self", ",", "dest_dir", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "dest_dir", ")", ":", "os", ".", "makedirs", "(", "dest_dir", ")", "total_translation_rows", "=", "0", "with", "open", "(", "os", ...
Converts translations to the new format and stores at dest_dir.
[ "Converts", "translations", "to", "the", "new", "format", "and", "stores", "at", "dest_dir", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/upgrade_translations.py#L264-L286
train
google/transitfeed
upgrade_translations.py
TranslationsConverter._translate_table
def _translate_table(self, dest_dir, table_name, translations_writer): """ Converts translations to the new format for a single table. """ in_filename = os.path.join(self.src_dir, '%s.txt' % table_name) if not os.path.exists(in_filename): raise Exception('No %s' % tab...
python
def _translate_table(self, dest_dir, table_name, translations_writer): """ Converts translations to the new format for a single table. """ in_filename = os.path.join(self.src_dir, '%s.txt' % table_name) if not os.path.exists(in_filename): raise Exception('No %s' % tab...
[ "def", "_translate_table", "(", "self", ",", "dest_dir", ",", "table_name", ",", "translations_writer", ")", ":", "in_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "src_dir", ",", "'%s.txt'", "%", "table_name", ")", "if", "not", "os", ...
Converts translations to the new format for a single table.
[ "Converts", "translations", "to", "the", "new", "format", "for", "a", "single", "table", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/upgrade_translations.py#L288-L316
train
google/transitfeed
transitfeed/loader.py
Loader._DetermineFormat
def _DetermineFormat(self): """Determines whether the feed is in a form that we understand, and if so, returns True.""" if self._zip: # If zip was passed to __init__ then path isn't used assert not self._path return True if not isinstance(self._path, basestring) and hasattr(self._p...
python
def _DetermineFormat(self): """Determines whether the feed is in a form that we understand, and if so, returns True.""" if self._zip: # If zip was passed to __init__ then path isn't used assert not self._path return True if not isinstance(self._path, basestring) and hasattr(self._p...
[ "def", "_DetermineFormat", "(", "self", ")", ":", "if", "self", ".", "_zip", ":", "# If zip was passed to __init__ then path isn't used", "assert", "not", "self", ".", "_path", "return", "True", "if", "not", "isinstance", "(", "self", ".", "_path", ",", "basestr...
Determines whether the feed is in a form that we understand, and if so, returns True.
[ "Determines", "whether", "the", "feed", "is", "in", "a", "form", "that", "we", "understand", "and", "if", "so", "returns", "True", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/loader.py#L69-L99
train
google/transitfeed
transitfeed/loader.py
Loader._GetFileNames
def _GetFileNames(self): """Returns a list of file names in the feed.""" if self._zip: return self._zip.namelist() else: return os.listdir(self._path)
python
def _GetFileNames(self): """Returns a list of file names in the feed.""" if self._zip: return self._zip.namelist() else: return os.listdir(self._path)
[ "def", "_GetFileNames", "(", "self", ")", ":", "if", "self", ".", "_zip", ":", "return", "self", ".", "_zip", ".", "namelist", "(", ")", "else", ":", "return", "os", ".", "listdir", "(", "self", ".", "_path", ")" ]
Returns a list of file names in the feed.
[ "Returns", "a", "list", "of", "file", "names", "in", "the", "feed", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/loader.py#L101-L106
train
google/transitfeed
transitfeed/loader.py
Loader._GetUtf8Contents
def _GetUtf8Contents(self, file_name): """Check for errors in file_name and return a string for csv reader.""" contents = self._FileContents(file_name) if not contents: # Missing file return # Check for errors that will prevent csv.reader from working if len(contents) >= 2 and contents[0:2] ...
python
def _GetUtf8Contents(self, file_name): """Check for errors in file_name and return a string for csv reader.""" contents = self._FileContents(file_name) if not contents: # Missing file return # Check for errors that will prevent csv.reader from working if len(contents) >= 2 and contents[0:2] ...
[ "def", "_GetUtf8Contents", "(", "self", ",", "file_name", ")", ":", "contents", "=", "self", ".", "_FileContents", "(", "file_name", ")", "if", "not", "contents", ":", "# Missing file", "return", "# Check for errors that will prevent csv.reader from working", "if", "l...
Check for errors in file_name and return a string for csv reader.
[ "Check", "for", "errors", "in", "file_name", "and", "return", "a", "string", "for", "csv", "reader", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/loader.py#L118-L145
train
google/transitfeed
transitfeed/loader.py
Loader._HasFile
def _HasFile(self, file_name): """Returns True if there's a file in the current feed with the given file_name in the current feed.""" if self._zip: return file_name in self._zip.namelist() else: file_path = os.path.join(self._path, file_name) return os.path.exists(file_path) and os....
python
def _HasFile(self, file_name): """Returns True if there's a file in the current feed with the given file_name in the current feed.""" if self._zip: return file_name in self._zip.namelist() else: file_path = os.path.join(self._path, file_name) return os.path.exists(file_path) and os....
[ "def", "_HasFile", "(", "self", ",", "file_name", ")", ":", "if", "self", ".", "_zip", ":", "return", "file_name", "in", "self", ".", "_zip", ".", "namelist", "(", ")", "else", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "self", "."...
Returns True if there's a file in the current feed with the given file_name in the current feed.
[ "Returns", "True", "if", "there", "s", "a", "file", "in", "the", "current", "feed", "with", "the", "given", "file_name", "in", "the", "current", "feed", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/loader.py#L375-L382
train
google/transitfeed
transitfeed/route.py
Route.AddTrip
def AddTrip(self, schedule=None, headsign=None, service_period=None, trip_id=None): """Add a trip to this route. Args: schedule: a Schedule object which will hold the new trip or None to use the schedule of this route. headsign: headsign of the trip as a string service_p...
python
def AddTrip(self, schedule=None, headsign=None, service_period=None, trip_id=None): """Add a trip to this route. Args: schedule: a Schedule object which will hold the new trip or None to use the schedule of this route. headsign: headsign of the trip as a string service_p...
[ "def", "AddTrip", "(", "self", ",", "schedule", "=", "None", ",", "headsign", "=", "None", ",", "service_period", "=", "None", ",", "trip_id", "=", "None", ")", ":", "if", "schedule", "is", "None", ":", "assert", "self", ".", "_schedule", "is", "not", ...
Add a trip to this route. Args: schedule: a Schedule object which will hold the new trip or None to use the schedule of this route. headsign: headsign of the trip as a string service_period: a ServicePeriod object or None to use schedule.GetDefaultServicePeriod() trip_id: op...
[ "Add", "a", "trip", "to", "this", "route", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/route.py#L69-L95
train
google/transitfeed
transitfeed/route.py
Route.GetPatternIdTripDict
def GetPatternIdTripDict(self): """Return a dictionary that maps pattern_id to a list of Trip objects.""" d = {} for t in self._trips: d.setdefault(t.pattern_id, []).append(t) return d
python
def GetPatternIdTripDict(self): """Return a dictionary that maps pattern_id to a list of Trip objects.""" d = {} for t in self._trips: d.setdefault(t.pattern_id, []).append(t) return d
[ "def", "GetPatternIdTripDict", "(", "self", ")", ":", "d", "=", "{", "}", "for", "t", "in", "self", ".", "_trips", ":", "d", ".", "setdefault", "(", "t", ".", "pattern_id", ",", "[", "]", ")", ".", "append", "(", "t", ")", "return", "d" ]
Return a dictionary that maps pattern_id to a list of Trip objects.
[ "Return", "a", "dictionary", "that", "maps", "pattern_id", "to", "a", "list", "of", "Trip", "objects", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/route.py#L113-L118
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.GetGtfsClassByFileName
def GetGtfsClassByFileName(self, filename): """Returns the transitfeed class corresponding to a GTFS file. Args: filename: The filename whose class is to be returned Raises: NonStandardMapping if the specified filename has more than one corresponding class """ if filename not...
python
def GetGtfsClassByFileName(self, filename): """Returns the transitfeed class corresponding to a GTFS file. Args: filename: The filename whose class is to be returned Raises: NonStandardMapping if the specified filename has more than one corresponding class """ if filename not...
[ "def", "GetGtfsClassByFileName", "(", "self", ",", "filename", ")", ":", "if", "filename", "not", "in", "self", ".", "_file_mapping", ":", "return", "None", "mapping", "=", "self", ".", "_file_mapping", "[", "filename", "]", "class_list", "=", "mapping", "["...
Returns the transitfeed class corresponding to a GTFS file. Args: filename: The filename whose class is to be returned Raises: NonStandardMapping if the specified filename has more than one corresponding class
[ "Returns", "the", "transitfeed", "class", "corresponding", "to", "a", "GTFS", "file", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L108-L125
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.GetLoadingOrder
def GetLoadingOrder(self): """Returns a list of filenames sorted by loading order. Only includes files that Loader's standardized loading knows how to load""" result = {} for filename, mapping in self._file_mapping.iteritems(): loading_order = mapping['loading_order'] if loading_order is not...
python
def GetLoadingOrder(self): """Returns a list of filenames sorted by loading order. Only includes files that Loader's standardized loading knows how to load""" result = {} for filename, mapping in self._file_mapping.iteritems(): loading_order = mapping['loading_order'] if loading_order is not...
[ "def", "GetLoadingOrder", "(", "self", ")", ":", "result", "=", "{", "}", "for", "filename", ",", "mapping", "in", "self", ".", "_file_mapping", ".", "iteritems", "(", ")", ":", "loading_order", "=", "mapping", "[", "'loading_order'", "]", "if", "loading_o...
Returns a list of filenames sorted by loading order. Only includes files that Loader's standardized loading knows how to load
[ "Returns", "a", "list", "of", "filenames", "sorted", "by", "loading", "order", ".", "Only", "includes", "files", "that", "Loader", "s", "standardized", "loading", "knows", "how", "to", "load" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L127-L135
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.IsFileRequired
def IsFileRequired(self, filename): """Returns true if a file is required by GTFS, false otherwise. Unknown files are, by definition, not required""" if filename not in self._file_mapping: return False mapping = self._file_mapping[filename] return mapping['required']
python
def IsFileRequired(self, filename): """Returns true if a file is required by GTFS, false otherwise. Unknown files are, by definition, not required""" if filename not in self._file_mapping: return False mapping = self._file_mapping[filename] return mapping['required']
[ "def", "IsFileRequired", "(", "self", ",", "filename", ")", ":", "if", "filename", "not", "in", "self", ".", "_file_mapping", ":", "return", "False", "mapping", "=", "self", ".", "_file_mapping", "[", "filename", "]", "return", "mapping", "[", "'required'", ...
Returns true if a file is required by GTFS, false otherwise. Unknown files are, by definition, not required
[ "Returns", "true", "if", "a", "file", "is", "required", "by", "GTFS", "false", "otherwise", ".", "Unknown", "files", "are", "by", "definition", "not", "required" ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L137-L143
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.AddMapping
def AddMapping(self, filename, new_mapping): """Adds an entry to the list of known filenames. Args: filename: The filename whose mapping is being added. new_mapping: A dictionary with the mapping to add. Must contain all fields in _REQUIRED_MAPPING_FIELDS. Raises: Duplic...
python
def AddMapping(self, filename, new_mapping): """Adds an entry to the list of known filenames. Args: filename: The filename whose mapping is being added. new_mapping: A dictionary with the mapping to add. Must contain all fields in _REQUIRED_MAPPING_FIELDS. Raises: Duplic...
[ "def", "AddMapping", "(", "self", ",", "filename", ",", "new_mapping", ")", ":", "for", "field", "in", "self", ".", "_REQUIRED_MAPPING_FIELDS", ":", "if", "field", "not", "in", "new_mapping", ":", "raise", "problems", ".", "InvalidMapping", "(", "field", ")"...
Adds an entry to the list of known filenames. Args: filename: The filename whose mapping is being added. new_mapping: A dictionary with the mapping to add. Must contain all fields in _REQUIRED_MAPPING_FIELDS. Raises: DuplicateMapping if the filename already exists in the map...
[ "Adds", "an", "entry", "to", "the", "list", "of", "known", "filenames", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L158-L174
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.UpdateMapping
def UpdateMapping(self, filename, mapping_update): """Updates an entry in the list of known filenames. An entry is identified by its filename. Args: filename: The filename whose mapping is to be updated mapping_update: A dictionary containing the fields to update and their ne...
python
def UpdateMapping(self, filename, mapping_update): """Updates an entry in the list of known filenames. An entry is identified by its filename. Args: filename: The filename whose mapping is to be updated mapping_update: A dictionary containing the fields to update and their ne...
[ "def", "UpdateMapping", "(", "self", ",", "filename", ",", "mapping_update", ")", ":", "if", "filename", "not", "in", "self", ".", "_file_mapping", ":", "raise", "problems", ".", "NonexistentMapping", "(", "filename", ")", "mapping", "=", "self", ".", "_file...
Updates an entry in the list of known filenames. An entry is identified by its filename. Args: filename: The filename whose mapping is to be updated mapping_update: A dictionary containing the fields to update and their new values. Raises: InexistentMapping if the fil...
[ "Updates", "an", "entry", "in", "the", "list", "of", "known", "filenames", ".", "An", "entry", "is", "identified", "by", "its", "filename", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L176-L190
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.AddClass
def AddClass(self, class_name, gtfs_class): """Adds an entry to the list of known classes. Args: class_name: A string with name through which gtfs_class is to be made accessible. gtfs_class: The class to be added. Raises: DuplicateMapping if class_name is already...
python
def AddClass(self, class_name, gtfs_class): """Adds an entry to the list of known classes. Args: class_name: A string with name through which gtfs_class is to be made accessible. gtfs_class: The class to be added. Raises: DuplicateMapping if class_name is already...
[ "def", "AddClass", "(", "self", ",", "class_name", ",", "gtfs_class", ")", ":", "if", "class_name", "in", "self", ".", "_class_mapping", ":", "raise", "problems", ".", "DuplicateMapping", "(", "class_name", ")", "self", ".", "_class_mapping", "[", "class_name"...
Adds an entry to the list of known classes. Args: class_name: A string with name through which gtfs_class is to be made accessible. gtfs_class: The class to be added. Raises: DuplicateMapping if class_name is already present in the class mapping.
[ "Adds", "an", "entry", "to", "the", "list", "of", "known", "classes", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L192-L204
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.UpdateClass
def UpdateClass(self, class_name, gtfs_class): """Updates an entry in the list of known classes. Args: class_name: A string with the class name that is to be updated. gtfs_class: The new class Raises: NonexistentMapping if there is no class with the specified class_name. """ ...
python
def UpdateClass(self, class_name, gtfs_class): """Updates an entry in the list of known classes. Args: class_name: A string with the class name that is to be updated. gtfs_class: The new class Raises: NonexistentMapping if there is no class with the specified class_name. """ ...
[ "def", "UpdateClass", "(", "self", ",", "class_name", ",", "gtfs_class", ")", ":", "if", "class_name", "not", "in", "self", ".", "_class_mapping", ":", "raise", "problems", ".", "NonexistentMapping", "(", "class_name", ")", "self", ".", "_class_mapping", "[", ...
Updates an entry in the list of known classes. Args: class_name: A string with the class name that is to be updated. gtfs_class: The new class Raises: NonexistentMapping if there is no class with the specified class_name.
[ "Updates", "an", "entry", "in", "the", "list", "of", "known", "classes", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L206-L217
train
google/transitfeed
transitfeed/gtfsfactory.py
GtfsFactory.RemoveClass
def RemoveClass(self, class_name): """Removes an entry from the list of known classes. Args: class_name: A string with the class name that is to be removed. Raises: NonexistentMapping if there is no class with the specified class_name. """ if class_name not in self._class_mapping: ...
python
def RemoveClass(self, class_name): """Removes an entry from the list of known classes. Args: class_name: A string with the class name that is to be removed. Raises: NonexistentMapping if there is no class with the specified class_name. """ if class_name not in self._class_mapping: ...
[ "def", "RemoveClass", "(", "self", ",", "class_name", ")", ":", "if", "class_name", "not", "in", "self", ".", "_class_mapping", ":", "raise", "problems", ".", "NonexistentMapping", "(", "class_name", ")", "del", "self", ".", "_class_mapping", "[", "class_name"...
Removes an entry from the list of known classes. Args: class_name: A string with the class name that is to be removed. Raises: NonexistentMapping if there is no class with the specified class_name.
[ "Removes", "an", "entry", "from", "the", "list", "of", "known", "classes", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/gtfsfactory.py#L219-L229
train
google/transitfeed
kmlparser.py
KmlParser.Parse
def Parse(self, filename, feed): """ Reads the kml file, parses it and updated the Google transit feed object with the extracted information. Args: filename - kml file name feed - an instance of Schedule class to be updated """ dom = minidom.parse(filename) self.ParseDom(dom, fe...
python
def Parse(self, filename, feed): """ Reads the kml file, parses it and updated the Google transit feed object with the extracted information. Args: filename - kml file name feed - an instance of Schedule class to be updated """ dom = minidom.parse(filename) self.ParseDom(dom, fe...
[ "def", "Parse", "(", "self", ",", "filename", ",", "feed", ")", ":", "dom", "=", "minidom", ".", "parse", "(", "filename", ")", "self", ".", "ParseDom", "(", "dom", ",", "feed", ")" ]
Reads the kml file, parses it and updated the Google transit feed object with the extracted information. Args: filename - kml file name feed - an instance of Schedule class to be updated
[ "Reads", "the", "kml", "file", "parses", "it", "and", "updated", "the", "Google", "transit", "feed", "object", "with", "the", "extracted", "information", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlparser.py#L61-L71
train
google/transitfeed
kmlparser.py
KmlParser.ParseDom
def ParseDom(self, dom, feed): """ Parses the given kml dom tree and updates the Google transit feed object. Args: dom - kml dom tree feed - an instance of Schedule class to be updated """ shape_num = 0 for node in dom.getElementsByTagName('Placemark'): p = self.ParsePlacemark...
python
def ParseDom(self, dom, feed): """ Parses the given kml dom tree and updates the Google transit feed object. Args: dom - kml dom tree feed - an instance of Schedule class to be updated """ shape_num = 0 for node in dom.getElementsByTagName('Placemark'): p = self.ParsePlacemark...
[ "def", "ParseDom", "(", "self", ",", "dom", ",", "feed", ")", ":", "shape_num", "=", "0", "for", "node", "in", "dom", ".", "getElementsByTagName", "(", "'Placemark'", ")", ":", "p", "=", "self", ".", "ParsePlacemark", "(", "node", ")", "if", "p", "."...
Parses the given kml dom tree and updates the Google transit feed object. Args: dom - kml dom tree feed - an instance of Schedule class to be updated
[ "Parses", "the", "given", "kml", "dom", "tree", "and", "updates", "the", "Google", "transit", "feed", "object", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlparser.py#L73-L89
train
google/transitfeed
examples/google_random_queries.py
Distance
def Distance(lat0, lng0, lat1, lng1): """ Compute the geodesic distance in meters between two points on the surface of the Earth. The latitude and longitude angles are in degrees. Approximate geodesic distance function (Haversine Formula) assuming a perfect sphere of radius 6367 km (see "What are some alg...
python
def Distance(lat0, lng0, lat1, lng1): """ Compute the geodesic distance in meters between two points on the surface of the Earth. The latitude and longitude angles are in degrees. Approximate geodesic distance function (Haversine Formula) assuming a perfect sphere of radius 6367 km (see "What are some alg...
[ "def", "Distance", "(", "lat0", ",", "lng0", ",", "lat1", ",", "lng1", ")", ":", "deg2rad", "=", "math", ".", "pi", "/", "180.0", "lat0", "=", "lat0", "*", "deg2rad", "lng0", "=", "lng0", "*", "deg2rad", "lat1", "=", "lat1", "*", "deg2rad", "lng1",...
Compute the geodesic distance in meters between two points on the surface of the Earth. The latitude and longitude angles are in degrees. Approximate geodesic distance function (Haversine Formula) assuming a perfect sphere of radius 6367 km (see "What are some algorithms for calculating the distance between...
[ "Compute", "the", "geodesic", "distance", "in", "meters", "between", "two", "points", "on", "the", "surface", "of", "the", "Earth", ".", "The", "latitude", "and", "longitude", "angles", "are", "in", "degrees", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/examples/google_random_queries.py#L40-L66
train
google/transitfeed
examples/google_random_queries.py
AddNoiseToLatLng
def AddNoiseToLatLng(lat, lng): """Add up to 500m of error to each coordinate of lat, lng.""" m_per_tenth_lat = Distance(lat, lng, lat + 0.1, lng) m_per_tenth_lng = Distance(lat, lng, lat, lng + 0.1) lat_per_100m = 1 / m_per_tenth_lat * 10 lng_per_100m = 1 / m_per_tenth_lng * 10 return (lat + (lat_per_100m ...
python
def AddNoiseToLatLng(lat, lng): """Add up to 500m of error to each coordinate of lat, lng.""" m_per_tenth_lat = Distance(lat, lng, lat + 0.1, lng) m_per_tenth_lng = Distance(lat, lng, lat, lng + 0.1) lat_per_100m = 1 / m_per_tenth_lat * 10 lng_per_100m = 1 / m_per_tenth_lng * 10 return (lat + (lat_per_100m ...
[ "def", "AddNoiseToLatLng", "(", "lat", ",", "lng", ")", ":", "m_per_tenth_lat", "=", "Distance", "(", "lat", ",", "lng", ",", "lat", "+", "0.1", ",", "lng", ")", "m_per_tenth_lng", "=", "Distance", "(", "lat", ",", "lng", ",", "lat", ",", "lng", "+",...
Add up to 500m of error to each coordinate of lat, lng.
[ "Add", "up", "to", "500m", "of", "error", "to", "each", "coordinate", "of", "lat", "lng", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/examples/google_random_queries.py#L69-L76
train
google/transitfeed
examples/google_random_queries.py
GetRandomDatetime
def GetRandomDatetime(): """Return a datetime in the next week.""" seconds_offset = random.randint(0, 60 * 60 * 24 * 7) dt = datetime.today() + timedelta(seconds=seconds_offset) return dt.replace(second=0, microsecond=0)
python
def GetRandomDatetime(): """Return a datetime in the next week.""" seconds_offset = random.randint(0, 60 * 60 * 24 * 7) dt = datetime.today() + timedelta(seconds=seconds_offset) return dt.replace(second=0, microsecond=0)
[ "def", "GetRandomDatetime", "(", ")", ":", "seconds_offset", "=", "random", ".", "randint", "(", "0", ",", "60", "*", "60", "*", "24", "*", "7", ")", "dt", "=", "datetime", ".", "today", "(", ")", "+", "timedelta", "(", "seconds", "=", "seconds_offse...
Return a datetime in the next week.
[ "Return", "a", "datetime", "in", "the", "next", "week", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/examples/google_random_queries.py#L87-L91
train
google/transitfeed
examples/google_random_queries.py
LatLngsToGoogleLink
def LatLngsToGoogleLink(source, destination): """Return a string "<a ..." for a trip at a random time.""" dt = GetRandomDatetime() return "<a href='%s'>from:%s to:%s on %s</a>" % ( LatLngsToGoogleUrl(source, destination, dt), FormatLatLng(source), FormatLatLng(destination), dt.ctime())
python
def LatLngsToGoogleLink(source, destination): """Return a string "<a ..." for a trip at a random time.""" dt = GetRandomDatetime() return "<a href='%s'>from:%s to:%s on %s</a>" % ( LatLngsToGoogleUrl(source, destination, dt), FormatLatLng(source), FormatLatLng(destination), dt.ctime())
[ "def", "LatLngsToGoogleLink", "(", "source", ",", "destination", ")", ":", "dt", "=", "GetRandomDatetime", "(", ")", "return", "\"<a href='%s'>from:%s to:%s on %s</a>\"", "%", "(", "LatLngsToGoogleUrl", "(", "source", ",", "destination", ",", "dt", ")", ",", "Form...
Return a string "<a ..." for a trip at a random time.
[ "Return", "a", "string", "<a", "...", "for", "a", "trip", "at", "a", "random", "time", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/examples/google_random_queries.py#L113-L119
train
google/transitfeed
examples/google_random_queries.py
ParentAndBaseName
def ParentAndBaseName(path): """Given a path return only the parent name and file name as a string.""" dirname, basename = os.path.split(path) dirname = dirname.rstrip(os.path.sep) if os.path.altsep: dirname = dirname.rstrip(os.path.altsep) _, parentname = os.path.split(dirname) return os.path.join(pare...
python
def ParentAndBaseName(path): """Given a path return only the parent name and file name as a string.""" dirname, basename = os.path.split(path) dirname = dirname.rstrip(os.path.sep) if os.path.altsep: dirname = dirname.rstrip(os.path.altsep) _, parentname = os.path.split(dirname) return os.path.join(pare...
[ "def", "ParentAndBaseName", "(", "path", ")", ":", "dirname", ",", "basename", "=", "os", ".", "path", ".", "split", "(", "path", ")", "dirname", "=", "dirname", ".", "rstrip", "(", "os", ".", "path", ".", "sep", ")", "if", "os", ".", "path", ".", ...
Given a path return only the parent name and file name as a string.
[ "Given", "a", "path", "return", "only", "the", "parent", "name", "and", "file", "name", "as", "a", "string", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/examples/google_random_queries.py#L181-L188
train
google/transitfeed
misc/sql_loop.py
LoadFile
def LoadFile(f, table_name, conn): """Import lines from f as new table in db with cursor c.""" reader = csv.reader(f) header = next(reader) columns = [] for n in header: n = n.replace(' ', '') n = n.replace('-', '_') columns.append(n) create_columns = [] column_types = {} for n in columns:...
python
def LoadFile(f, table_name, conn): """Import lines from f as new table in db with cursor c.""" reader = csv.reader(f) header = next(reader) columns = [] for n in header: n = n.replace(' ', '') n = n.replace('-', '_') columns.append(n) create_columns = [] column_types = {} for n in columns:...
[ "def", "LoadFile", "(", "f", ",", "table_name", ",", "conn", ")", ":", "reader", "=", "csv", ".", "reader", "(", "f", ")", "header", "=", "next", "(", "reader", ")", "columns", "=", "[", "]", "for", "n", "in", "header", ":", "n", "=", "n", ".",...
Import lines from f as new table in db with cursor c.
[ "Import", "lines", "from", "f", "as", "new", "table", "in", "db", "with", "cursor", "c", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/misc/sql_loop.py#L81-L123
train
google/transitfeed
shape_importer.py
PrintColumns
def PrintColumns(shapefile): """ Print the columns of layer 0 of the shapefile to the screen. """ ds = ogr.Open(shapefile) layer = ds.GetLayer(0) if len(layer) == 0: raise ShapeImporterError("Layer 0 has no elements!") feature = layer.GetFeature(0) print("%d features" % feature.GetFieldCount()) f...
python
def PrintColumns(shapefile): """ Print the columns of layer 0 of the shapefile to the screen. """ ds = ogr.Open(shapefile) layer = ds.GetLayer(0) if len(layer) == 0: raise ShapeImporterError("Layer 0 has no elements!") feature = layer.GetFeature(0) print("%d features" % feature.GetFieldCount()) f...
[ "def", "PrintColumns", "(", "shapefile", ")", ":", "ds", "=", "ogr", ".", "Open", "(", "shapefile", ")", "layer", "=", "ds", ".", "GetLayer", "(", "0", ")", "if", "len", "(", "layer", ")", "==", "0", ":", "raise", "ShapeImporterError", "(", "\"Layer ...
Print the columns of layer 0 of the shapefile to the screen.
[ "Print", "the", "columns", "of", "layer", "0", "of", "the", "shapefile", "to", "the", "screen", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/shape_importer.py#L42-L55
train
google/transitfeed
shape_importer.py
AddShapefile
def AddShapefile(shapefile, graph, key_cols): """ Adds shapes found in the given shape filename to the given polyline graph object. """ ds = ogr.Open(shapefile) layer = ds.GetLayer(0) for i in range(0, len(layer)): feature = layer.GetFeature(i) geometry = feature.GetGeometryRef() if key_col...
python
def AddShapefile(shapefile, graph, key_cols): """ Adds shapes found in the given shape filename to the given polyline graph object. """ ds = ogr.Open(shapefile) layer = ds.GetLayer(0) for i in range(0, len(layer)): feature = layer.GetFeature(i) geometry = feature.GetGeometryRef() if key_col...
[ "def", "AddShapefile", "(", "shapefile", ",", "graph", ",", "key_cols", ")", ":", "ds", "=", "ogr", ".", "Open", "(", "shapefile", ")", "layer", "=", "ds", ".", "GetLayer", "(", "0", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "lay...
Adds shapes found in the given shape filename to the given polyline graph object.
[ "Adds", "shapes", "found", "in", "the", "given", "shape", "filename", "to", "the", "given", "polyline", "graph", "object", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/shape_importer.py#L58-L85
train
google/transitfeed
shape_importer.py
GetMatchingShape
def GetMatchingShape(pattern_poly, trip, matches, max_distance, verbosity=0): """ Tries to find a matching shape for the given pattern Poly object, trip, and set of possibly matching Polys from which to choose a match. """ if len(matches) == 0: print ('No matching shape found within max-distance %d for tr...
python
def GetMatchingShape(pattern_poly, trip, matches, max_distance, verbosity=0): """ Tries to find a matching shape for the given pattern Poly object, trip, and set of possibly matching Polys from which to choose a match. """ if len(matches) == 0: print ('No matching shape found within max-distance %d for tr...
[ "def", "GetMatchingShape", "(", "pattern_poly", ",", "trip", ",", "matches", ",", "max_distance", ",", "verbosity", "=", "0", ")", ":", "if", "len", "(", "matches", ")", "==", "0", ":", "print", "(", "'No matching shape found within max-distance %d for trip %s '",...
Tries to find a matching shape for the given pattern Poly object, trip, and set of possibly matching Polys from which to choose a match.
[ "Tries", "to", "find", "a", "matching", "shape", "for", "the", "given", "pattern", "Poly", "object", "trip", "and", "set", "of", "possibly", "matching", "Polys", "from", "which", "to", "choose", "a", "match", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/shape_importer.py#L88-L112
train
google/transitfeed
shape_importer.py
AddExtraShapes
def AddExtraShapes(extra_shapes_txt, graph): """ Add extra shapes into our input set by parsing them out of a GTFS-formatted shapes.txt file. Useful for manually adding lines to a shape file, since it's a pain to edit .shp files. """ print("Adding extra shapes from %s" % extra_shapes_txt) try: tmpdi...
python
def AddExtraShapes(extra_shapes_txt, graph): """ Add extra shapes into our input set by parsing them out of a GTFS-formatted shapes.txt file. Useful for manually adding lines to a shape file, since it's a pain to edit .shp files. """ print("Adding extra shapes from %s" % extra_shapes_txt) try: tmpdi...
[ "def", "AddExtraShapes", "(", "extra_shapes_txt", ",", "graph", ")", ":", "print", "(", "\"Adding extra shapes from %s\"", "%", "extra_shapes_txt", ")", "try", ":", "tmpdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "shutil", ".", "copy", "(", "extra_shapes_tx...
Add extra shapes into our input set by parsing them out of a GTFS-formatted shapes.txt file. Useful for manually adding lines to a shape file, since it's a pain to edit .shp files.
[ "Add", "extra", "shapes", "into", "our", "input", "set", "by", "parsing", "them", "out", "of", "a", "GTFS", "-", "formatted", "shapes", ".", "txt", "file", ".", "Useful", "for", "manually", "adding", "lines", "to", "a", "shape", "file", "since", "it", ...
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/shape_importer.py#L114-L132
train
google/transitfeed
merge.py
ApproximateDistanceBetweenPoints
def ApproximateDistanceBetweenPoints(pa, pb): """Finds the distance between two points on the Earth's surface. This is an approximate distance based on assuming that the Earth is a sphere. The points are specified by their lattitude and longitude. Args: pa: the first (lat, lon) point tuple pb: the sec...
python
def ApproximateDistanceBetweenPoints(pa, pb): """Finds the distance between two points on the Earth's surface. This is an approximate distance based on assuming that the Earth is a sphere. The points are specified by their lattitude and longitude. Args: pa: the first (lat, lon) point tuple pb: the sec...
[ "def", "ApproximateDistanceBetweenPoints", "(", "pa", ",", "pb", ")", ":", "alat", ",", "alon", "=", "pa", "blat", ",", "blon", "=", "pb", "sa", "=", "transitfeed", ".", "Stop", "(", "lat", "=", "alat", ",", "lng", "=", "alon", ")", "sb", "=", "tra...
Finds the distance between two points on the Earth's surface. This is an approximate distance based on assuming that the Earth is a sphere. The points are specified by their lattitude and longitude. Args: pa: the first (lat, lon) point tuple pb: the second (lat, lon) point tuple Returns: The dist...
[ "Finds", "the", "distance", "between", "two", "points", "on", "the", "Earth", "s", "surface", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L63-L80
train
google/transitfeed
merge.py
LoadWithoutErrors
def LoadWithoutErrors(path, memory_db): """"Return a Schedule object loaded from path; sys.exit for any error.""" accumulator = transitfeed.ExceptionProblemAccumulator() loading_problem_handler = MergeProblemReporter(accumulator) try: schedule = transitfeed.Loader(path, mem...
python
def LoadWithoutErrors(path, memory_db): """"Return a Schedule object loaded from path; sys.exit for any error.""" accumulator = transitfeed.ExceptionProblemAccumulator() loading_problem_handler = MergeProblemReporter(accumulator) try: schedule = transitfeed.Loader(path, mem...
[ "def", "LoadWithoutErrors", "(", "path", ",", "memory_db", ")", ":", "accumulator", "=", "transitfeed", ".", "ExceptionProblemAccumulator", "(", ")", "loading_problem_handler", "=", "MergeProblemReporter", "(", "accumulator", ")", "try", ":", "schedule", "=", "trans...
Return a Schedule object loaded from path; sys.exit for any error.
[ "Return", "a", "Schedule", "object", "loaded", "from", "path", ";", "sys", ".", "exit", "for", "any", "error", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L353-L368
train
google/transitfeed
merge.py
HTMLProblemAccumulator._GenerateStatsTable
def _GenerateStatsTable(self, feed_merger): """Generate an HTML table of merge statistics. Args: feed_merger: The FeedMerger instance. Returns: The generated HTML as a string. """ rows = [] rows.append('<tr><th class="header"/><th class="header">Merged</th>' '<th cl...
python
def _GenerateStatsTable(self, feed_merger): """Generate an HTML table of merge statistics. Args: feed_merger: The FeedMerger instance. Returns: The generated HTML as a string. """ rows = [] rows.append('<tr><th class="header"/><th class="header">Merged</th>' '<th cl...
[ "def", "_GenerateStatsTable", "(", "self", ",", "feed_merger", ")", ":", "rows", "=", "[", "]", "rows", ".", "append", "(", "'<tr><th class=\"header\"/><th class=\"header\">Merged</th>'", "'<th class=\"header\">Copied from old feed</th>'", "'<th class=\"header\">Copied from new f...
Generate an HTML table of merge statistics. Args: feed_merger: The FeedMerger instance. Returns: The generated HTML as a string.
[ "Generate", "an", "HTML", "table", "of", "merge", "statistics", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L193-L216
train
google/transitfeed
merge.py
HTMLProblemAccumulator._GenerateSection
def _GenerateSection(self, problem_type): """Generate a listing of the given type of problems. Args: problem_type: The type of problem. This is one of the problem type constants from transitfeed. Returns: The generated HTML as a string. """ if problem_type == transi...
python
def _GenerateSection(self, problem_type): """Generate a listing of the given type of problems. Args: problem_type: The type of problem. This is one of the problem type constants from transitfeed. Returns: The generated HTML as a string. """ if problem_type == transi...
[ "def", "_GenerateSection", "(", "self", ",", "problem_type", ")", ":", "if", "problem_type", "==", "transitfeed", ".", "TYPE_WARNING", ":", "dataset_problems", "=", "self", ".", "_dataset_warnings", "heading", "=", "'Warnings'", "else", ":", "dataset_problems", "=...
Generate a listing of the given type of problems. Args: problem_type: The type of problem. This is one of the problem type constants from transitfeed. Returns: The generated HTML as a string.
[ "Generate", "a", "listing", "of", "the", "given", "type", "of", "problems", "." ]
eb2991a3747ba541b2cb66502b305b6304a1f85f
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/merge.py#L218-L244
train