def main()

in scripts/linkchecker.py [0:0]


def main():
    """The main entry of the program."""
    global ARGS, ROOT, REDIRECTS

    ARGS = parse_arguments()
    print("Language: " + ARGS.lang)
    ROOT = os.path.join(os.path.dirname(__file__), '..')
    content_dir = os.path.join(ROOT, 'content')
    lang_dir = os.path.join(content_dir, ARGS.lang)

    # read redirects data
    redirects_fn = os.path.join(ROOT, "static", "_redirects")
    try:
        with open(redirects_fn, "r") as f:
            data = f.readlines()
        for item in data:
            parts = item.split()
            # There are entries without 301 specified
            if len(parts) < 2:
                continue
            entry = parts[0]
            # There are some entries not ended with "/"
            if entry.endswith("/"):
                REDIRECTS[entry] = parts[1]
            else:
                REDIRECTS[entry + "/"] = parts[1]

    except Exception as ex:
        print("[Error] failed in reading redirects file: " + str(ex))
        return

    folders = [f for f in glob.glob(lang_dir + ARGS.filter, recursive=True)]
    for page in folders:
        validate_links(page)

    dump_result()

    # Done
    print("Completed link validation.")