def __init__(self, manifest, settings, debug_mode=False, validate_files=True, def_parser=None): Log.Debuggable.__init__(self, debug_mode=debug_mode) self.settings = settings self.manifest = manifest self.validate_files = validate_files self.line_info = None self.pkg_root = manifest.get_root() self.def_parser = def_parser # Always has a context top_context = ConditionContext(manifest_parser=self) self.context_stack = [top_context] regex_flags = 0 if Log.Logger.has_level(Log.LEVEL.EXTREME): regex_flags = re.DEBUG # line regexes, in order of matching with Log.CaptureStdout(self, "COMMENT_RE:"): self.comment_re = re.compile("[;#].*", regex_flags) with Log.CaptureStdout(self, "DIRECTIVE_RE:"): self.directive_re = re.compile(":.*", regex_flags) with Log.CaptureStdout(self, "PARAMETER_RE:"): self.parameter_re = re.compile("([a-z_]+)[ \t]+(.*)$", regex_flags) # directive regexes (preceding colon and whitespace stripped off), in order of matching with Log.CaptureStdout(self, "CONFIG_RE:"): self.config_re = re.compile("config", regex_flags) with Log.CaptureStdout(self, "CONDITION_IF_RE:"): self.condition_if_re = re.compile("if(.*)", regex_flags) with Log.CaptureStdout(self, "CONDITION_ELIF_RE:"): self.condition_elif_re = re.compile("elif(.*)", regex_flags) with Log.CaptureStdout(self, "CONDITION_ELSE_RE:"): self.condition_else_re = re.compile("else$", regex_flags) with Log.CaptureStdout(self, "BLOCK_END_RE:"): self.block_end_re = re.compile("end$", regex_flags) with Log.CaptureStdout(self, "INCLUDE_RE:"): self.include_re = re.compile("include[ ]+(.*)", regex_flags) with Log.CaptureStdout(self, "LABEL_RE:"): self.label_re = re.compile("([a-z_]+)", regex_flags) for label in self.get_labels(): self.manifest.add_type(label)
def __init__(self, config, debug_mode=False): Log.Debuggable.__init__(self, debug_mode=debug_mode) self.config = config self.line_info = None self.comment_block = [] regex_flags = 0 if Log.Logger.has_level(Log.LEVEL.EXTREME): regex_flags = re.DEBUG # line regexes, in order of matching with Log.CaptureStdout(self, "COMMENT_RE:"): self.comment_re = re.compile("[;#][ \t]*(.*)", regex_flags) with Log.CaptureStdout(self, "SETTING_RE:"): self.setting_re = re.compile("(" + IDENTIFIER_NAME + ")[ \t]*=[ \t]*(.+)", regex_flags) # Regexes used in formatting of comments with Log.CaptureStdout(self, "BULLETED_LIST:"): self.bulleted_list_re = re.compile("[*\\-+#][ \t](.+)", regex_flags)
def __init__(self, project, debug_mode=False): Log.Debuggable.__init__(self, debug_mode=debug_mode) self.project = project self.line_info = None # Always has a context top_context = Context(project_parser=self) self.context_stack = [top_context] self.prj_root = os.path.dirname(project.get_filename()) regex_flags = 0 if Log.Logger.has_level(Log.LEVEL.EXTREME): regex_flags = re.DEBUG # line regexes, in order of matching with Log.CaptureStdout(self, "COMMENT_RE:"): self.comment_re = re.compile("[;#].*", regex_flags) with Log.CaptureStdout(self, "DIRECTIVE_RE:"): self.directive_re = re.compile(":.*", regex_flags) # directive regexes (preceding colon and whitespace stripped off), in order of matching with Log.CaptureStdout(self, "BLOCK_END_RE:"): self.block_end_re = re.compile("end$", regex_flags) with Log.CaptureStdout(self, "PROJECT_RE:"): self.project_re = re.compile( "project[ \t]+(" + IDENTIFIER_NAME + ")$", regex_flags) with Log.CaptureStdout(self, "LAYER_RE:"): self.layer_re = re.compile("layer[ \t]+(" + IDENTIFIER_NAME + ")$", regex_flags) with Log.CaptureStdout(self, "DEPENDENCY_RE:"): self.dependency_re = re.compile( "dependency[ \t]+(" + IDENTIFIER_NAME + ")$", regex_flags) with Log.CaptureStdout(self, "PACKAGE_RE:"): self.package_re = re.compile("package[ \t]+(.+)$", regex_flags) with Log.CaptureStdout(self, "EXT_PACKAGE_RE:"): self.ext_package_re = re.compile( "ext_package[ \t]+(" + IDENTIFIER_NAME + ")[ \t]+(.+)$", regex_flags) with Log.CaptureStdout(self, "LCL_PACKAGE_RE:"): self.lcl_package_re = re.compile( "lcl_package[ \t]+(" + IDENTIFIER_NAME + ")[ \t]+(.+)$", regex_flags) with Log.CaptureStdout(self, "INCLUDE_RE:"): self.include_re = re.compile("include[ ]+(.*)", regex_flags) # Block parameter regex with Log.CaptureStdout(self, "BLOCK_PARAM_RE::"): self.param_re = re.compile("(" + IDENTIFIER_NAME + ")[ \t]+(.+)", regex_flags)