Exemplo n.º 1
0
def expandTitles(value):
  global stories
  titles = ""
  if not len(str(value)): return titles
  picklist = csplit(str(value))
  if not len(stories):
    stories = myStories(config.get("realmdir"))
  for item in picklist:
    if config['debug'] > 5: print "'%s' - '%s'" % (item,stories.get(item))
    if stories.get(item):
      titles += "%s\n" % stories[item]
    else:
      titles += "\'%s\'\n" % item
  titles = titles[:-1] # trim that last newline
  return titles
Exemplo n.º 2
0
def myStories(realmdir):
  global stories
  if len(stories) > 0:
    return stories
  else:
    fn = os.path.join(os.path.abspath(realmdir),"mystories.cfg")
    lines = backends.readfile(fn,False) # Try to read file, but quietly
    for line in lines:
      try:
        line = line.strip()
        if line:
          values = [x.strip() for x in line.split('=')]
          if not stories.get(values[0]): stories[values[0]] = values[1] # existing options will not be clobbered
      except Exception as e:
        print "There was an error in the configuration file: %s" % e
    return stories