Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
fileparser.Parser Class Reference
Inheritance diagram for fileparser.Parser:
fileparser.CParser

Public Member Functions

def __init__ (self)
 
def FindCopyrightBlock (self, comment_blocks)
 
def GetCopyrightBlockAttributes (self, comment_block)
 

Detailed Description

Base class for all language-specific parsers.

Definition at line 22 of file fileparser.py.

Constructor & Destructor Documentation

◆ __init__()

def fileparser.Parser.__init__ (   self)

Reimplemented in fileparser.CParser.

Definition at line 26 of file fileparser.py.

26 def __init__(self):
27 self._copyright_pattern = re.compile('copyright', re.IGNORECASE)
28 self._attribute_pattern = re.compile(
29 'copyright.*\D(\d{4})\W*(\w.*[\w.])', re.IGNORECASE)
30

Member Function Documentation

◆ FindCopyrightBlock()

def fileparser.Parser.FindCopyrightBlock (   self,
  comment_blocks 
)
Given a list of comment block strings, return the one that seems
like the most likely copyright block.

Returns None if comment_blocks was empty, or if we couldn't find
a comment block that contains copyright info.

Definition at line 31 of file fileparser.py.

31 def FindCopyrightBlock(self, comment_blocks):
32 """Given a list of comment block strings, return the one that seems
33 like the most likely copyright block.
34
35 Returns None if comment_blocks was empty, or if we couldn't find
36 a comment block that contains copyright info."""
37 if not comment_blocks:
38 return None
39 for block in comment_blocks:
40 if self._copyright_pattern.search(block):
41 return block
42

◆ GetCopyrightBlockAttributes()

def fileparser.Parser.GetCopyrightBlockAttributes (   self,
  comment_block 
)
Given a comment block, return a tuple of attributes: (year, holder).

If comment_block is None, or none of the attributes are found,
this will return (None, None).

Definition at line 43 of file fileparser.py.

43 def GetCopyrightBlockAttributes(self, comment_block):
44 """Given a comment block, return a tuple of attributes: (year, holder).
45
46 If comment_block is None, or none of the attributes are found,
47 this will return (None, None)."""
48 if not comment_block:
49 return (None, None)
50 matches = self._attribute_pattern.findall(comment_block)
51 if not matches:
52 return (None, None)
53 first_match = matches[0]
54 return (first_match[0], first_match[1])
55
56

The documentation for this class was generated from the following file: