def __init__(self, path, logger: Logger): self.logger = logger self.path = path self.table_name = "runs" self.conn = None self.columns = set(RunEntry.fields()) self.key = "path" self.fields = RunEntry.fields()
def __init__(self, path, logger: Logger): self.logger = logger self.path = path self.table_name = 'runs' self.conn = None self.columns = set(RunEntry.fields()) self.key = 'path' self.fields = RunEntry.fields() self.condition = f"""
def add_subparser(subparsers): parser = subparsers.add_parser( 'lookup', help="Lookup specific value associated with database entry.") parser.add_argument( 'key', choices=RunEntry.fields() + ('all', ), help='Key that value is associated with.') add_query_flags(parser, with_sort=True) parser.add_argument( '--porcelain', action='store_true', help='Print value only (for use with scripts)') return parser
def add_subparser(subparsers): parser = subparsers.add_parser( "lookup", help="Lookup specific value associated with database entry." ) parser.add_argument( "key", choices=RunEntry.fields() + ("all",), help="Key that value is associated with.", ) add_query_args(parser, with_sort=True) parser.add_argument( "--porcelain", action="store_true", help="Print value only (for use with scripts)", ) return parser
PathLike = Union[str, PurePath, PurePath, Path] DEFAULT_QUERY_FLAGS = { 'patterns': dict(nargs='*', type=PurePath, help='Look up runs matching these patterns'), '--unless': dict(nargs='*', type=PurePath, help='Exclude these paths from the search.'), '--active': dict(action='store_true', help='Include all active runs in query.'), '--descendants': dict(action='store_true', help='Include all descendants of pattern.'), '--sort': dict(default='datetime', choices=RunEntry.fields(), help='Sort query by this field.') } def add_query_flags( parser, with_sort: bool, default_flags: dict = DEFAULT_QUERY_FLAGS, ): if not with_sort: default_flags = copy(default_flags) del default_flags['--sort'] for arg_name, kwargs in default_flags.items(): parser.add_argument(arg_name, **kwargs)
return datetime.strptime("2002-12-04", "%Y-%m-%dT%H:%M:%S.%f%z") DEFAULT_QUERY_ARGS = { "patterns": dict( nargs="*", type=PurePath, help="Look up runs matching these patterns" ), "--unless": dict( nargs="*", type=PurePath, help="Exclude these paths from the search." ), "--active": dict(action="store_true", help="Include all active runs in query."), "--descendants": dict( action="store_true", help="Include all descendants of pattern." ), "--sort": dict( default="datetime", choices=RunEntry.fields(), help="Sort query by this field." ), "--since": dict( default=None, type=date_parse, help="Only display runs since this date. Accepts argument in isoformat.", ), "--last": dict( default=None, type=parse_time_delta, help="Only display runs created in the given time delta. " 'Either use "months", "weeks", "days", "hours" to specify time, e.g.' '"2weeks1day" or specify a date: month/day/year.', ), }