|
13 | 13 | import time
|
14 | 14 | import yaml
|
15 | 15 |
|
| 16 | +from aura import cli |
| 17 | + |
| 18 | +cli.init_logging(False, True) |
| 19 | + |
| 20 | +has_errors = False |
16 | 21 | CLONE_DIR = "."
|
17 | 22 | BASE_PORTAL_URL = "https://access.redhat.com/documentation/en-us/"
|
18 | 23 | ID_RE = re.compile("^\[(?:\[|id=\'|#)(.*?)(\'?,.*?)?(?:\]|\')?\]", re.M | re.DOTALL)
|
@@ -405,7 +410,8 @@ def copy_file(info, book_src_dir, src_file, dest_dir, dest_file, include_check=T
|
405 | 410 |
|
406 | 411 | # Check for any includes
|
407 | 412 | if include_check:
|
408 |
| - include_iter = INCLUDE_RE.finditer(content) |
| 413 | + cleaned_content = remove_conditional_content(content, info, tag=tag) |
| 414 | + include_iter = INCLUDE_RE.finditer(cleaned_content) |
409 | 415 | for include in include_iter:
|
410 | 416 | include_text = include.group(0)
|
411 | 417 | include_path = include.group(1)
|
@@ -605,7 +611,8 @@ def _fix_links(content, book_dir, src_file, info, tag=None, cwd=None):
|
605 | 611 | fixed_link = link_text
|
606 | 612 | if EXTERNAL_LINK_RE.search(link_file) is not None:
|
607 | 613 | rel_src_file = src_file.replace(os.path.dirname(book_dir) + "/", "")
|
608 |
| - log.warning("WARNING (%s): \"%s\" appears to try to reference a file not included in the \"%s\" distro", rel_src_file, link_text.replace("\n", ""), info['distro']) |
| 614 | + has_errors = True |
| 615 | + log.error("ERROR (%s): \"%s\" appears to try to reference a file not included in the \"%s\" distro", rel_src_file, link_text.replace("\n", ""), info['distro']) |
609 | 616 | else:
|
610 | 617 | fixed_link = "xref:" + link_anchor.replace("#", "") + link_title
|
611 | 618 |
|
@@ -640,7 +647,7 @@ def remove_conditional_content(content, info, tag=None):
|
640 | 647 | endpos = endif.end()
|
641 | 648 | break
|
642 | 649 | else:
|
643 |
| - search_pos = next_ifdef.end() |
| 650 | + search_pos = endif.end() |
644 | 651 |
|
645 | 652 | # Replace the content and move the end pos to be the same as the start since the content was removed
|
646 | 653 | ifdef_text = content[pos:endpos]
|
@@ -926,6 +933,9 @@ def main():
|
926 | 933 |
|
927 | 934 | # Copy the original data and reformat for drupal
|
928 | 935 | reformat_for_drupal(info)
|
| 936 | + |
| 937 | + if has_errors: |
| 938 | + sys.exit(1) |
929 | 939 |
|
930 | 940 | if args.push:
|
931 | 941 | # Parse the repo urls
|
|
0 commit comments