trovotutto/__init__.py
def main():
    """Function for command line execution"""

    parser = ArgumentParser(description="search files using n-grams")
    parser.add_argument('--path', dest='path', help="where to search", nargs=1, action="store", default=getcwd())
    parser.add_argument('--update', dest='update', help="update the index", action='store_true', default=True)
    parser.add_argument('--filetype', dest='filetype', help="any, images, documents, code, audio, video", nargs=1, action="store", default=["any"])
    parser.add_argument('--verbose', dest='verbose', help="extended output", action='store_true', default=False)
    parser.add_argument('--results', dest='results', help="number of results to display", action="store", default=10)
    parser.add_argument('query', nargs='+', help="what to search", action="store")
    args = parser.parse_args()

    if args.verbose:
        verbose = 2
        pprint(args)
    else:
        verbose = 0
 
    query = args.query[0]
    for arg in args.query[1:]:
        query = query + " " + arg
    slb = min([len(w) for w in query.split(" ")])

    files = Files(path=args.path, filetype=args.filetype[0], exclude=[], update=args.update, verbose=verbose)
    index = Index(files, slb=slb, verbose=verbose)
    results = index.search(query, verbose=verbose)
    Handler(results, results_number=int(args.results))
def main():
    """Function for command line execution"""

    parser = ArgumentParser(description="search files using n-grams")
    parser.add_argument('--path', dest='path', help="where to search", nargs=1, action="store", default=getcwd())
    parser.add_argument('--update', dest='update', help="update the index", action='store_true', default=True)
    parser.add_argument('--filetype', dest='filetype', help="any, images, documents, code, audio, video", nargs=1, action="store", default=["any"])
    parser.add_argument('--verbose', dest='verbose', help="extended output", action='store_true', default=False)
    parser.add_argument('--results', dest='results', help="number of results to display", action="store", default=10)
    parser.add_argument('query', nargs='+', help="what to search", action="store")
    args = parser.parse_args()

    if args.verbose:
        verbose = 2
        pprint(args)
    else:
        verbose = 0
 
    query = args.query[0]
    for arg in args.query[1:]:
        query = query + " " + arg
    slb = min([len(w) for w in query.split(" ")])

    files = Files(path=args.path, filetype=args.filetype[0], exclude=[], update=args.update, verbose=verbose)
    index = Index(files, slb=slb, verbose=verbose)
    results = index.search(query, verbose=verbose)
    Handler(results, results_number=int(args.results))
def main ( ) : parser = ArgumentParser ( description = "search files using n-grams" ) parser . add_argument ( '--path' , dest = 'path' , help = "where to search" , nargs = 1 , action = "store" , default = getcwd ( ) ) parser . add_argument ( '--update' , dest = 'update' , help = "update the index" , action = 'store_true' , default = True ) parser . add_argument ( '--filetype' , dest = 'filetype' , help = "any, images, documents, code, audio, video" , nargs = 1 , action = "store" , default = [ "any" ] ) parser . add_argument ( '--verbose' , dest = 'verbose' , help = "extended output" , action = 'store_true' , default = False ) parser . add_argument ( '--results' , dest = 'results' , help = "number of results to display" , action = "store" , default = 10 ) parser . add_argument ( 'query' , nargs = '+' , help = "what to search" , action = "store" ) args = parser . parse_args ( ) if args . verbose : verbose = 2 pprint ( args ) else : verbose = 0 query = args . query [ 0 ] for arg in args . query [ 1 : ] : query = query + " " + arg slb = min ( [ len ( w ) for w in query . split ( " " ) ] ) files = Files ( path = args . path , filetype = args . filetype [ 0 ] , exclude = [ ] , update = args . update , verbose = verbose ) index = Index ( files , slb = slb , verbose = verbose ) results = index . search ( query , verbose = verbose ) Handler ( results , results_number = int ( args . results ) )
Function for command line execution
Function for command line execution