Return the template file that goes with the given service name, or return
    None if there's no match.  Subservices return the parent service's file.
771373
def get_matching_service_template_file(service_name, template_files):
    
    # If this is a subservice, use the parent service's template
    service_name = service_name.split('.')[0]
    if service_name in template_files:
        return template_files[service_name]
    return None
515802
def load(self, name):
        

        if self.reload:
            self._maybe_purge_cache()

        template = self.cache.get(name)
        if template:
            return template

        path = self.resolve(name)
        if not path:
            raise OSError(errno.ENOENT, "File not found: %s" % name)

        with codecs.open(path, 'r', encoding='UTF-8') as f:
            contents = f.read()
            mtime = os.fstat(f.fileno()).st_mtime

        template = self.load_string(contents, filename=path)
        template.mtime = mtime
        template.path = path

        self.cache[name] = template
        return template
736741
def getFileFormat(self, name, args):
		
		# récupération du nom du fichier
		template_pathname = self.get(name, "--")
		if not os.path.isfile(template_pathname):
			return False

		# configuration
		content = ""
		with open(template_pathname) as fp:
			# Create a text/plain message
			content = fp.read().format(**args)

		# retour ok
		return content
157216
def get_template_image(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_template_image function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_template_image function requires a \'name\'.'
        )

    try:
        ret = list_templates()[name]['template']['disk']['image']
    except KeyError:
        raise SaltCloudSystemExit(
            'The image for template \'{0}\' could not be found.'.format(name)
        )

    return ret
905846
def factory(self, request, parent=None, name=None):
        
        traverse = request.matchdict['traverse']

        # show documentation at the root path
        if not traverse:
            return {}
        else:
            service = {}
            name = name or traverse[0]

            # look for direct pattern matches
            traversed = '/' + '/'.join(traverse)
            service_type = None
            service_object = None

            for route, endpoint in self.routes:
                result = route.match(traversed)
                if result is not None:
                    request.matchdict = result
                    request.endpoint = endpoint
                    break
            else:
                try:
                    service_type, service_object = self.services[name]
                except KeyError:
                    raise HTTPNotFound()

            if service_type:
                if isinstance(service_type, Endpoint):
                    service[name] = service_type
                elif service_object is None:
                    service[name] = service_type(request)
                else:
                    service[name] = service_type(request, service_object)

            request.api_service = service
            return service
1083950
def get_service(self, name):
    
    return services.get_service(self._get_resource_root(), name, self.name)
1085215
def _loadService(self, servicePath):
        
        serviceName = ntpath.basename(servicePath).replace(".py", "")

        # importing service
        serviceSpec = importlib.util.spec_from_file_location(
            serviceName,
            servicePath
        )
        service = importlib.util.module_from_spec(serviceSpec)
        serviceSpec.loader.exec_module(service)

        # checking if there is a service in the file
        if hasattr(service, "Service"):
            # instantiate the service
            serviceInstance = service.Service(self.application)
            self.application.addService(
                self.name,
                serviceName,
                serviceInstance
            )
661685
def get_template_file(self):
        
        if os.path.exists(os.path.join(self.theme_dir, 'base.html')):
            return os.path.join(self.theme_dir, 'base.html')
        default_dir = os.path.join(THEMES_DIR, 'default')
        if not os.path.exists(os.path.join(default_dir, 'base.html')):
            raise IOError(u"Cannot find base.html in default theme")
        return os.path.join(default_dir, 'base.html')
