pygrok/pygrok.py
def match(self, text):
        """If text is matched with pattern, return variable names specified(%{pattern:variable name})
        in pattern and their corresponding values.If not matched, return None.
        custom patterns can be passed in by custom_patterns(pattern name, pattern regular expression pair)
        or custom_patterns_dir.
        """

        match_obj = None
        if self.fullmatch:
            match_obj = self.regex_obj.fullmatch(text)
        else:
            match_obj = self.regex_obj.search(text)

        if match_obj == None:
            return None
        matches = match_obj.groupdict()
        for key,match in matches.items():
            try:
                if self.type_mapper[key] == 'int':
                    matches[key] = int(match)
                if self.type_mapper[key] == 'float':
                    matches[key] = float(match)
            except (TypeError, KeyError) as e:
                pass
        return matches
def match(self, text):
        """If text is matched with pattern, return variable names specified(%{pattern:variable name})
        in pattern and their corresponding values.If not matched, return None.
        custom patterns can be passed in by custom_patterns(pattern name, pattern regular expression pair)
        or custom_patterns_dir.
        """

        match_obj = None
        if self.fullmatch:
            match_obj = self.regex_obj.fullmatch(text)
        else:
            match_obj = self.regex_obj.search(text)

        if match_obj == None:
            return None
        matches = match_obj.groupdict()
        for key,match in matches.items():
            try:
                if self.type_mapper[key] == 'int':
                    matches[key] = int(match)
                if self.type_mapper[key] == 'float':
                    matches[key] = float(match)
            except (TypeError, KeyError) as e:
                pass
        return matches
def match ( self , text ) : match_obj = None if self . fullmatch : match_obj = self . regex_obj . fullmatch ( text ) else : match_obj = self . regex_obj . search ( text ) if match_obj == None : return None matches = match_obj . groupdict ( ) for key , match in matches . items ( ) : try : if self . type_mapper [ key ] == 'int' : matches [ key ] = int ( match ) if self . type_mapper [ key ] == 'float' : matches [ key ] = float ( match ) except ( TypeError , KeyError ) as e : pass return matches
If text is matched with pattern, return variable names specified(%{pattern:variable name})
        in pattern and their corresponding values.If not matched, return None.
        custom patterns can be passed in by custom_patterns(pattern name, pattern regular expression pair)
        or custom_patterns_dir.
If text is matched with pattern return variable names specified ( % { pattern : variable name } ) in pattern and their corresponding values . If not matched return None . custom patterns can be passed in by custom_patterns ( pattern name pattern regular expression pair ) or custom_patterns_dir .