Package sabx10 :: Package utils :: Module sabx_csv :: Class CsvProcessor
[hide private]
[frames] | no frames]

Class CsvProcessor

source code

                          object --+        
                                   |        
templating.generic.TemplateProcessor --+    
                                       |    
           templating.sabx.SabxProcessor --+
                                           |
                                          CsvProcessor

Merge an SABX 1.0 file and a CSV file. Process it through an SABX 1.0 template and output it into a SABX 1.0 file.

Instance Methods [hide private]
 
__init__(self, template_file=None, man=None)
Adds the id, csv, and generate options to the standard SABX 1.0 template processor.
source code
 
_generate_blank(self) source code
 
process_options(self)
Get the CSV file name.
source code
 
_process_lat_lon(self, lat, lon)
Get the lat, lon, and waypoint corresponding to the lat and lon values passed in.
source code
 
_parse_parking(self, id, item)
Parse the CSV line as if it's a PARK item.
source code
 
_parse_turn(self, id, fromto, seg)
Parse the CSV line as if it's a ROAD item, and remove the turn data from it.
source code
 
_get_segment_waypoints(self, seg)
Get the waypoints for the corresponding segment.
source code
 
_parse_segment(self, id, fromto, seg)
Parse the CSV line as if it's a ROAD item, and remove the segment data from it.
source code
 
_update_segment_fromto(self, seg, tofrom)
Update the fromto field in a segment.
source code
 
_parse_stop(self, id, item)
Parse the CSV line as if it's a STOP item.
source code
 
_parse_poi(self, id, item)
Parse the CSV line as if it's a POI item.
source code
 
_parse_csv(self)
Parse the CSV file and merge it with the SABX 1.0 template data.
source code
 
get_template_data(self)
Update the template data by merging it with the specified CSV data.
source code

Inherited from templating.sabx.SabxProcessor: process_template

Inherited from templating.generic.TemplateProcessor: process

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]

Inherited from templating.sabx.SabxProcessor: in_file, sabx

Inherited from templating.generic.TemplateProcessor: args, man, options, out_file, parser, template_data, template_file, template_path

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, template_file=None, man=None)
(Constructor)

source code 

Adds the id, csv, and generate options to the standard SABX 1.0 template processor.

Parameters:
  • template_file (string) - (optional) file name of template file
  • man (string) - (optional) extended program help
Overrides: object.__init__

process_options(self)

source code 

Get the CSV file name. It's expected to be the last command-line argument. Print a blank CSV file and exit if asked to.

Parameters:
  • arg_count - count of non-optional command-line arguments expected
Raises:
  • NotEnoughArgsException - this exception is raised when there is no template file specified on the command-line
Overrides: templating.generic.TemplateProcessor.process_options

_process_lat_lon(self, lat, lon)

source code 

Get the lat, lon, and waypoint corresponding to the lat and lon values passed in. If lat contains a point id, then the corresponding point is found. Otherwise, the point closest to (lat, lon) is found.

Parameters:
  • lat (string) - latitude or point to search for
  • lon (string) - longitude to search for

_parse_parking(self, id, item)

source code 

Parse the CSV line as if it's a PARK item.

Parameters:
  • id (int) - id for this item
  • item (dict) - CSV line item to parse

_parse_turn(self, id, fromto, seg)

source code 

Parse the CSV line as if it's a ROAD item, and remove the turn data from it.

Parameters:
  • id (int) - id for this item
  • fromto (string) - fromto part of the turn
  • seg (dict) - CSV ROAD item to parse

_get_segment_waypoints(self, seg)

source code 

Get the waypoints for the corresponding segment. These are the points from START POINT to END POINT.

Parameters:
  • seg (SABX 1.0 Segment) - segment to get points for

_parse_segment(self, id, fromto, seg)

source code 

Parse the CSV line as if it's a ROAD item, and remove the segment data from it.

Parameters:
  • id (int) - id for this item
  • fromto (string) - fromto part of the turn
  • seg (dict) - CSV ROAD item to parse

_update_segment_fromto(self, seg, tofrom)

source code 

Update the fromto field in a segment.

Parameters:
  • seg (SABX 1.0 Segment) - segment to update
  • tofrom (string) - value to update with

_parse_stop(self, id, item)

source code 

Parse the CSV line as if it's a STOP item.

Parameters:
  • id (int) - id for this item
  • item (dict) - CSV line item to parse

_parse_poi(self, id, item)

source code 

Parse the CSV line as if it's a POI item.

Parameters:
  • id (int) - id for this item
  • item (dict) - CSV line item to parse

get_template_data(self)

source code 

Update the template data by merging it with the specified CSV data.

Overrides: templating.generic.TemplateProcessor.get_template_data