def check_all_images_are_used():
    print_caller_name()
    error = False
    global root

    files = gglob(root, "*.md")
    for f in files:
        path = os.path.dirname(os.path.abspath(f))
        if not os.path.exists(path + "/pix"):
            continue

        existing_images = gglob(path, "*.png")  + gglob(path, "*.jpg") +\
                     gglob(path, "*.jpeg") + gglob(path, "*.gif") +\
                     gglob(path, "*.svg")

        mentioned_images = get_grep(cat(f), "!\[\]\(([^)]*)\)")

        for img in mentioned_images:
            full_path = os.path.join(path, img).replace('/./', '/')
            if os.path.exists(full_path) and (full_path in existing_images):
                existing_images.remove(full_path)

        if len(existing_images) > 0:
            print("images are not used: ")
            for i in existing_images:
                print('      - {}'.format(i))
            error = True  # TODO: change to Truem so check fails

    return error
    def test_all_images_are_used(self):
        error = False

        for f in self.md_files:
            path = os.path.dirname(os.path.abspath(f))
            if not os.path.exists(path + "/pix"):
                continue

            existing_images = gglob(path, "*.png")  + gglob(path, "*.jpg") +\
                         gglob(path, "*.jpeg") + gglob(path, "*.gif") +\
                         gglob(path, "*.svg")

            mentioned_images = get_grep(cat(f), "!\[\]\(([^)]*)\)")

            for img in mentioned_images:
                full_path = os.path.join(path, img).replace('/./', '/')
                if os.path.exists(full_path) and (full_path in existing_images):
                    existing_images.remove(full_path)

            if len(existing_images) > 0:
                print("images are not used: ")
                for i in existing_images:
                    print('      - {}'.format(i))
                error = True

        self.assertEqual(False, error)
Exemple #3
0
    def test_all_images_are_used(self):
        error = False

        for f in self.md_files:
            path = os.path.dirname(os.path.abspath(f))
            if not os.path.exists(path + "/pix"):
                continue

            existing_images = gglob(path, "*.png")  + gglob(path, "*.jpg") +\
                         gglob(path, "*.jpeg") + gglob(path, "*.gif") +\
                         gglob(path, "*.svg")

            mentioned_images = get_grep(cat(f), "!\[\]\(([^)]*)\)")

            for img in mentioned_images:
                full_path = os.path.join(path,
                                         img).replace('/./', '/').replace(
                                             '\./pix/', '\\pix\\')
                if os.path.exists(full_path) and (full_path
                                                  in existing_images):
                    existing_images.remove(full_path)

            if len(existing_images) > 0:
                print("images are not used: ")
                for i in existing_images:
                    print('      - {}'.format(i))
                error = True

        self.assertEqual(False, error)
    def test_all_images_exist(self):
        error = False

        for f in self.md_files:
            path = os.path.dirname(os.path.abspath(f))
            m = get_grep(cat(f), "!\[\]\(([^)]*)\)")
            for img in m:
                full_path = os.path.join(path, img).replace('/./', '/')
                if not os.path.exists(full_path):
                    print('error: {} does not exist'.format(full_path))
                    error = True

        self.assertEqual(False, error)
Exemple #5
0
    def test_all_images_exist(self):
        error = False

        for f in self.md_files:
            path = os.path.dirname(os.path.abspath(f))
            m = get_grep(cat(f), "!\[\]\(([^)]*)\)")
            for img in m:
                full_path = os.path.join(path, img).replace('/./', '/')
                if not os.path.exists(full_path):
                    print('error: {} does not exist'.format(full_path))
                    error = True

        self.assertEqual(False, error)
def check_all_images_exist():
    print_caller_name()
    error = False
    global root
    files = gglob(root, "*.md")
    for f in files:
        path = os.path.dirname(os.path.abspath(f))
        m = get_grep(cat(f), "!\[\]\(([^)]*)\)")
        for img in m:
            full_path = os.path.join(path, img).replace('/./', '/')
            if not os.path.exists(full_path):
                print('error: {} does not exist'.format(full_path))
                error = True
    return error