1085490
def get_common_payload_template(services=None):
    
    available_services = {'citrine', 'materials_commons', 'materials_data_facility'}
    if services is None:
        services = list(available_services)
    else:
        services = [service for service in services if service in available_services]
        if not services:
            services = list(available_services)
    combined_requirements = {}
    for service in services:
        # TODO(Recursive check dictionaries to make sure all requirements fields are combined.)
        service_requirements = eval('_%s_metadata_requirements()' % service)
        if service_requirements:
            for key in service_requirements:
                if not key in combined_requirements:
                    combined_requirements[key] = service_requirements[key]
    return {
        'all_fields': {
            'title': 'string',
            'source': {
                'name': 'string',
                'producer': 'string',
                'url': 'url string',
                'tags': ['string']
            },
            'data_contacts': [
                {
                    'given_name': 'string',
                    'family_name': 'string',
                    'title': 'string',
                    'orcid': 'TBD',
                    'email': 'string',
                    'tags': ['string']
                }
            ],
            'data_contributors': [
                {
                    'given_name': 'string',
                    'family_name': 'string',
                    'title': 'string',
                    'orcid': 'TBD',
                    'email': 'string',
                    'tags': ['string']
                }
            ],
            'links': {
                'landing_page': 'uri (string)',
                'publication': ['uri (string)'],
                'data_doi': 'uri (string)',
                'related_id': ['string'],
                'parent_id': 'string'
            },
            'authors': [
                {
                    'given_name': 'string',
                    'family_name': 'string',
                    'title': 'string',
                    'orcid': 'TBD',
                    'email': 'string',
                    'tags': ['string']
                }
            ],
            'licenses': [
                {
                    'name': 'string',
                    'description': 'string',
                    'url': 'string',
                    'tags': ['string']
                }
            ],
            'citations': [
                {
                    'authors': [
                        {
                            'given_name': 'string',
                            'family_name': 'string',
                            'title': 'string',
                            'orcid': 'TBD',
                            'email': 'string',
                            'tags': ['string']
                        }
                    ],
                    'year': 'string',
                    'title': 'string',
                    'journal': 'string',
                    'volume': 'string',
                    'issue': 'string',
                    'page_location': 'string',
                    'edition': 'string',
                    'publication_location': 'string',
                    'publisher': 'string',
                    'extent': 'string',
                    'notes': 'string',
                }
            ],
            'repository': 'not yet available',
            'collection': 'not yet available',
            'tags': ['string'],
            'description': 'string',
            'raw': 'not yet available',
            'year': 'integer',
            'composition': 'not yet available'
        },
        'required_fields': combined_requirements,
        'usage': 'payload = <service class, e.g. CITPayload>(**input_dictionary).metapayload'
    }
212509
def _loadServices(self):
        
        servicesPath = os.path.join(self.path, "service")
        if not os.path.isdir(servicesPath):
            return

        self._scanDirectoryForServices(servicesPath)
1132030
def get_template(template_id, opts = {})
      data, _status_code, _headers = get_template_with_http_info(template_id, opts)
      data
    end
706368
def get_service_name(self, name, search_filter):
        
        service_filter = "services[?name=='{}'].metadata.name".format(name)
        return one(jmespath.search(service_filter, self.get(search_filter)))
752378
def get_template_loader(self, subdir='templates'):
        ''''''
        if self.request is None:
            raise ValueError("this method can only be called after the view middleware is run. Check that `django_mako_plus.middleware` is in MIDDLEWARE.")
        dmp = apps.get_app_config('django_mako_plus')
        return dmp.engine.get_template_loader(self.app, subdir)
540249
def find_template_companion(template, extension='', check=True):
    

    if check and not os.path.isfile(template):
        yield ''
        return # May be '<stdin>' (click)

    template = os.path.abspath(template)
    template_dirname = os.path.dirname(template)
    template_basename = os.path.basename(template).split('.')

    current_path = template_dirname
    stop_path = os.path.commonprefix((os.getcwd(), current_path))
    stop_path = os.path.dirname(stop_path)

    token = template_basename[0] + '.'

    while True:

        for file in sorted(os.listdir(current_path)):
            if not file.startswith(token):
                continue
            if not file.endswith(extension):
                continue

            file_parts = file.split('.')
            for i in range(1, len(template_basename)):
                if template_basename[:-i] != file_parts[:-1]:
                    continue
                if current_path == template_dirname:
                    if file_parts == template_basename:
                        continue # Do not accept template itself

                yield os.path.join(current_path, file)

        if current_path == stop_path:
            break

        # cd ..
        current_path = os.path.split(current_path)[0]
50318
def template(name, datas)
      file = template_path(name)
      content = File.read(file)

      datas.each do |k, v|
        k = "<%= #{k} %>"
        content = content.gsub(k, v)
      end
      return content
    end
877303
def get_service(self, name, search_filter):
        """"""
        if self.version == 1:
            service_filter = "service.{name}".format(name=name)
            return jmespath.search(service_filter, self.get(search_filter))
        else:
            service_filter = "services[?name=='{}']".format(name)
            return one(jmespath.search(service_filter, self.get(search_filter)))
816347
def find_parents(name, parents=None):
    
    template = loader.get_template(name)
    source, origin = find_template_source(name)
    if parents is None:
        parents = []
    else:
        parents.append({'name': name, 'file': origin})
    for node in template:
        if isinstance(node, ExtendsNode):
            parent_name = node.parent_name.token.strip('"')
            return find_parents(parent_name, parents)
    return parents