Returns a list of files which can be either {% imported %},
    {% extended %} or {% included %} within a template.
772369
def find_referenced_templates(template, search_path):
    
    from jinja2 import Environment, meta
    env = Environment()
    ast = env.parse(template.read())
    referenced_templates = list(meta.find_referenced_templates(ast))

    def realpath(tpl):
        for path in search_path:
            t = os.path.realpath(os.path.join(path, tpl))
            if os.path.isfile(t):
                return t
        return None

    return [realpath(t) for t in referenced_templates if t is not None]
930228
def get_importable_modules(folder):
    
    for fname in os.listdir(folder):
        if fname.endswith('.py') and not fname.startswith('_'):
            yield fname[:-3]
626336
def get_abs_template_path(template_name, directory, extension):
    
    # Get the relative path
    relative_path = join(directory, template_name)
    file_with_ext = template_name

    if extension:
        # If there is a default extension, but no file extension, then add it
        file_name, file_ext = splitext(file_with_ext)
        if not file_ext:
            file_with_ext = extsep.join(
                (file_name, extension.replace(extsep, '')))
            # Rebuild the relative path
            relative_path = join(directory, file_with_ext)

    return abspath(relative_path)
194403
def get_c_sources(folder, include_headers=False):
    """"""
    allowed_extensions = [".c", ".C", ".cc", ".cpp", ".cxx", ".c++"]
    if include_headers:
        allowed_extensions += [".h", ".hpp"]
    sources = []
    for root, _, files in os.walk(folder):
        for name in files:
            ext = os.path.splitext(name)[1]
            if name == "types.cc":
                # Make sure `types.cc` is compiled first, as it has multiple
                # useful static assertions.
                sources.insert(0, os.path.join(root, name))
            elif ext in allowed_extensions:
                sources.append(os.path.join(root, name))
    return sources
71983
def get_template_sources(self, template_name, template_dirs=None):
        
        if not template_dirs:
            template_dirs = self.get_dirs()
        for template_dir in template_dirs:
            try:
                name = safe_join(template_dir, template_name)
            except SuspiciousFileOperation:
                # The joined path was located outside of this template_dir
                # (it might be inside another one, so this isn't fatal).
                pass
            else:
                if Origin:
                    yield Origin(
                        name=name,
                        template_name=template_name,
                        loader=self,
                    )
                else:
                    yield name
792960
def get_template_options():
        
        template_root = turrentine_settings.TURRENTINE_TEMPLATE_ROOT
        turrentine_dir = turrentine_settings.TURRENTINE_TEMPLATE_SUBDIR
        output = []
        for root, dirs, files in os.walk(turrentine_dir):
            for file_name in files: 
                full_path = os.path.join(root, file_name)
                relative_path = os.path.relpath(full_path, template_root)
                output.append(relative_path)
        return output
1215780
def __get_supported_file_types_string(self):
        

        languages = ["All Files (*)"]
        for language in self.__languages_model.languages:
            languages.append("{0} Files ({1})".format(language.name,
                                                      " ".join(language.extensions.split("|")).replace("\\", "*")))
        return ";;".join(languages)
982916
def get_dependencies(self, filename):
        
        if self.is_partial(filename):
            return self.templates
        elif self.is_template(filename):
            return [self.get_template(filename)]
        elif self.is_static(filename):
            return [filename]
        else:
            return []
990408
def extract_applicable_files(config, options)
      included_patterns = options[:files]
      excluded_patterns = config['exclude']
      excluded_patterns += options.fetch(:excluded_files, [])

      HamlLint::FileFinder.new(config).find(included_patterns, excluded_patterns)
    end
375878
def extensions(self):
        
        _tmp_extensions = self.mimes.encodings_map.keys() + \
            self.mimes.suffix_map.keys() + \
            self.mimes.types_map[1].keys() + \
            cfg['CFG_BIBDOCFILE_ADDITIONAL_KNOWN_FILE_EXTENSIONS']
        extensions = []
        for ext in _tmp_extensions:
            if ext.startswith('.'):
                extensions.append(ext)
            else:
                extensions.append('.' + ext)
        extensions.sort()
        extensions.reverse()
        extensions = set([ext.lower() for ext in extensions])
        extensions = '\\' + '$|\\'.join(extensions) + '$'
        extensions = extensions.replace('+', '\\+')
        return re.compile(extensions, re.I)
