Skip to content

Commit

Permalink
Adding check for filepath lengths above 255 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
esimpsons3ti committed Jul 17, 2024
1 parent 8463cef commit 07761bb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pds4indextools/pds4_create_xml_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,10 @@ def main(cmd_line=None):
update_nillable_elements_from_xsd_file(url, nillable_elements_info)

filepath = str(label_file.relative_to(args.directorypath)).replace('\\', '/')
# PDS4 compliant filepaths must be less than 255 characters.
if len(filepath) > 255:
print(f'Filepath {filepath} exceeds 255 character limit.')
sys.exit(1)

# Creates two dictionaries: one for the namespaces, and one for their
# associated prefixes.
Expand Down Expand Up @@ -1464,10 +1468,7 @@ def main(cmd_line=None):
elif header == 'filename':
true_type = 'pds:ASCII_File_Name'
elif header == filepath:
if len(header) > 255:
true_type = 'pds:ASCII_Text_Preserved'
else:
true_type = 'pds:ASCII_File_Specification_Name'
true_type = 'pds:ASCII_File_Specification_Name'
elif header == 'bundle':
true_type = 'pds:ASCII_Text_Preserved'
else:
Expand Down

0 comments on commit 07761bb

Please sign in to comment.