201 ifdef_skipping =
False
202 ifdef_skipping_level = 0
208 if l.startswith(
"#!"):
225 if not (m2
and m2.start() < m.start()):
228 l = l[: m.start()] + l[m.end() :]
232 directive_name = m.group(1)
233 directive_arg = m.group(2).strip()
234 if directive_name ==
"include":
235 included_file = directive_arg.strip(
"'\"")
237 elif directive_name ==
"units":
238 units_file = directive_arg.strip(
"'\"")
240 elif directive_name
in [
"ifdef",
"ifndef"]:
241 ifdef_skipping_level = ifdef_level
243 if directive_arg
in self.
defines:
244 ifdef_skipping = directive_name ==
"ifndef"
246 ifdef_skipping = directive_name ==
"ifdef"
247 elif directive_name ==
"else":
248 ifdef_skipping =
not ifdef_skipping
249 elif directive_name ==
"endif":
251 if ifdef_skipping
and ifdef_skipping_level == ifdef_level:
252 ifdef_skipping =
False
253 elif directive_name ==
"pragma":
254 if not directive_arg:
257 pragma = directive_arg.split()
258 if pragma[0] ==
"print":
260 if pragma[1].upper()
in [
"ON",
"TRUE",
"1"]:
265 _log.warning(
"unknown directive '%s'", directive_name)
276 l, l1 = l[: m.start()], l[m.end() :]
285 "End Of File reached before end of multi-line comment"
292 string_end = l.find(
'"')
294 statement += l[: string_end + 1]
295 l = l[string_end + 1 :]
301 string_start = l.find(
'"')
302 if string_start >= 0:
303 string_end = l.find(
'"', string_start + 1)
306 statement += l[: string_end + 1]
307 l = l[string_end + 1 :]
319 statement = l[i + 1 :]
322 if statement.lstrip().startswith(
"//"):
342 from GaudiKernel.Proxy.Configurable
import (
351 property, value = statement.split(
"=", 1)
354 if property[-1]
in [
"+",
"-"]:
356 property = property[:-1]
358 property = property.strip()
359 value = value.strip()
376 property =
".".join([w.strip()
for w
in property.split(
".")])
377 component, property = property.rsplit(
".", 1)
378 if component
in Configurable.allConfigurables:
379 cfg = Configurable.allConfigurables[component]
381 cfg = ConfigurableGeneric(component)
384 value = value.replace(
"true",
"True").replace(
"false",
"False")
387 if ":" in value
and not (
388 value[: value.index(
":")].count(
'"') % 2
389 or value[: value.index(
":")].count(
"'") % 2
392 value =
"{" + value[1:-1].replace(
"{",
"[").replace(
"}",
"]") +
"}"
394 value = value.replace(
"{",
"[").replace(
"}",
"]")
397 value = value.replace(
"\\",
"\\\\")
400 value.replace(
r"\\n",
r"\n").replace(
r"\\t",
r"\t").replace(
r'\\"',
r"\"")
405 (v
if i % 2
else re.sub(
r"\\[nt]",
" ", v))
406 for i, v
in enumerate(value.split(
'"'))
414 value = PropertyReference(m.group(1))
416 value = eval(value, self.
units)
421 if property
not in cfg.__slots__
and not hasattr(cfg, property):
423 lprop = property.lower()
424 for p
in cfg.__slots__:
425 if lprop == p.lower():
427 "property '%s' was requested for %s, but the correct spelling is '%s'",
437 if hasattr(cfg, property):
438 prop = getattr(cfg, property)
439 if isinstance(prop, dict):
445 setattr(cfg, property, value)
447 if hasattr(cfg, property):
448 prop = getattr(cfg, property)
449 if isinstance(prop, dict):
455 "key '%s' not in %s.%s", k, cfg.name(), property
463 "value '%s' not in %s.%s", k, cfg.name(), property
466 setattr(cfg, property, value)