Skip to content

Commit

Permalink
some clean up on the semantics of .Condo objects vs. strings, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndenny committed Jul 11, 2024
1 parent ba1f48f commit 738a213
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions lib/Bastion/Site.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ def configured(self, conf):
logger.debug("self.zones is type {}".format(type(self.zones)))
self._zones[zname] = Zone(self, zname).configured( zspec )

aspecs = conf.get("assets.{}".format(self.name), None)
if aspecs is not None:
for zname in aspecs.keys:
zspecs = conf.get("assets.{}".format(self.name), None)
if zspecs is not None:
for zkey, aspecs in zspecs:
zname = str(zkey) #-- cast from Condo.CxKey to the zone's simple name.
logger.info("reading assets for resource zone {} in site {}".format(zname, self.name))
zone = self.zone(zname)
for aspec in aspecs[zname]:
#-- Short form....
for aspec in aspecs:
if entity(aspec).isString:
#-- Short form....
#-- Short form declaration of an asset is just the subfolder's name.
zone.assets.add( aspec )
logger.debug("added asset {} to zone {} by short form description".format(aspec, zname))
else:
#-- Long form ...
#-- Long form declaration of an asset is a dictionary with additional definition key-value pairs.
zone.assets.add( Asset(zone, aspec) )
logger.debug("added asset {} to zone {} by long form description".format(aspec, zname))

Expand Down Expand Up @@ -273,6 +273,8 @@ def __init__(self, zone, *args, **kwargs):
def __str__(self):
return "{} ({})".format(self.badge, self.RDN)

def __repr__(self):
return str(self.ARK.CURIE)

def _get_policy(self):
return getattr(self, '_policy', self.zone.policy)
Expand Down Expand Up @@ -384,11 +386,15 @@ def named(self, name):
else:
return None

@property
def names(self):
return tuple(sorted(self.xnames.keys()))

def __len__(self):
return len(self.xRDNs)

def __iter__(self):
return iter(sorted(self.xRDNs.values(), key = lambda x: str(x.path)))
return iter(sorted(self.xRDNs.values(), key = lambda x: str(x.halo)))


class Zone(isZone, canConfigure):
Expand All @@ -402,7 +408,7 @@ class Zone(isZone, canConfigure):
ASSET_CLS = Asset

def __init__(self, site, name, root = None):
isZone.__init__(self, site, name, root)
isZone.__init__(self, site, str(name), root)
self.site = Site(site)
self.policy = self.site.policy #--inherit my site's default policy

Expand All @@ -425,3 +431,7 @@ def configured(self, conf):
def __div__(self, name):
return Asset(self, name)

def __getitem__(self, name):
return self.site.assets(self.name).named(name)


0 comments on commit 738a213

Please sign in to comment.