Chain.py
Go to the documentation of this file.
1 class Chain():
2 
3  import Tier
4 
5  def __init__(self, name):
6  #print "chain: --- Initalise chain"
7  self.name = name
8  self.env = {}
9  self.time_str = "Default"
10  self.tiers = []
11 
12  def AddTier(self, tier):
13  #assert(type(tier) == Tier.Tier)
14  self.tiers.append(tier)
15  self.tiers[-1].setChainName(self.name)
16 
17  def GetTierShortNames(self):
18  short_names = []
19  for tier in self.tiers: short_names.append(tier.short_name)
20  return short_names
21 
22  def GetTier(self, tier_name):
23  return self.tiers[self.GetTierShortNames().index(tier_name)]
24 
25  def GetTiers(self, start_tier_name, end_tier_name):
26  return self.tiers[self.GetTierShortNames().index(start_tier_name):self.GetTierShortNames().index(end_tier_name)+1]
27 
28  def __repr__(self):
29  _repr = "chain: --- Name: %s\n"%repr(self.name)
30  _repr += "chain: %i tiers\n"%len(self.tiers)
31  for tier in self.tiers:
32  _repr += "chain: %s\n"%tier.short_name
33  # strip trailing newline
34  _repr = _repr[:-1]
35  return _repr
time_str
Definition: Chain.py:9
def __repr__(self)
Definition: Chain.py:28
def AddTier(self, tier)
Definition: Chain.py:12
def GetTier(self, tier_name)
Definition: Chain.py:22
def GetTiers(self, start_tier_name, end_tier_name)
Definition: Chain.py:25
def __init__(self, name)
Definition: Chain.py:5
def GetTierShortNames(self)
Definition: Chain.py:17