65728
def extract_required_files(files, options = {})
      return [] if files.nil? || files.empty?
      seen = []
      files.inject([]) do |extracted, req_js|
        include_files, include_options = if req_js.last.is_a?(Hash)
          [req_js[0..-2], options.merge(req_js.last)]
        else
          [req_js, options]
        end
        seen += (includes = include_files - seen)
        extracted << (includes + [include_options]) unless includes.empty?
        extracted
      end
    end
923378
private function getIncludedFiles()
    {
        // Retrieve the include and exclude lists
        // from the options
        $include = Options::get('coverage.include');
        $exclude = Options::get('coverage.exclude');

        // Create empty arrays to store our filenames in
        $includedFiles = [];
        $excludedFiles = [];

        // If we have marked files as included
        if ($include !== null) {
            // Convert a string to an array so that
            // we only have to loop once
            if (!is_array($include)) {
                $include = [$include];
            }

            // Loop through each of the include glob strings
            foreach ($include as $glob) {
                // Prepend the current working directory to the glob
                $glob = $this->runner->pwd.'/'.$glob;

                // Add the glob results to the included files array
                $includedFiles = array_merge($includedFiles, glob_recursive($glob));
            }
        }

        // If we have marked files as excluded
        if ($exclude !== null) {
            // Convert a string to an array so that
            // we only have to loop once
            if (!is_array($exclude)) {
                $exclude = [$exclude];
            }

            // Loop through each of the include glob strings
            foreach ($exclude as $glob) {
                // Prepend the current working directory to the glob
                $glob = $this->runner->pwd.'/'.$glob;

                // Add the glob results to the excluded files array
                $excludedFiles = array_merge($excludedFiles, glob_recursive($glob));
            }
        }

        // Store the results
        $this->includedFiles = $includedFiles ?: [];
        $this->excludedFiles = $excludedFiles ?: [];
    }
432187
function initializeIncludes()
    {
        // If we have this global variable we shouldn't do any processing
        if ( !empty( $GLOBALS['eZSimpleTagsInit'] ) )
            return;

        $GLOBALS['eZSimpleTagsInit'] = true;
        $ini = eZINI::instance( 'template.ini' );
        $extensions = $ini->variable( 'SimpleTagsOperator', 'Extensions' );
        $pathList = eZExtension::expandedPathList( $extensions, 'simpletags' );
        $includeList = $ini->variable( 'SimpleTagsOperator', 'IncludeList' );

        foreach ( $includeList as $includeFile )
        {
            foreach ( $pathList as $path )
            {
                $file = $path . '/' . $includeFile;
                if ( file_exists( $file ) )
                {
                    include_once( $file );
                }
            }
        }
    }
409863
def existing_config_files():
    
    global _ETC_PATHS
    global _MAIN_CONFIG_FILE
    global _CONFIG_VAR_INCLUDE
    global _CONFIG_FILTER

    config_files = []
    for possible in _ETC_PATHS:
        config_files = config_files + glob.glob("%s%s" % (possible, _MAIN_CONFIG_FILE))
    
    if _CONFIG_VAR_INCLUDE != "":
        main_config = Configuration("general", {
            _CONFIG_VAR_INCLUDE:""
        }, _MAIN_CONFIG_FILE)

        if main_config.CONFIG_DIR != "":
            for possible in _ETC_PATHS:
                config_files = config_files + glob.glob("%s%s/%s" % (possible, main_config.CONFIG_DIR, _CONFIG_FILTER))
            
    return config_files
804471
def template_scripts(self, config, template_name):
        '''
        
        '''
        dmp = apps.get_app_config('django_mako_plus')
        template_obj = dmp.engine.get_template_loader(config, create=True).get_mako_template(template_name, force=True)
        mako_context = create_mako_context(template_obj)
        inner_run = WebpackProviderRun(mako_context['self'])
        inner_run.run()
        scripts = []
        for tpl in inner_run.templates:
            for p in tpl.providers:
                if os.path.exists(p.absfilepath):
                    scripts.append(p.absfilepath)
        return scripts
1362175
def global_include(self, pattern):
        
        if self.allfiles is None:
            self.findall()
        match = translate_pattern(os.path.join('**', pattern))
        found = [f for f in self.allfiles if match.match(f)]
        self.extend(found)
        return bool(found)
462703
def compiled_orm_imports(self):
        """"""
        module = 'sqlalchemy.orm'
        labels = []
        if self.relationship_definitions:
            labels.append("relationship")
        return ALCHEMY_TEMPLATES.named_import.safe_substitute(module=module, labels=", ".join(labels))