- # RFC5545 and RFC5546 Calendars should be generated UTF-8 and we need to
- # be able to read ANSI as well. This should take care of us.
- content = unicode(content, encoding='utf-8')
+if __name__ == '__main__':
+ from optparse import OptionParser
+ # If the user passed us a 'stdin' argument, we'll go with that,
+ # otherwise we'll try for a url opener
+
+ parser = OptionParser('usage: %prog [options] url')
+ parser.add_option('-s', '--stdin', action='store_true', dest='stdin',
+ default=False, help='Take a calendar from standard input')
+ parser.add_option('-o', '--output', dest='outfile', default='',
+ help='Specify output file (defaults to standard output)')
+
+ (options, args) = parser.parse_args()
+
+ if not args and not options.stdin:
+ parser.print_usage()
+ sys.exit(0)
+ elif not options.stdin:
+ url = args[0]
+ else:
+ url = ''
+
+ content = getContent(url, options.stdin)
+ cal = lineJoiner(content)
+ ical = applyRules(splitFields(cal), generateRules())
+ print ical