@@ 880,33 880,29 @@ def choose_prodcomponent(ui, repo, cache
class LazyDict(collections.abc.Mapping):
+ '''Dictionary that calls the given loader function when its contents are accessed.'''
def __init__(self, loader):
collections.abc.Mapping.__init__(self)
self._loader = loader
self._data = None
- def __missing__(self, key):
- if self._data is None:
- self._data = self._loader()
- return self._data.__getitem__(key)
-
- def __getitem__(self, key):
+ def data(self):
if self._data is None:
self._data = self._loader()
- return self._data.__getitem__(key)
+ return self._data
+
+ def __getitem__(self, key):
+ return self.data().__getitem__(key)
def __iter__(self):
- if self._data is None:
- self._data = self._loader()
- return self._data.__iter__()
+ return self.data().__iter__()
def __len__(self):
- if self._data is None:
- self._data = self._loader()
- return len(self._data)
+ return len(self.data())
def fill_values(values, ui, repo, api_server, finalize=False, patchdata=None):
+ # If things are fully specified, the bugzilla configuration info may be unneeded.
cache = LazyDict(lambda: bzauth.load_configuration(ui, api_server, BINARY_CACHE_FILENAME))
if 'PRODUCT' in values: