CMS 3D CMS Logo

Classes | Functions
main Namespace Reference

Classes

class  SkeletonOptionParser
 

Functions

def generator ()
 
def parse_args (args)
 
def tmpl_dir ()
 

Function Documentation

def main.generator ( )
Code generator function, parse user arguments and load appropriate
template module. Once loaded, run its data method depending on
user requested input parameter, e.g. print_etags, print_tags or
generate template code.

Definition at line 81 of file main.py.

References utils.code_generator(), parse_args(), and utils.test_env().

81 def generator():
82  """
83  Code generator function, parse user arguments and load appropriate
84  template module. Once loaded, run its data method depending on
85  user requested input parameter, e.g. print_etags, print_tags or
86  generate template code.
87  """
88  optmgr = SkeletonOptionParser()
89  opts, args = optmgr.get_opt()
90  test_env(os.path.join(opts.tdir, opts.tmpl), opts.tmpl)
91  config = {'pname': opts.pname, 'tmpl': opts.tmpl, 'author': opts.author,
92  'args': parse_args(args), 'debug': opts.debug,
93  'ftype': opts.ftype, 'tmpl_dir': opts.tdir}
94  if opts.ketags:
95  etags = opts.ketags.split(',')
96  config.update({'tmpl_etags': etags})
97  else:
98  config.update({'tmpl_etags': []})
99  obj = code_generator(config)
100  if opts.etags:
101  obj.print_etags()
102  sys.exit(0)
103  elif opts.tags:
104  obj.print_tags()
105  sys.exit(0)
106  elif opts.templates:
107  for name in os.listdir(opts.tdir):
108  print name
109  sys.exit(0)
110  obj.generate()
111 
def generator()
Definition: main.py:81
def parse_args(args)
Definition: main.py:69
def test_env(tdir, tmpl)
Definition: utils.py:37
def code_generator(kwds)
Definition: utils.py:106
def main.parse_args (   args)

Definition at line 69 of file main.py.

Referenced by generator().

69 def parse_args(args):
70  "Parse input arguments"
71  output = {}
72  for arg in args:
73  key, val = arg.split('=')
74  key = key.strip()
75  val = val.strip()
76  if val[0] == '[' and val[-1] == ']':
77  val = eval(val, { "__builtins__": None }, {})
78  output[key] = val
79  return output
80 
def parse_args(args)
Definition: main.py:69
def main.tmpl_dir ( )

Definition at line 22 of file main.py.

References join().

22 def tmpl_dir():
23  "Retturn default location of template directory"
24  return '%s/templates' % '/'.join(__file__.split('/')[:-1])
25 
def tmpl_dir()
Definition: main.py:22
static std::string join(char **cmd)
Definition: RemoteFile.cc:18