manifest: give Project a __repr__

An unambiguous __repr__ is now possible since the removal of the
Defaults and Remote API. This useful e.g. when printing lists of
Projects in a debugger.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2019-11-18 14:25:24 -08:00 committed by Carles Cufí
parent 5b41f9d26b
commit c7c8e8a196
1 changed files with 10 additions and 0 deletions

View File

@ -573,6 +573,12 @@ class Project:
def __eq__(self, other): def __eq__(self, other):
return NotImplemented return NotImplemented
def __repr__(self):
return ('Project({}, {}, revision={}, path={}, clone_depth={}, '
'west_commands={}, topdir={}').format(
self.name, self.url, self.revision, self.path,
self.clone_depth, self.west_commands, self.topdir)
def __str__(self): def __str__(self):
return '<Project {} at {}>'.format( return '<Project {} at {}>'.format(
repr(self.name), repr(self.abspath or self.path)) repr(self.name), repr(self.abspath or self.path))
@ -865,6 +871,10 @@ class ManifestProject(Project):
- ``clone_depth``: ``None``, because ``url`` is - ``clone_depth``: ``None``, because ``url`` is
''' '''
def __repr__(self):
return 'ManifestProject({}, path={}, west_commands={}, topdir={})'. \
format(self.name, self.path, self.west_commands, self.topdir)
def __init__(self, path=None, west_commands=None, topdir=None): def __init__(self, path=None, west_commands=None, topdir=None):
''' '''
:param path: Relative path to the manifest repository in the :param path: Relative path to the manifest repository in the