We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In [1]: from aiida.orm import SinglefileData In [2]: !pwd /Users/leopold In [3]: s=SinglefileData(file='/Users/leopold/nanopub.zip') In [4]: from pathlib import Path In [5]: s=SinglefileData(file=Path('/Users/leopold/nanopub.zip')) ------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-5-e5ace348d29f> in <module> ----> 1 s=SinglefileData(file=Path('/Users/leopold/nanopub.zip')) ~/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/orm/nodes/data/singlefile.py in __init__(self, file, filename, **kwargs) 45 if filename is None: 46 # don't assume that set_file has a 'filename' argument (remove guard in 2.0.0) ---> 47 self.set_file(file) 48 else: 49 self.set_file(file, filename=filename) ~/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/orm/nodes/data/singlefile.py in set_file(self, file, filename) 130 131 if is_filelike: --> 132 self.put_object_from_filelike(file, key, mode='wb') 133 else: 134 self.put_object_from_file(file, key) ~/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/orm/nodes/node.py in put_object_from_filelike(self, handle, path, mode, encoding, force, key) 637 raise TypeError("put_object_from_filelike() missing 1 required positional argument: 'path'") 638 --> 639 self._repository.put_object_from_filelike(handle, path, mode, encoding, force) 640 641 def delete_object(self, path=None, force=False, key=None): ~/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/orm/utils/_repository.py in put_object_from_filelike(self, handle, key, mode, encoding, force) 229 folder = folder.get_subfolder(basepath, create=True) 230 --> 231 folder.create_file_from_filelike(handle, key, mode=mode, encoding=encoding) 232 233 def delete_object(self, key, force=False): ~/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/common/folders.py in create_file_from_filelike(self, filelike, filename, mode, encoding) 226 227 with open(filepath, mode=mode, encoding=encoding) as handle: --> 228 shutil.copyfileobj(filelike, handle) 229 230 os.chmod(filepath, self.mode_file) ~/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/shutil.py in copyfileobj(fsrc, fdst, length) 77 """copy data from file-like object fsrc to file-like object fdst""" 78 while 1: ---> 79 buf = fsrc.read(length) 80 if not buf: 81 break AttributeError: 'PosixPath' object has no attribute 'read'
We should start supporting pathlib.Path objects, wherever we accept paths in string form.
pathlib.Path
The text was updated successfully, but these errors were encountered:
Maybe we can just revive #3614.
Sorry, something went wrong.
Oops - I searched for issues but didn't find one ;-)
Thanks @greschd , feel free to put me as a reviewer
It's because it was a PR, not an issue ;)
Successfully merging a pull request may close this issue.
Is your feature request related to a problem? Please describe
Describe the solution you'd like
We should start supporting
pathlib.Path
objects, wherever we accept paths in string form.The text was updated successfully, but these errors were encountered: