def main(infile): '''After setting up all parameters, finally try to process input data.''' parsed_data = inputclass(infile) parsed_points = parsed_data.points # processing options if options.xy_only: for feature in parsed_points: geom_cls = getattr(totalopenstation.formats, feature.geometry.geom_type) try: feature.geometry = geom_cls(feature.geometry.x, feature.geometry.y) except: feature.geometry = geom_cls([(p.x, p.y) for p in feature.geometry.geoms]) output = outputclass(parsed_points) def write_to_file(outfile): e = open(outfile, 'w') e.write(output.process()) e.close() if options.outfile: if not os.path.exists(options.outfile): write_to_file(options.outfile) print _("Downloaded data saved to out file %s") % options.outfile else: if options.overwrite: write_to_file(options.outfile) print _("Downloaded data saved to file %s,") % options.outfile, print _("overwriting the existing file") else: sys.exit(_("Specified output file already exists\n")) else: sys.stdout.write(output.process())
def main(infile): '''After setting up all parameters, finally try to process input data.''' parsed_data = inputclass(infile) if options.raw: parsed_points = parsed_data.raw_line else: parsed_points = parsed_data.points # processing options if options.xy_only: for feature in parsed_points: geom_cls = getattr(totalopenstation.formats, feature.geometry.geom_type) try: feature.geometry = geom_cls(feature.geometry.x, feature.geometry.y) except: feature.geometry = geom_cls([(p.x, p.y) for p in feature.geometry.geoms]) output = outputclass(parsed_points) def write_to_file(outfile): e = open(outfile, 'w') e.write(output.process()) e.close() if options.outfile: if not os.path.exists(options.outfile): write_to_file(options.outfile) logger.info( _("Downloaded data saved to out file %s") % options.outfile) else: if options.overwrite: write_to_file(options.outfile) logger.info( _("Downloaded data saved to file %s,") % (options.outfile)) logger.info(_("overwriting the existing file")) else: sys.exit(_("Specified output file already exists\n")) else: sys.stdout.write(output.process())
def write_to_file(outfile): e = open(outfile, 'w') e.write(output.process()) e.close()