getgauge/parser_redbaron.py
def parse(file_path, content=None):
        """
        Create a PythonFile object with specified file_path and content.
        If content is None then, it is loaded from the file_path method.
        Otherwise, file_path is only used for reporting errors.
        """
        try:
            if content is None:
                with open(file_path) as f:
                    content = f.read()
            py_tree = RedBaron(content)
            return RedbaronPythonFile(file_path, py_tree)
        except Exception as ex:
            # Trim parsing error message to only include failure location
            msg = str(ex)
            marker = "<---- here\n"
            marker_pos = msg.find(marker)
            if marker_pos > 0:
                msg = msg[:marker_pos + len(marker)]
            logging.error("Failed to parse {}: {}".format(file_path, msg))
def parse(file_path, content=None):
        """
        Create a PythonFile object with specified file_path and content.
        If content is None then, it is loaded from the file_path method.
        Otherwise, file_path is only used for reporting errors.
        """
        try:
            if content is None:
                with open(file_path) as f:
                    content = f.read()
            py_tree = RedBaron(content)
            return RedbaronPythonFile(file_path, py_tree)
        except Exception as ex:
            # Trim parsing error message to only include failure location
            msg = str(ex)
            marker = "<---- here\n"
            marker_pos = msg.find(marker)
            if marker_pos > 0:
                msg = msg[:marker_pos + len(marker)]
            logging.error("Failed to parse {}: {}".format(file_path, msg))
def parse ( file_path , content = None ) : try : if content is None : with open ( file_path ) as f : content = f . read ( ) py_tree = RedBaron ( content ) return RedbaronPythonFile ( file_path , py_tree ) except Exception as ex : # Trim parsing error message to only include failure location msg = str ( ex ) marker = "<---- here\n" marker_pos = msg . find ( marker ) if marker_pos > 0 : msg = msg [ : marker_pos + len ( marker ) ] logging . error ( "Failed to parse {}: {}" . format ( file_path , msg ) )
Create a PythonFile object with specified file_path and content.
        If content is None then, it is loaded from the file_path method.
        Otherwise, file_path is only used for reporting errors.
Create a PythonFile object with specified file_path and content . If content is None then it is loaded from the file_path method . Otherwise file_path is only used for reporting errors .