Skip to content

Commit

Permalink
layers: move loop parameter out of object state
Browse files Browse the repository at this point in the history
The event loop is needed when doing something. It is not part of the
layers state.
  • Loading branch information
jkloetzke committed Oct 4, 2024
1 parent 619ff2c commit 493ba31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pym/bob/cmds/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def doLayers(argv, bobRoot):
updateLayers(loop, defines, args.verbose,
args.attic, args.layerConfig)
elif args.action == "status":
layers = Layers(loop, defines, args.attic)
layers = Layers(defines, args.attic)
layers.setLayerConfig(args.layerConfig)
layers.collect(False, args.verbose)
layers.collect(loop, False, args.verbose)
pp = PackagePrinter(args.verbose, False, False)
layers.status(pp.show)

17 changes: 8 additions & 9 deletions pym/bob/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ def status(self, printer):
printer(status, self.__layerDir)

class Layers:
def __init__(self, loop, defines, attic):
def __init__(self, defines, attic):
self.__layers = {}
self.__loop = loop
self.__attic = attic
self.__defines = defines
self.__layerConfigFiles = []
Expand All @@ -217,19 +216,19 @@ def __haveLayer(self, layer):
return True
return False

def __collect(self, depth, yamlCache, update, verbose):
def __collect(self, loop, depth, yamlCache, update, verbose):
self.__layers[depth+1] = []
newLevel = False
for l in self.__layers[depth]:
if update:
l.checkout(self.__loop, verbose)
l.checkout(loop, verbose)
l.parse(yamlCache)
for subLayer in l.getSubLayers():
if not self.__haveLayer(subLayer):
self.__layers[depth+1].append(subLayer)
newLevel = True
if newLevel:
self.__collect(depth + 1, yamlCache, update, verbose)
self.__collect(loop, depth + 1, yamlCache, update, verbose)

def cleanupUnused(self):
old_layers = BobState().getLayers()
Expand All @@ -250,7 +249,7 @@ def cleanupUnused(self):
os.rename(d, atticPath)
BobState().delLayerState(d)

def collect(self, update, verbose=0):
def collect(self, loop, update, verbose=0):
configSchema = (schema.Schema(RecipeSet.STATIC_CONFIG_LAYER_SPEC), b'')
config = LayersConfig()
with YamlCache() as yamlCache:
Expand All @@ -264,7 +263,7 @@ def collect(self, update, verbose=0):
rootLayers = Layer("", config, os.getcwd(), self.__defines, self.__attic)
rootLayers.parse(yamlCache)
self.__layers[0] = rootLayers.getSubLayers();
self.__collect(0, yamlCache, update, verbose)
self.__collect(loop, 0, yamlCache, update, verbose)

def setLayerConfig(self, configFiles):
self.__layerConfigFiles = configFiles
Expand All @@ -275,7 +274,7 @@ def status(self, printer):
layer.status(printer)

def updateLayers(loop, defines, verbose, attic, layerConfigs):
layers = Layers(loop, defines, attic)
layers = Layers(defines, attic)
layers.setLayerConfig(layerConfigs)
layers.collect(True, verbose)
layers.collect(loop, True, verbose)
layers.cleanupUnused()

0 comments on commit 493ba31

Please sign in to comment.