Browse Source

Remove debug option, always write pretty KML.

debian-sid
Tom Payne 14 years ago
parent
commit
6756fcc0cb
  1. 6
      bin/igc2kmz.py
  2. 5
      bin/leonardo2kmz.py
  3. 7
      igc2kmz/kmz.py

6
bin/igc2kmz.py

@ -84,9 +84,6 @@ def main(argv):
help='add root element')
parser.add_option('-t', '--task', metavar='FILENAME',
help='set task')
parser.add_option('--debug',
action='store_true',
help='enable pretty KML output')
group = optparse.OptionGroup(parser, 'Per-flight options')
group.add_option('-i', '--igc', metavar='FILENAME', type='string',
action='callback', callback=add_flight,
@ -119,7 +116,6 @@ def main(argv):
help='set photo comment')
parser.add_option_group(group)
#
parser.set_defaults(debug=False)
parser.set_defaults(flights=[])
parser.set_defaults(output='igc2kmz.kmz')
parser.set_defaults(roots=[])
@ -137,7 +133,7 @@ def main(argv):
roots=roots,
tz_offset=options.tz_offset,
task=task)
kmz.write(options.output, '2.2', debug=options.debug)
kmz.write(options.output, '2.2')
if __name__ == '__main__':

5
bin/leonardo2kmz.py

@ -126,8 +126,6 @@ def main(argv):
help='set table prefix')
parser.add_option('-x', '--igc-suffix', metavar='STRING',
help='set IGC file suffix')
parser.add_option('--debug', action='store_true',
help='enable pretty KML output')
parser.set_defaults(output='igc2kmz.kmz')
parser.set_defaults(name=DEFAULT_NAME)
parser.set_defaults(icon=DEFAULT_ICON)
@ -136,7 +134,6 @@ def main(argv):
parser.set_defaults(tz_offset=0)
parser.set_defaults(table_prefix=DEFAULT_TABLE_PREFIX)
parser.set_defaults(igc_suffix='.saned.full.igc')
parser.set_defaults(debug=False)
options, args = parser.parse_args(argv)
#
flights_dir = os.path.join(options.directory,
@ -239,7 +236,7 @@ def main(argv):
roots.append(make_takeoff_placemark(takeoff_row))
#
kmz = flights2kmz(flights, roots=roots, tz_offset=options.tz_offset)
kmz.write(options.output, '2.2', debug=options.debug)
kmz.write(options.output, '2.2')
if __name__ == '__main__':
main(sys.argv)

7
igc2kmz/kmz.py

@ -62,17 +62,14 @@ class kmz(object):
self.elements.append(kml.__dict__[key](value))
return self
def write(self, filename, version, debug=False):
def write(self, filename, version):
date_time = datetime.datetime.now().timetuple()[:6]
zf = zipfile.ZipFile(filename, 'w')
document = kml.Document()
document.add(*self.roots)
document.add(*self.elements)
string_io = StringIO()
if debug:
kml.kml(version, document).pretty_write(string_io)
else:
kml.kml(version, document).write(string_io)
kml.kml(version, document).pretty_write(string_io)
zi = zipfile.ZipInfo('doc.kml')
zi.compress_type = zipfile.ZIP_DEFLATED
zi.date_time = date_time

Loading…
Cancel
Save