On 08/01/16 14:04, sebastian cheung via Tutor wrote: > * take an s3 destination path as an argument optionally containing the string > ++DATE++ as a placeholder (e.g. s3://my-bucket/objects/++DATE++/, > s3://my-bucket/objects/++DATE++/file-++DATE++.txt and s3://my-bucket/objects/ > should all be valid) > I already have something for something more simple, but for s3 maybe use > awscli etc? Thanks Seb
I have no idea what you are asking about (other than I assume its something related to AWS?). This is the python tutor list for answering questions about the Python language and its standard library. Did you mean to post here? If so you need to give us a bit more information about what you are doing and what exactly you want help with. > def dateType(string): > """ > Convert a date string to a date object > """ > try: > date = datetime.datetime.strptime(string, '%Y-%m-%d').date() > except ValueError: > msg = "%r is not a valid date" % string > raise argparse.ArgumentTypeError(msg) > return date > > > def is_valid_file(parser, arg): > if not os.path.exists(arg): > parser.error("The file %s does not exist!" % arg) > else: > return open(arg, 'r')parser = argparse.ArgumentParser( > description="Take CLI options called start-date and end-date, which > must be formatted YYYY-MM-DD. " > "These should default to today if not supplied", > epilog="See http://bitbucket.org/niceseb/ for details about the > Project Time Tracker.") > parser.add_argument('-e', '--end-date', metavar='DATE', type=dateType, > default=datetime.date.today(), > help='the date tracking data should start at, inclusive > in the format YYYY-MM-DD (defaults to today)') > parser.add_argument('-s', '--start-date', metavar='DATE', type=dateType, > default=datetime.date.today(), > help='the date tracking data should end at, inclusive > in the format YYYY-MM-DD (defaults to today)') > parser.add_argument('-v', action='version', version='%(prog)s 1.0') > parser.add_argument('-i', dest="filename", required=False, help="input file > name", metavar="FILE", > type=lambda x: is_valid_file(parser, x)) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor