Commit 5336f30d authored by Martí Bolívar's avatar Martí Bolívar Committed by Carles Cufi
Browse files

doc: make extract_content.py flake8 clean



Address flake8's complaints.

Signed-off-by: default avatarMarti Bolivar <marti@foundries.io>
parent e3eb8e77
Loading
Loading
Loading
Loading
+21 −17
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
# to fix the website and external links

import argparse
import errno
import filecmp
import fnmatch
import os
@@ -30,6 +29,7 @@ if "ZEPHYR_BUILD" in os.environ:
else:
    ZEPHYR_BUILD = None


def copy_if_different(src, dst):
    # Copies 'src' as 'dst', but only if dst does not exist or if itx contents
    # differ from src.This avoids unnecessary # timestamp updates, which
@@ -38,11 +38,13 @@ def copy_if_different(src, dst):
        return
    shutil.copyfile(src, dst)


def get_files(all, dest, dir):
    matches = []
    for root, dirnames, filenames in os.walk('%s/%s' % (ZEPHYR_BASE, dir)):
        if ZEPHYR_BUILD:
            if os.path.normpath(root).startswith(os.path.normpath(ZEPHYR_BUILD)):
            if os.path.normpath(root).startswith(
                    os.path.normpath(ZEPHYR_BUILD)):
                # Build folder, skip it
                continue

@@ -82,7 +84,8 @@ def get_files(all, dest, dir):
                        copy_if_different(src, dst)

                    except FileNotFoundError:
                        sys.stderr.write("File not found: %s\n  reference by %s\n" % (inf, file))
                        print("File not found:", inf, "\n  referenced by:",
                              file, file=sys.stderr)

        except UnicodeDecodeError as e:
            sys.stderr.write(
@@ -97,16 +100,16 @@ def get_files(all, dest, dir):

        f.close()

def main():

    parser = argparse.ArgumentParser(description='Recursively copy .rst files '
                                     'from the origin folder(s) to the '
                                     'destination folder, plus files referenced '
                                     'in those .rst files by a configurable '
                                     'list of directives: {}.'.format(DIRECTIVES))

    parser.add_argument('-a', '--all', action='store_true', help='Copy all files '
                        '(recursively) in the specified source folder(s).')
def main():
    parser = argparse.ArgumentParser(
        description='''Recursively copy .rst files from the origin folder(s) to
        the destination folder, plus files referenced in those .rst files by a
        configurable list of directives: {}.'''.format(DIRECTIVES))

    parser.add_argument('-a', '--all', action='store_true',
                        help='''Copy all files (recursively) in the specified
                        source folder(s).''')
    parser.add_argument('dest', nargs=1)
    parser.add_argument('src', nargs='+')
    args = parser.parse_args()
@@ -116,5 +119,6 @@ def main():
    for d in args.src:
        get_files(args.all, dest, d)


if __name__ == "__main__":
    main()