Skip to content

Commit

Permalink
Update bundle processing to include README
Browse files Browse the repository at this point in the history
Software now includes //File_Area_Text/File/file_name if it exists
in the bundle.xml

Resolves #55
  • Loading branch information
jordanpadams committed Apr 24, 2020
1 parent beb007d commit adf97b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pds/aipgen/sip.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
PDS_SCHEMA_URL, AIP_PRODUCT_URI_PREFIX, PDS_LABEL_FILENAME_EXTENSION, HASH_ALGORITHMS, SIP_MANIFEST_URL
)
from .utils import (
getPrimariesAndOtherInfo, getMD5, getLogicalIdentifierAndFileInventory, parseXML, getDigest, addLoggingArguments
getPrimariesAndOtherInfo, getMD5, getLogicalIdentifierAndFileInventory, parseXML, getDigest, addLoggingArguments, getBundleFiles
)
from datetime import datetime
from lxml import etree
Expand Down Expand Up @@ -222,8 +222,8 @@ def _getLocalFileInfo(bundle, primaries, bundleLidvid, allCollections, con):
cursor.execute('''CREATE INDEX IF NOT EXISTS lidvidIndex ON lidvids (lidvid)''')
cursor.execute('''CREATE UNIQUE INDEX lidvidPairing ON lidvids (lidvid, xmlFile)''')

# Add bundle to manifest
lidvidsToFiles[bundleLidvid] = {'file:' + bundle}
# Add bundle and associated files to manifest
lidvidsToFiles[bundleLidvid] = getBundleFiles(bundle)

# OK, here we go
root = os.path.dirname(bundle)
Expand Down
14 changes: 14 additions & 0 deletions src/pds/aipgen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ def addLoggingArguments(parser):
)


def getBundleFiles(bundle):
files = {'file:' + bundle}

tree = parseXML(bundle)
root = tree.getroot()
matches = root.findall(f'./{{{PDS_NS_URI}}}File_Area_Text/{{{PDS_NS_URI}}}File/{{{PDS_NS_URI}}}file_name')

if matches:
for i in matches:
files.add('file:' + os.path.join(os.path.dirname(bundle), i.text.strip()))

return files


# Classes
# -------

Expand Down

0 comments on commit adf97b4

Please sign in to comment.