project_manifest Namespace Reference

Functions

def indent
 
def CMakeParseArguments
 

Variables

tuple parser = OptionParser(usage='%prog [options] <cmake_lists> <lcg_version> <platform>')
 
string help = 'output filename'
 
list project_args = []
 
tuple m = re.search(r'gaudi_project\s*\(([^)]*)\)
 

Function Documentation

def project_manifest.CMakeParseArguments (   args,
  options = None,
  single_value = None,
  multi_value = None 
)
Parse a list or strings using the logic of the CMake function
CMAKE_PARSE_ARGUMENTS.

>>> res = CMakeParseArguments(['USE', 'Gaudi', 'v25r0', 'DATA', 'Det/SQLDDDB'],
... multi_value=['USE', 'DATA'])
>>> res['USE']
['Gaudi', 'v25r0']
>>> res['DATA']
['Det/SQLDDDB']
>>> res['UNPARSED']
[]
>>> res = CMakeParseArguments('a b OPTION1 c FLAG1 d OPTION2 e f'.split(),
... options=['FLAG1', 'FLAG2'],
... single_value=['OPTION1', 'OPTION2'])
>>> res['FLAG1']
True
>>> res['FLAG2']
False
>>> res['OPTION1']
'c'
>>> res['OPTION2']
'e'
>>> res['UNPARSED']
['a', 'b', 'd', 'f']

Definition at line 31 of file project_manifest.py.

31 def CMakeParseArguments(args, options=None, single_value=None, multi_value=None):
32  '''
33  Parse a list or strings using the logic of the CMake function
34  CMAKE_PARSE_ARGUMENTS.
35 
36  >>> res = CMakeParseArguments(['USE', 'Gaudi', 'v25r0', 'DATA', 'Det/SQLDDDB'],
37  ... multi_value=['USE', 'DATA'])
38  >>> res['USE']
39  ['Gaudi', 'v25r0']
40  >>> res['DATA']
41  ['Det/SQLDDDB']
42  >>> res['UNPARSED']
43  []
44  >>> res = CMakeParseArguments('a b OPTION1 c FLAG1 d OPTION2 e f'.split(),
45  ... options=['FLAG1', 'FLAG2'],
46  ... single_value=['OPTION1', 'OPTION2'])
47  >>> res['FLAG1']
48  True
49  >>> res['FLAG2']
50  False
51  >>> res['OPTION1']
52  'c'
53  >>> res['OPTION2']
54  'e'
55  >>> res['UNPARSED']
56  ['a', 'b', 'd', 'f']
57  '''
58  args = list(args)
59  options = set(options or [])
60  single_value = set(single_value or [])
61  multi_value = set(multi_value or [])
62  all_keywords = options.union(single_value).union(multi_value)
63  result = {'UNPARSED': []}
64  result.update((k, False) for k in options)
65  result.update((k, None) for k in single_value)
66  result.update((k, []) for k in multi_value)
67 
68  while args:
69  arg = args.pop(0)
70  if arg in options:
71  result[arg] = True
72  elif arg in single_value:
73  result[arg] = args.pop(0)
74  elif arg in multi_value:
75  while args and args[0] not in all_keywords:
76  result[arg].append(args.pop(0))
77  else:
78  result['UNPARSED'].append(arg)
79  return result
80 
def project_manifest.indent (   elem,
  level = 0 
)
Add spaces and newlines to elements to allow pretty-printing of XML.

http://effbot.org/zone/element-lib.htm#prettyprint

Definition at line 11 of file project_manifest.py.

11 def indent(elem, level=0):
12  '''
13  Add spaces and newlines to elements to allow pretty-printing of XML.
14 
15  http://effbot.org/zone/element-lib.htm#prettyprint
16  '''
17  i = "\n" + level*" "
18  if len(elem):
19  if not elem.text or not elem.text.strip():
20  elem.text = i + " "
21  if not elem.tail or not elem.tail.strip():
22  elem.tail = i
23  for elem in elem:
24  indent(elem, level+1)
25  if not elem.tail or not elem.tail.strip():
26  elem.tail = i
27  else:
28  if level and (not elem.tail or not elem.tail.strip()):
29  elem.tail = i
30 

Variable Documentation

string project_manifest.help = 'output filename'

Definition at line 85 of file project_manifest.py.

tuple project_manifest.m = re.search(r'gaudi_project\s*\(([^)]*)\)

Definition at line 102 of file project_manifest.py.

tuple project_manifest.parser = OptionParser(usage='%prog [options] <cmake_lists> <lcg_version> <platform>')

Definition at line 83 of file project_manifest.py.

list project_manifest.project_args = []

Definition at line 101 of file project_manifest.py.