23
23
24
24
cli .init_logging (False , True )
25
25
26
- has_errors = False
26
+ list_of_errors = []
27
27
CLONE_DIR = "."
28
28
BASE_PORTAL_URL = "https://access.redhat.com/documentation/en-us/"
29
29
# ID_RE = re.compile("^\[(?:\[|id=\'|#)(.*?)(\'?,.*?)?(?:\]|\')?\]", re.M | re.DOTALL)
@@ -442,6 +442,7 @@ def reformat_for_drupal(info):
442
442
443
443
# Reformat the data
444
444
for book in books :
445
+
445
446
log .info ("Processing %s" , book ["Dir" ])
446
447
book_src_dir = os .path .join (src_dir , book ["Dir" ])
447
448
@@ -460,6 +461,7 @@ def reformat_for_drupal(info):
460
461
copy_images (book , src_dir , images_dir , distro )
461
462
462
463
464
+
463
465
def copy_images (node , src_path , dest_dir , distro ):
464
466
"""
465
467
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):
630
632
raise ConnectionError ("Malformed URL" )
631
633
except Exception as exception :
632
634
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 } " )
634
636
sys .exit (- 1 )
635
637
636
638
# 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):
732
734
content = _fix_links (
733
735
content , book_src_dir , src_file , info , tag = tag , cwd = cwd
734
736
)
735
-
736
737
return content
737
738
738
739
def dir_to_book_name (dir ,src_file ,info ):
@@ -742,11 +743,11 @@ def dir_to_book_name(dir,src_file,info):
742
743
return (book ["Name" ])
743
744
break
744
745
745
- has_errors = True
746
746
log .error (
747
747
'ERROR (%s): book not found for the directory %s' ,
748
748
src_file ,
749
749
dir )
750
+ list_of_errors .append (f"ERROR ({ src_file } ): book not found for the directory { dir } " )
750
751
return (dir )
751
752
752
753
@@ -791,6 +792,7 @@ def _fix_links(content, book_dir, src_file, info, tag=None, cwd=None):
791
792
'ERROR (%s): link pointing outside source directory? %s' ,
792
793
src_file ,
793
794
link_file )
795
+ list_of_errors .append (f'ERROR ({ src_file } ): link pointing outside source directory? { link_file } ' )
794
796
continue
795
797
split_relative_path = full_relative_path .split ("/" )
796
798
book_dir_name = split_relative_path [0 ]
@@ -823,13 +825,14 @@ def _fix_links(content, book_dir, src_file, info, tag=None, cwd=None):
823
825
fixed_link = link_text
824
826
if EXTERNAL_LINK_RE .search (link_file ) is not None :
825
827
rel_src_file = src_file .replace (os .path .dirname (book_dir ) + "/" , "" )
826
- has_errors = True
828
+ link_text_message = link_text . replace ( " \n " , "" )
827
829
log .error (
828
830
'ERROR (%s): "%s" appears to try to reference a file not included in the "%s" distro' ,
829
831
rel_src_file ,
830
- link_text . replace ( " \n " , "" ) ,
832
+ link_text_message ,
831
833
info ["distro" ],
832
834
)
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' )
833
836
else :
834
837
fixed_link = "xref:" + link_anchor .replace ("#" , "" ) + link_title
835
838
@@ -1177,7 +1180,7 @@ def main():
1177
1180
# Copy the original data and reformat for drupal
1178
1181
reformat_for_drupal (info )
1179
1182
1180
- if has_errors :
1183
+ if list_of_errors :
1181
1184
sys .exit (1 )
1182
1185
1183
1186
if args .push :
0 commit comments