-
Notifications
You must be signed in to change notification settings - Fork 14
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
Extend load_file
to handle file objects.
#379
Conversation
Co-authored-by: Marvin Poul <[email protected]>
pyiron_base/generic/filedata.py
Outdated
if is_file: | ||
with open(file, encoding='utf8') as f: | ||
return f.readlines() | ||
else: | ||
return file.readlines() |
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.
I'm not sure the extra flag is needed, maybe something like
if is_file: | |
with open(file, encoding='utf8') as f: | |
return f.readlines() | |
else: | |
return file.readlines() | |
if instance(file, io.IOBase): | |
return file.readlines() | |
else: | |
with open(file, encoding='utf8') as f: | |
return _load_txt(f) |
is better.
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.
Probably we should then go the whole way and use this check instead of generating the filename_is_string
at all.
return _load_default(fp, is_file=filename_is_str) | ||
|
||
|
||
class FileDataTemplate(ABC): |
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.
I didn't see it before, but where else is the FileDataTemplate
supposed to be used?
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.
I hope to have it as a Base class for storing File related data. I am using this also for the S3FileData
here.
No description provided.