gcsfs icon indicating copy to clipboard operation
gcsfs copied to clipboard

Is there already a way to list metadata attributes?

Open Tunneller opened this issue 1 year ago • 2 comments

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.

Tunneller avatar Apr 27 '23 20:04 Tunneller

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.

martindurant avatar Apr 27 '23 20:04 martindurant

Sure, if that is more Pythonesque.

Tunneller avatar Apr 27 '23 20:04 Tunneller