parameters: (self, rules)
docstring: Make a configuration state object from a compiled rulebase.
docstring_summary: Make a configuration state object from a compiled rulebase.
docstring_tokens: Make a configuration state object from a compiled rulebase .
function: def __init__(self, rules):
          "Make a configuration state object from a compiled rulebase."
          # Interpret a string as the name of a file containing pickled rules.
          if type(rules) == type(""):
              import cPickle
              rules = cPickle.load(open(rules, "rb"))
  
          # Copy the symbol table.   Since a python object's members are all
          # stored in a single hash table, we can steal its contents and
          # then discard the original object.
          self.__dict__ = rules.__dict__
  
          self.clear()
  
          # Enhance the ConfigSymbol methods to deal with the value state.
          if 'oldeval' not in dir(cml.ConfigSymbol):
              cml.ConfigSymbol.oldeval = cml.ConfigSymbol.eval
              def _neweval(symbol, debug=0, self=self):	# Not a method!
                  value = self.__bindeval(symbol)
                  if value != None:
                      return value
                  value = cml.ConfigSymbol.oldeval(symbol, debug)
                  if value != None:
                      return value
                  elif symbol.type in ("decimal", "hexadecimal"):
                      return 0
                  elif symbol.type == "string":
                      return ""
                  elif symbol.is_logical():
                      return cml.n
                  else:
                      return None	# for menu, choices, and message-valued symbols
              cml.ConfigSymbol.eval = _neweval
  
              def _newstr(symbol):		# Not a method!
                  res = "%s={" % (symbol.name)
                  res = res + symbol.dump()
                  if symbol.setcount:
                      res = res + " has been set,"
                  if symbol.included:
                      res = res + " was loaded,"
                  if symbol.frozen():
                      res = res + " frozen,"
                  value = symbol.eval()
                  if value != None:
                      res = res + " value " + str(value) + "," 
                  return res[:-1] + "}"
              cml.ConfigSymbol.__str__ = _newstr
  
              def _freeze(symbol):
                  "Freeze a symbol."
                  symbol.iced = 1
                  if symbol.menu and symbol.menu.type == "choices":
                      symbol.menu.iced = 1
                      symbol.menu.value = symbol.name
                      for sibling in symbol.menu.items:
                          sibling.iced = 1
              cml.ConfigSymbol.freeze = _freeze
  
              def _frozen(symbol, self=self):
                  "Is the symbol frozen?"
                  if symbol.iced or symbol.type == "message":
                      return 1
                  if symbol.type in ("menu", "choices"):
                      for item in symbol.items:
                          if self.is_visible(item) and not item.frozen():
                              return 0
                      return 1
                  return 0
              cml.ConfigSymbol.frozen = _frozen
  
          # Extra state for the configuration object
          self.debug = 0			# Initially, no status logging
          self.cdepth = 0			# Constraint recursion xdepth
          self.errout = sys.stderr	# Where to do status logging
          self.suppressions = 1		# Yes, do visibility checks
          self.interactive = 1		# Are we doing a file inclusion?
          self.commits = 0		# Value sets since last save 
          self.lang = _eng		# Someday we'll support more languages.
          self.side_effects = []		# Track side effects
          self.trits_enabled = not self.trit_tie or self.trit_tie.eval()
  
          if rules.version != cml.version:
              sys.stderr.write(self.lang["BADVERSION"] % (rules.version, cml.version))
              raise SystemExit, 1
function_tokens: def __init__ ( self , rules ) : # Interpret a string as the name of a file containing pickled rules. if type ( rules ) == type ( "" ) : import cPickle rules = cPickle . load ( open ( rules , "rb" ) ) # Copy the symbol table.   Since a python object's members are all # stored in a single hash table, we can steal its contents and # then discard the original object. self . __dict__ = rules . __dict__ self . clear ( ) # Enhance the ConfigSymbol methods to deal with the value state. if 'oldeval' not in dir ( cml . ConfigSymbol ) : cml . ConfigSymbol . oldeval = cml . ConfigSymbol . eval def _neweval ( symbol , debug = 0 , self = self ) : # Not a method! value = self . __bindeval ( symbol ) if value != None : return value value = cml . ConfigSymbol . oldeval ( symbol , debug ) if value != None : return value elif symbol . type in ( "decimal" , "hexadecimal" ) : return 0 elif symbol . type == "string" : return "" elif symbol . is_logical ( ) : return cml . n else : return None # for menu, choices, and message-valued symbols cml . ConfigSymbol . eval = _neweval def _newstr ( symbol ) : # Not a method! res = "%s={" % ( symbol . name ) res = res + symbol . dump ( ) if symbol . setcount : res = res + " has been set," if symbol . included : res = res + " was loaded," if symbol . frozen ( ) : res = res + " frozen," value = symbol . eval ( ) if value != None : res = res + " value " + str ( value ) + "," return res [ : - 1 ] + "}" cml . ConfigSymbol . __str__ = _newstr def _freeze ( symbol ) : "Freeze a symbol." symbol . iced = 1 if symbol . menu and symbol . menu . type == "choices" : symbol . menu . iced = 1 symbol . menu . value = symbol . name for sibling in symbol . menu . items : sibling . iced = 1 cml . ConfigSymbol . freeze = _freeze def _frozen ( symbol , self = self ) : "Is the symbol frozen?" if symbol . iced or symbol . type == "message" : return 1 if symbol . type in ( "menu" , "choices" ) : for item in symbol . items : if self . is_visible ( item ) and not item . frozen ( ) : return 0 return 1 return 0 cml . ConfigSymbol . frozen = _frozen # Extra state for the configuration object self . debug = 0 # Initially, no status logging self . cdepth = 0 # Constraint recursion xdepth self . errout = sys . stderr # Where to do status logging self . suppressions = 1 # Yes, do visibility checks self . interactive = 1 # Are we doing a file inclusion? self . commits = 0 # Value sets since last save  self . lang = _eng # Someday we'll support more languages. self . side_effects = [ ] # Track side effects self . trits_enabled = not self . trit_tie or self . trit_tie . eval ( ) if rules . version != cml . version : sys . stderr . write ( self . lang [ "BADVERSION" ] % ( rules . version , cml . version ) ) raise SystemExit , 1