Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a mechanism to provide a custom FILEID #71

Merged
merged 2 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
# built documents.
#
# The short X.Y version.
version = "0.3.8"
version = "0.3.9"
# The full version, including alpha/beta/rc tags.
release = "0.3.8"
release = "0.3.9"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion metsrw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())
__version__ = "0.3.8"
__version__ = "0.3.9"

__all__ = [
"Agent",
Expand Down
10 changes: 10 additions & 0 deletions metsrw/fsentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class FSEntry(DependencyPossessor):
populate FLocat @xlink:href
:param str label: Label in the structMap. If not provided, will be populated
with the basename of path
:param str fileid: Provides a mechanism to assign a FILEID to an FSENTRY
when a pointer file is being created, so when a METS file is being
written for an package-file-type, i.e. an AIP. The FILE ID is an XML
NC (Non-colonized) name and so callers must understand the restricted
character-set of that type to use it properly. There is currently no
validation on this attribute on generation.
:param str use: Use for the fileGrp. Items with identical uses will be
grouped together.
:param str type: Type of FSEntry this is. This will appear in the structMap.
Expand Down Expand Up @@ -112,6 +118,7 @@ class FSEntry(DependencyPossessor):
def __init__(
self,
path=None,
fileid=None,
label=None,
use="original",
type=u"Item",
Expand All @@ -138,6 +145,7 @@ def __init__(
self.path = path
if label is None and path is not None:
label = os.path.basename(path)
self._fileid = fileid
self.label = label
self.use = use
self.type = six.text_type(type)
Expand Down Expand Up @@ -204,6 +212,8 @@ def file_id(self):
"No FILEID: File %s does not have file_uuid set" % self.path
)
if self.is_aip:
if self._fileid:
return self._fileid
return os.path.splitext(os.path.basename(self.path))[0]
return utils.FILE_ID_PREFIX + self.file_uuid

Expand Down