mirror of
https://github.com/powerline/powerline.git
synced 2025-07-23 22:05:43 +02:00
Add ability to copy recursive specifications
This commit is contained in:
parent
23ec5efb41
commit
0ecd10ffb2
@ -93,15 +93,21 @@ class Spec(object):
|
|||||||
self.did_type = True
|
self.did_type = True
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def copy(self):
|
def copy(self, copied=None):
|
||||||
return self.__class__()._update(self.__dict__)
|
copied = copied or {}
|
||||||
|
try:
|
||||||
|
return copied[id(self)]
|
||||||
|
except KeyError:
|
||||||
|
instance = self.__class__()
|
||||||
|
copied[id(self)] = instance
|
||||||
|
return self.__class__()._update(self.__dict__, copied)
|
||||||
|
|
||||||
def _update(self, d):
|
def _update(self, d, copied):
|
||||||
self.__dict__.update(d)
|
self.__dict__.update(d)
|
||||||
self.keys = copy(self.keys)
|
self.keys = copy(self.keys)
|
||||||
self.checks = copy(self.checks)
|
self.checks = copy(self.checks)
|
||||||
self.uspecs = copy(self.uspecs)
|
self.uspecs = copy(self.uspecs)
|
||||||
self.specs = [spec.copy() for spec in self.specs]
|
self.specs = [spec.copy(copied) for spec in self.specs]
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def unknown_spec(self, keyfunc, spec):
|
def unknown_spec(self, keyfunc, spec):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user