예제 #1
0
def main():
    # searching
    # Create instance of FieldStorage
    form = cgi.FieldStorage()
    request = form.getvalue("request")
    if not request:
        request = "."
    database = engine.load_database(True)
    request_re = re.compile(".*" + request + ".*", re.IGNORECASE)

    results = []
    for file_info in database:
        if request_re.match(file_info.name_):
            results.append(file_info)
    print_page.head(request)
    print_page.results(results)
    print_page.tail()

    exit(0)
예제 #2
0
def main():
    # searching
    # Create instance of FieldStorage
    form = cgi.FieldStorage()
    request = form.getvalue('request')
    if not request:
        request = "."
    database = engine.load_database(True)
    request_re = re.compile(".*" + request + ".*", re.IGNORECASE)

    results = []
    for file_info in database:
        if request_re.match(file_info.name_):
            results.append(file_info)
    print_page.head(request)
    print_page.results(results)
    print_page.tail()

    exit(0)
예제 #3
0
def main():
    # indexing mode
    if len(sys.argv) != 2:
        print("wrong usage")
        exit(0)
    database_old = engine.load_database(False)
    database_new = engine.index_folder(sys.argv[1])
    for file_info_new in database_new:
        file_presented = False
        for file_info_old in database_old:
            if file_info_new.name_ == file_info_old.name_:
                file_presented = True
                break
        if not file_presented:
            database_old.append(file_info_new)
    engine.store_database(database_old)
    for f in database_old:
        print(f.name_)
    exit(0)
예제 #4
0
def main():
    # indexing mode
    if len(sys.argv) != 2:
        print("wrong usage")
        exit(0)
    database_old = engine.load_database(False)
    database_new = engine.index_folder(sys.argv[1])
    for file_info_new in database_new:
        file_presented = False
        for file_info_old in database_old:
            if file_info_new.name_ == file_info_old.name_:
                file_presented = True
                break
        if not file_presented:
            database_old.append(file_info_new)
    engine.store_database(database_old)
    for f in database_old:
        print(f.name_)
    exit(0)