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

Is there already a way to list metadata attributes? #545

Open
Tunneller opened this issue Apr 27, 2023 · 2 comments
Open

Is there already a way to list metadata attributes? #545

Tunneller opened this issue Apr 27, 2023 · 2 comments

Comments

@Tunneller
Copy link

I see::

    async def _getxattr(self, path, attr):
        """Get user-defined metadata attribute"""
        meta = (await self._info(path)).get("metadata", {})
        return meta[attr]

    getxattr = sync_wrapper(_getxattr)

Could we have as well something like:

    async def _listxattr(self, path, attr):
        """List all user-defined metadata attribute"""
        meta = (await self._info(path)).get("metadata", {})
        return meta

    listxattr = sync_wrapper(_listxattr)

My specific application is to check if a certain attribute exists and then x/y/z. I can do this at the moment with a try/except loop. If I had a list of available attributes then that would be a little cleaner.

Maybe this capability already exists?

Thanks, T.

@martindurant
Copy link
Member

I would suggest that allowing getxattr with attr=None should return the whole of the meta variable, so you have everything you want in one.

@Tunneller
Copy link
Author

Sure, if that is more Pythonesque.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants