-
Notifications
You must be signed in to change notification settings - Fork 16
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
File format to extension function #378
Conversation
This looks great. I made a couple of suggestions to improve the code. I'd also like to see a unit tests that checks at least 2 of the known file types and one unknown file type, verifying the raised exception. There are unit tests that check for exceptions. Let me know if you can't find one. I would be happy to help you craft some or all of this test method. It should go in Thanks! |
sbol3/document.py
Outdated
@@ -279,6 +279,22 @@ def _guess_format(self, fpath: str): | |||
rdf_format = 'nt11' | |||
return rdf_format | |||
|
|||
# Return standard extensions when provided the document's file format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this comment line and put it into a docstring (see below):
# Return standard extensions when provided the document's file format |
sbol3/document.py
Outdated
@@ -279,6 +279,22 @@ def _guess_format(self, fpath: str): | |||
rdf_format = 'nt11' | |||
return rdf_format | |||
|
|||
# Return standard extensions when provided the document's file format | |||
def file_extension(self, file_format: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a staticmethod
since it doesn't use self
, and add a docstring:
def file_extension(self, file_format: str) -> str: | |
@staticmethod | |
def file_extension(file_format: str) -> str: | |
"""Return standard extensions when provided the document's file format | |
:param file_format: The format of the file | |
:return: A file extension, including the leading '.' | |
""" |
Co-authored-by: Tom Mitchell <tcmitchell@users.noreply.github.com>
Sure, I have made one named |
Hey @tcmitchell @jakebeal , this tries to fix #244 , by implementing a function bound on the
Document
class to provide standard extensions for given file format.