Add a format_debug method to InstallRequirement

This commit is contained in:
Pradyun Gedam 2019-07-20 10:29:14 +05:30
parent c5560f18fd
commit 21c4c4d5ee
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
1 changed files with 15 additions and 0 deletions

View File

@ -180,6 +180,21 @@ class InstallRequirement(object):
return '<%s object: %s editable=%r>' % (
self.__class__.__name__, str(self), self.editable)
def format_debug(self):
# type: () -> str
"""An un-tested helper for getting state, for debugging.
"""
attributes = vars(self)
names = sorted(attributes)
state = (
"{}={!r}".format(attr, attributes[attr]) for attr in sorted(names)
)
return '<{name} object: {{{state}}}>'.format(
name=self.__class__.__name__,
state=", ".join(state),
)
def populate_link(self, finder, upgrade, require_hashes):
# type: (PackageFinder, bool, bool) -> None
"""Ensure that if a link can be found for this, that it is found.