__getattr__¶
-
_AsyncGit.
__getattr__
(item: str) → Union[Callable[[Any, Any, Any, Any, Any], Coroutine], callable, Any][source]¶ If an attribute doesn’t exist, this method will return a
awaitable()
function that simply callsgit()
with the attribute name as the first argument, followed by any additional positional/keyword arguments.Since a lot of git commands have
-
in their name, but Python doesn’t support attributes containing-
, non-existent attributes will have_
replaced with-
when callinggit()
with their name.For example,
git.count_objects('-v')
would becomegit count-objects -v
This allows most unimplemented
git
sub-commands to function when called as a method, for example, at the current point in time, neither thedescribe
command, norcount-objects
are implemented as a method, but both can still be called synchronously or asynchronously and it will work:>>> from privex.helpers import Git >>> g = Git() >>> g.describe('--tags') '2.14.0-1-g8418c96' >>> await g.describe('--tags') '2.14.0-1-g8418c96' >>> g.count_objects() '2061 objects, 8880 kilobytes' >>> await g.count_objects() '2061 objects, 8880 kilobytes'