def read_command_line(): """Returns a dict containing the arguments specified on the command line""" parser = argparse.ArgumentParser(description="Mount an S3 bucket as a read-only filesystem") # All arguments must default to None so that they can be filtered # out of the returned dictionary; otherwise, the argument defaults # will override settings from the configuration file. parser.add_argument("mount-point", help="where to mount the bucket") parser.add_argument("--bucket", dest="bucket", help="S3 bucket to mount") parser.add_argument("--access-key", dest="access-key", help="access key for the bucket") parser.add_argument("--secret-key", dest="secret-key", help="secret key for the bucket") parser.add_argument( "--config-file", dest="config-file", default="~/.s3viewport.yaml", help="path to the configuration file" ) parser.add_argument( "--no-input", dest="no-input", action="store_true", default=None, help="don't prompt for missing information" ) parser.add_argument( "--foreground", dest="foreground", action="store_true", default=None, help="run filesystem server in the foreground", ) # TODO: Describe configuration file format args = parser.parse_args() return filter_dict(vars(args), lambda k, v: v is not None)
def read_command_line(): """Returns a dict containing the arguments specified on the command line""" parser = argparse.ArgumentParser( description='Mount an S3 bucket as a read-only filesystem') # All arguments must default to None so that they can be filtered # out of the returned dictionary; otherwise, the argument defaults # will override settings from the configuration file. parser.add_argument('mount-point', help='where to mount the bucket') parser.add_argument('--bucket', dest='bucket', help='S3 bucket to mount') parser.add_argument('--access-key', dest='access-key', help='access key for the bucket') parser.add_argument('--secret-key', dest='secret-key', help='secret key for the bucket') parser.add_argument('--config-file', dest='config-file', default='~/.s3viewport.yaml', help='path to the configuration file') parser.add_argument('--no-input', dest='no-input', action='store_true', default=None, help="don't prompt for missing information") parser.add_argument('--foreground', dest='foreground', action='store_true', default=None, help='run filesystem server in the foreground') # TODO: Describe configuration file format args = parser.parse_args() return filter_dict(vars(args), lambda k, v: v is not None)
def expire(self): now = datetime.now() self.cache = filter_dict( self.cache, lambda k, v: v.timestamp + self.lifetime >= now)