Given a TemplateLiteral path, return the metadata about a RelayQL tag
if one exists.
496053
function getValidRelayQLTag(path: any): [any, ?string, ?string] {
  const {node} = path;

  const tag = path.get('tag');
  const tagName = tag.matchesPattern('Relay.QL')
    ? 'Relay.QL'
    : tag.matchesPattern('RelayClassic_DEPRECATED.QL')
    ? 'RelayClassic_DEPRECATED.QL'
    : tag.matchesPattern('RelayClassic.QL')
    ? 'RelayClassic.QL'
    : tag.isIdentifier({name: 'RelayQL'})
    ? 'RelayQL'
    : null;
  if (!tagName) {
    return [null, null, null];
  }

  let p = path;
  let propName = null;
  while (!propName && (p = p.parentPath)) {
    if (p.isProperty()) {
      propName = p.node.key.name;
    }
  }

  return [node.quasi, tagName, propName];
}
1102221
public static TemplatePathInfo forTemplatePath(@NotNull String templatePath, @NotNull TemplatePathInfo @NotNull... templates) {
    if (templatePath == null || templates == null || templates.length == 0) {
      return null;
    }
    for (TemplatePathInfo template : templates) {
      if (StringUtils.equals(template.getTemplatePath(), templatePath)) {
        return template;
      }
    }
    return null;
  }
550345
def get_templates(path: Path) -> List[str]:
    '''
    '''

    result = []

    for item in path.glob('**/*'):
        if item.is_file() and not item.name.startswith('_'):
            result.append(item.relative_to(path.parent).as_posix())

    return result
817521
public static Template getClassPathTemplate(String path, String templateFileName) {
		return getTemplate(createClassPathGroupTemplate(path), templateFileName);
	}
1122723
def get_template(template):
    
    from cloud_inquisitor.database import db

    tmpl = db.Template.find_one(template_name=template)
    if not tmpl:
        raise InquisitorError('No such template found: {}'.format(template))

    tmplenv = Environment(loader=BaseLoader, autoescape=True)
    tmplenv.filters['json_loads'] = json.loads
    tmplenv.filters['slack_quote_join'] = lambda data: ', '.join('`{}`'.format(x) for x in data)

    return tmplenv.from_string(tmpl.template)
955141
def read(self, source_path):
        """"""

        self._metadata = {}
        with pelican_open(source_path) as text:
            content = creole2html(text, macros={'header': self._parse_header_macro,
                                            'code': self._parse_code_macro})
        return content, self._metadata
1175150
def get_template(template_id,**kwargs):
    
    try:
        tmpl_i = db.DBSession.query(Template).filter(Template.id==template_id).options(joinedload_all('templatetypes.typeattrs.default_dataset.metadata')).one()

        #Load the attributes.
        for tmpltype_i in tmpl_i.templatetypes:
            for typeattr_i in tmpltype_i.typeattrs:
                typeattr_i.attr

        return tmpl_i
    except NoResultFound:
        raise HydraError("Template %s not found"%template_id)
208618
def get_template_by_name(name,**kwargs):
    
    try:
        tmpl_i = db.DBSession.query(Template).filter(Template.name == name).options(joinedload_all('templatetypes.typeattrs.default_dataset.metadata')).one()
        return tmpl_i
    except NoResultFound:
        log.info("%s is not a valid identifier for a template",name)
        raise HydraError('Template "%s" not found'%name)
148154
function catchpath (req, res, pathmatch, callback, templateReader) {
  getQueries(req, function gotQueries(err) {
    if (err != null) {
      log('While getting queries for ' + req.uri + ':\n'
        + err
        , 'error');
    } else {
      // params: template parameters (JSON-serializable).
      callback(req.query, pathmatch, function end (params, options) {
        options = options || {};
        var templates = options.template || pathmatch[0];
        var reader = options.reader || templateReader;
        if (Object(options.string) instanceof String) {
          templates = [streamFromString(options.string)];
        } else if (Object(params) instanceof String) {
          templates = [streamFromString(params)];
        } else if (!Array.isArray(templates)) {
          templates = [templates];
        }
        if (!res.getHeader('Content-Type')  // Allow overriding.
            && (Object(templates[0]) instanceof String)) {
          res.mime(p.extname(templates[0]).slice(1));
        }
        for (var i = 0; i < templates.length; i++) {
          if (Object(templates[i]) instanceof String) {
            // `templates[i]` is a string path for a file.
            var templatePath = p.join(req.server.documentRoot, templates[i]);
            templates[i] = fs.createReadStream(templatePath);
          }
        }

        var template = concatStreams(templates);

        template.on('error', function(err) {
          log(err.stack, 'error');
          res.end('Not Found\n');
        });

        if (params === null || reader === null) {
          // No data was given. Same behaviour as static.
          template.pipe(res);
        } else {
          reader(template, res, params, function errorcb(err) {
            if (err) {
              log(err.stack, 'error');
              res.end('Not Found\n');
            }
          });
        }
      }, req.ask);
    }
  });
}
146370
function getComponentMetadataPath(filepath) {
	const extname = path.extname(filepath)
	return filepath.substring(0, filepath.length - extname.length) + '.json'
}
162702
def _from_metadata(self, urlpath):
        """"""
        md = self.get_metadata(urlpath)
        if md is not None:
            return [self._path(urlpath)]
