2323
2424cli .init_logging (False , True )
2525
26- has_errors = False
26+ list_of_errors = []
2727CLONE_DIR = "."
2828BASE_PORTAL_URL = "https://access.redhat.com/documentation/en-us/"
2929# ID_RE = re.compile("^\[(?:\[|id=\'|#)(.*?)(\'?,.*?)?(?:\]|\')?\]", re.M | re.DOTALL)
@@ -442,6 +442,7 @@ def reformat_for_drupal(info):
442442
443443 # Reformat the data
444444 for book in books :
445+
445446 log .info ("Processing %s" , book ["Dir" ])
446447 book_src_dir = os .path .join (src_dir , book ["Dir" ])
447448
@@ -460,6 +461,7 @@ def reformat_for_drupal(info):
460461 copy_images (book , src_dir , images_dir , distro )
461462
462463
464+
463465def copy_images (node , src_path , dest_dir , distro ):
464466 """
465467 Copy images over to the destination directory and flatten all image directories into the one top level dir.
@@ -630,7 +632,7 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None):
630632 raise ConnectionError ("Malformed URL" )
631633 except Exception as exception :
632634 log .error ("An include file wasn't found: %s" , base_src_file )
633- has_errors = True
635+ list_of_errors . append ( f"An include file wasn't found: { base_src_file } " )
634636 sys .exit (- 1 )
635637
636638 # Get a list of predefined custom title ids for the file
@@ -732,7 +734,6 @@ def fix_links(content, info, book_src_dir, src_file, tag=None, cwd=None):
732734 content = _fix_links (
733735 content , book_src_dir , src_file , info , tag = tag , cwd = cwd
734736 )
735-
736737 return content
737738
738739def dir_to_book_name (dir ,src_file ,info ):
@@ -742,11 +743,11 @@ def dir_to_book_name(dir,src_file,info):
742743 return (book ["Name" ])
743744 break
744745
745- has_errors = True
746746 log .error (
747747 'ERROR (%s): book not found for the directory %s' ,
748748 src_file ,
749749 dir )
750+ list_of_errors .append (f"ERROR ({ src_file } ): book not found for the directory { dir } " )
750751 return (dir )
751752
752753
@@ -791,6 +792,7 @@ def _fix_links(content, book_dir, src_file, info, tag=None, cwd=None):
791792 'ERROR (%s): link pointing outside source directory? %s' ,
792793 src_file ,
793794 link_file )
795+ list_of_errors .append (f'ERROR ({ src_file } ): link pointing outside source directory? { link_file } ' )
794796 continue
795797 split_relative_path = full_relative_path .split ("/" )
796798 book_dir_name = split_relative_path [0 ]
@@ -823,13 +825,14 @@ def _fix_links(content, book_dir, src_file, info, tag=None, cwd=None):
823825 fixed_link = link_text
824826 if EXTERNAL_LINK_RE .search (link_file ) is not None :
825827 rel_src_file = src_file .replace (os .path .dirname (book_dir ) + "/" , "" )
826- has_errors = True
828+ link_text_message = link_text . replace ( " \n " , "" )
827829 log .error (
828830 'ERROR (%s): "%s" appears to try to reference a file not included in the "%s" distro' ,
829831 rel_src_file ,
830- link_text . replace ( " \n " , "" ) ,
832+ link_text_message ,
831833 info ["distro" ],
832834 )
835+ list_of_errors .append (f'ERROR ({ rel_src_file } )): { link_text_message } appears to try to reference a file not included in the { info ["distro" ]} distro' )
833836 else :
834837 fixed_link = "xref:" + link_anchor .replace ("#" , "" ) + link_title
835838
@@ -1177,7 +1180,7 @@ def main():
11771180 # Copy the original data and reformat for drupal
11781181 reformat_for_drupal (info )
11791182
1180- if has_errors :
1183+ if list_of_errors :
11811184 sys .exit (1 )
11821185
11831186 if args .push :
0 commit comments