def main():
    """Create a Whoosh index for a PO file.

    Given a PO file, enumerates all the strings, and creates a Whoosh index to
    be able to search later.
    """
    print("Create Whoosh index from a PO file")
    print("Use --help for assistance")

    start_time = time.time()

    try:
        locale.setlocale(locale.LC_ALL, '')
    except Exception as detail:
        print("Exception: " + str(detail))

    po_directory, debug_keyword, projects_names = read_parameters()
    indexCreator = IndexCreator(po_directory)
    indexCreator.debug_keyword = debug_keyword
    indexCreator.projects_names = projects_names
    indexCreator.create()
    indexCreator.process_projects()

    _write_statistics(indexCreator.projects, indexCreator.words)
    _write_select_projects(indexCreator.options)

    end_time = time.time() - start_time
    print("time used to create the index: " + str(end_time))
示例#2
0
def main():
    print("Create Whoosh index from a directory with JSONs")

    start_time = datetime.datetime.now()

    indexCreator = IndexCreator("data/jsons/")
    indexCreator.create()
    indexCreator.process_files()
    indexCreator.save_index()

    print(
        "Time used to create the index: {0} ".format(datetime.datetime.now() -
                                                     start_time))
示例#3
0
def main():
    """Create a Whoosh index for a PO file.

    Given a PO file, enumerates all the strings, and creates a Whoosh index to
    be able to search later.
    """
    print("Create Whoosh index from a PO file")
    print("Use --help for assistance")

    start_time = time.time()

    try:
        locale.setlocale(locale.LC_ALL, '')
    except Exception as detail:
        print("Exception: " + str(detail))

    po_directory, debug_keyword, projects_names = read_parameters()
    indexCreator = IndexCreator(po_directory, debug_keyword, projects_names)
    indexCreator.create()
    indexCreator.process_projects()

    ctx = {
        'date': datetime.date.today().strftime("%d/%m/%Y"),
        'projects': str(indexCreator.projects),
        'words': locale.format("%d", indexCreator.words, grouping=True),
    }
    process_template("templates/statistics.mustache", "statistics.html", ctx)

    ctx = {
        # This is the list of projects to display for the user to select.
        'options': sorted(indexCreator.options, key=lambda x: x.lower()),
    }
    process_template("templates/select-projects.mustache",
                     "select-projects.html", ctx)

    end_time = time.time() - start_time
    print("time used to create the index: " + str(end_time))