1135433
def get_template_as_xml(template_id,**kwargs):
    
    template_xml = etree.Element("template_definition")

    template_i = db.DBSession.query(Template).filter(
            Template.id==template_id).options(
                #joinedload_all('templatetypes.typeattrs.default_dataset.metadata')
                joinedload('templatetypes').joinedload('typeattrs').joinedload('default_dataset').joinedload('metadata')

            ).one()

    template_name = etree.SubElement(template_xml, "template_name")
    template_name.text = template_i.name
    template_description = etree.SubElement(template_xml, "template_description")
    template_description.text = template_i.description
    resources = etree.SubElement(template_xml, "resources")

    for type_i in template_i.templatetypes:
        xml_resource    = etree.SubElement(resources, "resource")

        resource_type   = etree.SubElement(xml_resource, "type")
        resource_type.text   = type_i.resource_type

        name   = etree.SubElement(xml_resource, "name")
        name.text   = type_i.name

        description   = etree.SubElement(xml_resource, "description")
        description.text   = type_i.description

        alias   = etree.SubElement(xml_resource, "alias")
        alias.text   = type_i.alias

        if type_i.layout is not None and type_i.layout != "":
            layout = _get_layout_as_etree(type_i.layout)
            xml_resource.append(layout)

        for type_attr in type_i.typeattrs:
            attr = _make_attr_element_from_typeattr(xml_resource, type_attr)

        resources.append(xml_resource)

    xml_string = etree.tostring(template_xml, encoding="unicode")

    return xml_string
732973
def get_template_path(self, content=None):
        
        if isinstance(content, Paginator):
            return op.join('api', 'paginator.%s' % self.format)

        if isinstance(content, UpdatedList):
            return op.join('api', 'updated.%s' % self.format)

        app = ''
        name = self.resource._meta.name

        if not content:
            content = self.resource._meta.model

        if isinstance(content, (Model, ModelBase)):
            app = content._meta.app_label
            name = content._meta.module_name

        basedir = 'api'
        if getattr(self.resource, 'api', None):
            basedir = self.resource.api.prefix

        return op.join(
            basedir,
            str(self.resource.api or ''), app, "%s.%s" % (name, self.format)
        )
605394
protected URL getNearTemplateURL(String jarFile, String template) {
        if (jarFile != null) {
            Enumeration<URL> urls = IOUtils.getResources(template);
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                if (url.getPath().startsWith(jarFile)) {
                    return url;
                }
            }
        }
        return null;
    }
672360
def xpath(request):
    """"""
    ident_hash = request.params.get('id')
    xpath_string = request.params.get('q')

    if not ident_hash or not xpath_string:
        exc = httpexceptions.HTTPBadRequest
        exc.explanation = 'You must supply both a UUID and an xpath'
        raise exc

    try:
        uuid, version = split_ident_hash(ident_hash)
    except IdentHashShortId as e:
        uuid = get_uuid(e.id)
        version = e.version
    except IdentHashMissingVersion as e:
        uuid = e.id
        version = get_latest_version(e.id)
    except IdentHashSyntaxError:
        raise httpexceptions.HTTPBadRequest

    settings = get_current_registry().settings
    with db_connect() as db_connection:
        with db_connection.cursor() as cursor:
            result = get_content_metadata(uuid, version, cursor)

    resp = request.response

    if result['mediaType'] == COLLECTION_MIMETYPE:
        matched_route = request.matched_route.name
        results = xpath_book(request, uuid, version,
                             return_json=matched_route.endswith('json'))
        if matched_route.endswith('json'):
            results = {'results': list(results)}
            resp.body = json.dumps(results)
            resp.content_type = 'application/json'
        else:
            resp.body = results
            resp.content_type = 'application/xhtml+xml'
    else:
        results = {'results': list(xpath_page(request, uuid, version))}
        resp.body = json.dumps(results)
        resp.content_type = 'application/json'

    resp.status = "200 OK"
    return resp
565049
function (type, path) {
    var version = config.timestamp && config.build ? '?v=' + config.time : '';
    return filter.get('tag', type)(path + version) || '';
}
715120
public static function getTemplatePath(
        $settings,
        $elementKey,
        $onlyTemplateName = false,
        $path = null
    ): string {
        if (!$path) {
            $path = self::getFileAbsFileName(rtrim($settings['content'], '/') . '/');
        }
        $fileExtension = '.html';

        // check if an html file with underscores exist
        if (file_exists($path . CoreUtility::underscoredToUpperCamelCase($elementKey) . $fileExtension)
        ) {
            $fileName = CoreUtility::underscoredToUpperCamelCase($elementKey);
        } else {
            if (file_exists($path . ucfirst($elementKey) . $fileExtension)
            ) {
                $fileName = ucfirst($elementKey);
            } else {
                if (file_exists($path . $elementKey . $fileExtension)) {
                    $fileName = $elementKey;
                } else {
                    $fileName = CoreUtility::underscoredToUpperCamelCase($elementKey);
                }
            }
        }

        if ($onlyTemplateName) {
            return $fileName . $fileExtension;
        }
        return $path . $fileName . $fileExtension;
    }