def include_file(self, path, include_dirs = []):
        """
        Includes a file into the current model.

        @param path: Path to the file to be included.
        @type path: str

        @param include_dirs: Optional alternate include search path.
        @type include_dirs: list(str)
        """
        if self.include_includes:
            if self.debug: print("------------------                   Including a file: %s"%path)
            inc_dirs = include_dirs if include_dirs else self.include_dirs

            parser = LEMSFileParser(self, inc_dirs, self.include_includes)
            if os.access(path, os.F_OK):
                if not path in self.included_files:
                    parser.parse(open(path).read()) 
                    self.included_files.append(path)
                    return
                else:
                    if self.debug: print("Already included: %s"%path)
                    return
            else:
                for inc_dir in inc_dirs:
                    new_path = (inc_dir + '/' + path)
                    if os.access(new_path, os.F_OK):
                        if not new_path in self.included_files:
                            parser.parse(open(new_path).read())
                            self.included_files.append(new_path)
                            return
                        else:
                            if self.debug: print("Already included: %s"%path)
                            return
            msg = 'Unable to open ' + path
            if self.fail_on_missing_includes:
                raise Exception(msg)
            elif self.debug: 
                print(msg)
def include_file ( self , path , include_dirs = [ ] ) : if self . include_includes : if self . debug : print ( "------------------                   Including a file: %s" % path ) inc_dirs = include_dirs if include_dirs else self . include_dirs parser = LEMSFileParser ( self , inc_dirs , self . include_includes ) if os . access ( path , os . F_OK ) : if not path in self . included_files : parser . parse ( open ( path ) . read ( ) ) self . included_files . append ( path ) return else : if self . debug : print ( "Already included: %s" % path ) return else : for inc_dir in inc_dirs : new_path = ( inc_dir + '/' + path ) if os . access ( new_path , os . F_OK ) : if not new_path in self . included_files : parser . parse ( open ( new_path ) . read ( ) ) self . included_files . append ( new_path ) return else : if self . debug : print ( "Already included: %s" % path ) return msg = 'Unable to open ' + path if self . fail_on_missing_includes : raise Exception ( msg ) elif self . debug : print ( msg )
Includes a file into the current model.

        @param path: Path to the file to be included.
        @type path: str

        @param include_dirs: Optional alternate include search path.
        @type include_dirs: list(str)