PageConfig.py
Go to the documentation of this file.
1 import os, sys
2 from ConfigParser import SafeConfigParser
3 from collections import OrderedDict
4 from ChainData import *
5 
6 class PageConfig:
7  def __init__(self,cfgFileName):
8  cfgFile=os.path.expandvars(cfgFileName)
9  if not os.path.isfile(cfgFile):
10  sys.stderr.write("ERROR!! Could not open %s\n" %cfgFile)
11  sys.exit(-1)
12 
13  mainDefaults={}
14  #max cache lifetime in seconds
15  mainDefaults['include_directory']="./"
16  mainDefaults['includes']=""
17  cfg=SafeConfigParser()
18  cfg.readfp(open(cfgFile))
19 
20  self.pageFileName = cfg.get("main","page_name")
21  self.pageTitle = cfg.get("main","page_title")
22  self.pageDesc = cfg.get("main","description").replace("\n"," ")
23 
24 
25  self.maxCacheLifetime = 604800 #units in seconds
26  if "max_cache_lifetime" in cfg.options("main"):
27  self.maxCacheLifetime = int(cfg.get("main","max_cache_lifetime"))
28 
29  includeDir=""
30  if "include_directory" in cfg.options("main"):
31  includeDir=cfg.get("main","include_directory")
32 
33  includes=""
34  if "includes" in cfg.options("main"):
35  includes=cfg.get("main","includes")
36 
37  for include in includes.split():
38  include=include.strip()
39  fullInclude=os.path.expandvars(includeDir + "/" + include)
40  cfg.readfp(open(fullInclude))
41 
42 
43  self.chains=[]
44  for section in cfg.sections():
45  if not section.startswith("chain") : continue
46  chain=makeChain(section,cfg)
47  self.chains.append(chain)
48 
def makeChain(chainSection, cfg)
Definition: ChainData.py:69
procfile open("FD_BRL_v0.txt")
def __init__(self, cfgFileName)
Definition: PageConfig.py:7