Browse Source

Merge branch 'master' of git://github.com/twpayne/igc2kmz

cfd
marc 13 years ago
parent
commit
8de99addb4
  1. 15
      bin/leonardo2kmz.py
  2. 2
      igc2kmz/__init__.py
  3. 4
      igc2kmz/task.py

15
bin/leonardo2kmz.py

@ -134,8 +134,10 @@ def main(argv):
help='set table prefix')
parser.add_option('-x', '--igc-suffix', metavar='STRING',
help='set IGC file suffix')
parser.add_option('-I', '--igc-path', metavar='STRING', help='set IGC path')
parser.add_option('-P', '--photos-path', metavar='STRING', help='set photos path')
parser.add_option('-I', '--igc-path', metavar='STRING',
help='set IGC path')
parser.add_option('-P', '--photos-path', metavar='STRING',
help='set photos path')
parser.set_defaults(output='igc2kmz.kmz')
parser.set_defaults(name=DEFAULT_NAME)
parser.set_defaults(icon=DEFAULT_ICON)
@ -176,11 +178,11 @@ def main(argv):
pilot_id = '%(userServerID)d_%(userID)d' % flight_row
else:
pilot_id = flight_row.userID
substituions = {
substitutions = {
'PILOTID': str(pilot_id),
'YEAR': str(flight_row.DATE.year),
}
igc_path = os.path.join(substitute(options.igc_path, substituions),
igc_path = os.path.join(substitute(options.igc_path, substitutions),
flight_row.filename + options.igc_suffix)
track = IGC(open(igc_path), date=flight_row.DATE).track()
flight = Flight(track)
@ -234,8 +236,9 @@ def main(argv):
== flight_row.ID)
for photo_row in select.execute().fetchall():
photo_url = options.url + PHOTO_URL % photo_row
photo_path = os.path.join(substitute(options.photo_path, substituions),
flight_row.filename + options.photo_suffix)
photo_path = os.path.join(substitute(options.photos_path,
substitutions),
photo_row.path, photo_row.name)
photo = Photo(photo_url, path=photo_path)
if photo_row.description:
photo.description = photo_row.description

2
igc2kmz/__init__.py

@ -52,7 +52,7 @@ def make_table(rows, bgcolors='#dddddd #ffffff'.split()):
trs = ('<tr bgcolor="%s"><th align="right">%s</th><td>%s</td></tr>'
% (bgcolor, row[0], row[1])
for row, bgcolor in izip(rows, cycle(bgcolors)))
return '<table cellpadding="0" cellspacing="0">%s</table>' % ''.join(trs)
return '<table cellpadding="1" cellspacing="1">%s</table>' % ''.join(trs)
class Stock(object):

4
igc2kmz/task.py

@ -126,11 +126,11 @@ class Task(object):
name_tag = element.find('{%s}name' % namespace)
name = None if name_tag is None else name_tag.text.encode('utf_8')
rtepts = element.findall('{%s}rtept' % namespace)
tps = map(Turnpoint.from_element, rtepts)
tps = [Turnpoint.from_element(rtept, namespace) for rtept in rtepts]
return cls(name, tps)
@classmethod
def from_file(cls, file):
element = parse(file)
namespace = re.match('\{(.*)\}', element.getroot().tag).group(1)
return cls.from_element(element.find('/{%s}rte' % namespace), element)
return cls.from_element(element.find('/{%s}rte' % namespace), namespace)

Loading…
Cancel
Save