Source

qadpid / qadpid / parser.py

"""
Parser Code

Copyright 2011 John Chandler
This software is distributed under the terms of the GNU General Public License version 3
"""
import re

INCLUDE_RE = re.compile( '''(include|require)(?:_once)? ["']([^"']+)["']''' )

class PHPFileParser( object ):
    """ PHP File Parser """
    def parse( self, file_text ):
        """ parse the file_text and return a list of include/require dependencies """
        matches = INCLUDE_RE.findall( file_text )
        
        dependencies = []
        if matches:
            for dependency_found in matches:
                dependencies.append( dependency_found )
     
        return dependencies