Ejemplo n.º 1
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)
Ejemplo n.º 2
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('/./', '/')
                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)
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
    def test_empty_line_before_eof(self):
        error = False

        for f in self.md_files:
            if cat(f)[-1][-1] != '\n':
                print('error: in {} has no line break in the end of file'.format(f))
                error = True

        self.assertEqual(False, error)
Ejemplo n.º 5
0
    def test_no_tabs(self):
        error = False

        for f in self.md_files:
            lines = grep(cat(f), "\t")
            if len(lines) > 0:
                print('error: in {} has tabs in {} lines'.format(f, lines))
                error = True

        self.assertEqual(False, error)
Ejemplo n.º 6
0
def check_empty_line_before_eof():
    print_caller_name()
    error = False
    global root
    files = gglob(root, "*.md")
    for f in files:
        if cat(f)[-1][-1] != '\n':
            print('error: in {} has no line break in the end of file'.format(f))
            error = True
    return error
Ejemplo n.º 7
0
    def test_no_tabs(self):
        error = False

        for f in self.md_files:
            lines = grep(cat(f), "\t")
            if len(lines) > 0:
                print('error: in {} has tabs in {} lines'.format(f, lines))
                error = True

        self.assertEqual(False, error)
Ejemplo n.º 8
0
def check_no_trailing_spaces():
    print_caller_name()
    error = False
    global root
    files = gglob(root, "*.md")
    for f in files:
        lines = grep(cat(f), ".*[ ]+$")
        if len(lines) > 0:
            print('error: in {} has space in the end of lines {}'.format(f, lines))
            error = True
    return error
Ejemplo n.º 9
0
def check_no_tabs():
    print_caller_name()
    error = False
    global root
    files = gglob(root, "*.md")
    for f in files:
        lines = grep(cat(f), "\t")
        if len(lines) > 0:
            print('error: in {} has tabs in {} lines'.format(f, lines))
            error = True
    return error
Ejemplo n.º 10
0
    def test_empty_line_before_eof(self):
        error = False

        for f in self.md_files:
            if cat(f)[-1][-1] != '\n':
                print(
                    'error: in {} has no line break in the end of file'.format(
                        f))
                error = True

        self.assertEqual(False, error)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
    def test_use_highlighting(self):
        error = False

        for f in self.md_files:
            p = re.compile(".*```\n[^`]*```\n.*")
            text = ''.join(cat(f))
            m = p.findall(text)
            if m:
                print('error: {} has block code without highlighting:'.format(f))
                for b in m:
                    print('\n{}\n'.format(b))
                error = True

        self.assertEqual(False, error)
Ejemplo n.º 15
0
def check_use_highlighting():
    print_caller_name()
    error = False
    global root
    files = gglob(root, "*.md")
    for f in files:
        p = re.compile(".*```\n[^`]*```\n.*")
        text = ''.join(cat(f))
        m = p.findall(text)
        if m:
            print('error: {} has block code without highlighting:'.format(f))
            for b in m:
                print('\n{}\n'.format(b))
            error = True
    return error
Ejemplo n.º 16
0
    def test_use_highlighting(self):
        error = False

        for f in self.md_files:
            p = re.compile(".*```\n[^`]*```\n.*")
            text = ''.join(cat(f))
            m = p.findall(text)
            if m:
                print(
                    'error: {} has block code without highlighting:'.format(f))
                for b in m:
                    print('\n{}\n'.format(b))
                error = True

        self.assertEqual(False, error)
def extract_questions(tup):
    lines = cat(tup[0])

    questions = make_header(tup)

    copying = False
    for line in lines:
        if copying:
            if line.startswith("#"):
                break
            else:
                questions += line

        if line.startswith(header):
            copying = True

    return questions
def extract_questions(tup):
    lines = cat(tup[0])

    questions = make_header(tup)

    copying = False
    for line in lines:
        if copying:
            if line.startswith("#"):
                break;
            else:
                questions += line

        if line.startswith(header):
            copying = True

    return questions
Ejemplo n.º 19
0
 def test_no_trailing_spaces(self):
     for file in self.md_files:
         lines = grep(cat(file), ".*[ ]+$")
         self.assertEqual(0, len(lines))
Ejemplo n.º 20
0
 def test_no_trailing_spaces(self):
     for file in self.md_files:
         lines = grep(cat(file), ".*[ ]+$")
         self.assertEqual(0, len(lines))
def check_if_control_questions_exist(file):
    lines = cat(file)
    findings = grep(lines, header)
    return len(findings)
def check_if_control_questions_exist(file):
    lines = cat(file)
    findings = grep(lines, header)
    return len(findings)