Internal method to translate the named CRITs TLO type to a URL
        specific string.
439554
def _type_translation(self, str_type):
        
        if str_type == 'Indicator':
            return 'indicators'
        if str_type == 'Domain':
            return 'domains'
        if str_type == 'IP':
            return 'ips'
        if str_type == 'Sample':
            return 'samples'
        if str_type == 'Event':
            return 'events'
        if str_type == 'Actor':
            return 'actors'
        if str_type == 'Email':
            return 'emails'
        if str_type == 'Backdoor':
            return 'backdoors'

        raise CRITsInvalidTypeError('Invalid object type specified: '
                                    '{}'.format(str_type))
245044
def enqueue_conversion_path(url_string, to_type, enqueue_convert):
    '''
    
    '''
    target_ts = TypeString(to_type)
    foreign_res = ForeignResource(url_string)

    # Determine the file type of the foreign resource
    typed_foreign_res = foreign_res.guess_typed()

    if not typed_foreign_res.cache_exists():
        # Symlink to new location that includes typed extension
        typed_foreign_res.symlink_from(foreign_res)

    # Now find path between types
    original_ts = typed_foreign_res.typestring
    path = singletons.converter_graph.find_path(original_ts, target_ts)

    # Loop through each step in graph path and convert
    is_first = True
    for converter_class, from_ts, to_ts in path:
        converter = converter_class()
        in_resource = TypedResource(url_string, from_ts)
        if is_first:  # Ensure first resource is just the source one
            in_resource = TypedForeignResource(url_string, from_ts)
        out_resource = TypedResource(url_string, to_ts)
        enqueue_convert(converter, in_resource, out_resource)
        is_first = False
409592
def _urlencode(items):
    """"""
    try:
        return urllib.urlencode(items)
    except UnicodeEncodeError:
        return urllib.urlencode([(k, smart_str(v)) for k, v in items])
358222
def urlunparse(components):
    """"""
    scheme, netloc, url, params, query, fragment, _coerce_result = (
                                                  _coerce_args(*components))
    if params:
        url = "%s;%s" % (url, params)
    return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment)))
35941
public static String[] mappingGroovyName(String url,String version) {
		Iterator it = urlMap.entrySet().iterator();
		while (it.hasNext()) {
			Entry entry = (Entry) it.next();

			String key = (String) entry.getKey();
			if(key.equals(url)){
				MicroUrlBean urlBean=(MicroUrlBean) entry.getValue();
				if(version==null || "".equals(version)){
					return urlBean.getDefaultInfo();
				}else{
					version=versionFormat(version);
				}
				Entry fEntry=urlBean.getTreeMap().floorEntry(version);
				String[] ret=null;
				if(fEntry!=null){
					ret=(String[]) fEntry.getValue();
				}
				return ret;
			}
		}
		return null;
	}
474146
def found_url(self, url, name, base):
        """"""
        assert isinstance(url, unicode) or url is None, repr(url)
        self.callback(url, line=self.parser.last_lineno(),
                      column=self.parser.last_column(), name=name, base=base)
607036
def to_url(request):
        """"""
        scheme, netloc, path, query, fragment = urlsplit(to_utf8(request.url))
        query = parse_qs(query)

        for key, value in request.data_and_params.iteritems():
            query.setdefault(key, []).append(value)

        query = urllib.urlencode(query, True)
        return urlunsplit((scheme, netloc, path, query, fragment))
826609
def with_name(self, name):
        
        # N.B. DOES cleanup query/fragment
        if not isinstance(name, str):
            raise TypeError("Invalid name type")
        if "/" in name:
            raise ValueError("Slash in name is not allowed")
        name = self._PATH_QUOTER(name)
        if name in (".", ".."):
            raise ValueError(". and .. values are forbidden")
        parts = list(self.raw_parts)
        if self.is_absolute():
            if len(parts) == 1:
                parts.append(name)
            else:
                parts[-1] = name
            parts[0] = ""  # replace leading '/'
        else:
            parts[-1] = name
            if parts[0] == "/":
                parts[0] = ""  # replace leading '/'
        return URL(
            self._val._replace(path="/".join(parts), query="", fragment=""),
            encoded=True,
        )
1119536
function (url, qsName, qsValue) {

    let urlObj = Url.parse(url);
    if (qsName && qsValue) {
        urlObj.query = Querystring.parse(qsName + '=' + qsValue);
        urlObj.search = '?' + encodeURIComponent(qsName) + '=' + encodeURIComponent(qsValue);
    } else {
        urlObj.search = '';
    }
    return urlObj.format(urlObj);
}
224984
function _getStringAtPos(hostEditor, pos) {
        var token = hostEditor._codeMirror.getTokenAt(pos, true);

        // If the pos is at the beginning of a name, token will be the
        // preceding whitespace or dot. In that case, try the next pos.
        if (!/\S/.test(token.string) || token.string === ".") {
            token = hostEditor._codeMirror.getTokenAt({line: pos.line, ch: pos.ch + 1}, true);
        }

        if (token.type === "string") {
            var string = token.string;

            // Strip quotes
            var ch = string[0];
            if (ch === "\"" || ch === "'") {
                string = string.substr(1);
            }
            ch = string[string.length - 1];
            if (ch === "\"" || ch === "'") {
                string = string.substr(0, string.length - 1);
            }

            return string;
        } else {

            // Check for url(...);
            var line = hostEditor._codeMirror.getLine(pos.line);
            var match = /url\s*\(([^)]*)\)/.exec(line);

            if (match && match[1]) {
                // URLs are relative to the doc
                var docPath = hostEditor.document.file.fullPath;

                docPath = docPath.substr(0, docPath.lastIndexOf("/"));

                return docPath + "/" + match[1];
            }
        }

        return "";
    }
324562
def to_string(self):
        """"""
        root = etree.Element('urlset', nsmap={None: SITEMAP_NS})
        for url in self.urls:
            url.generate(root)
        return etree.tostring(root, pretty_print=True, xml_declaration=True,
                              encoding='utf-8')
555634
def urlopen(url, method=None, params=None, data=None, json=None,
            headers=None, allow_redirects=False, timeout=30,
            verify_ssl=True, user_agent=None):
    
    if user_agent is not None:
        warnings.warn('user_agent is no longer used with safe_urlopen')

    session = build_session()

    kwargs = {}

    if json:
        kwargs['json'] = json
        if not headers:
            headers = {}
        headers.setdefault('Content-Type', 'application/json')

    if data:
        kwargs['data'] = data

    if params:
        kwargs['params'] = params

    if headers:
        kwargs['headers'] = headers

    if method is None:
        method = 'POST' if (data or json) else 'GET'

    try:
        response = session.request(
            method=method,
            url=url,
            allow_redirects=allow_redirects,
            timeout=timeout,
            verify=verify_ssl,
            **kwargs
        )
    # Our version of requests does not transform ZeroReturnError into an
    # appropriately generically catchable exception
    except ZeroReturnError as exc:
        import sys
        exc_tb = sys.exc_info()[2]
        six.reraise(SSLError, exc, exc_tb)
        del exc_tb

    # requests' attempts to use chardet internally when no encoding is found
    # and we want to avoid that slow behavior
    if not response.encoding:
        response.encoding = 'utf-8'

    return response
558019
def extract_translations(self, string):
        """"""

        trans = []
        for t in Lexer(string.decode("utf-8"), None).tokenize():
            if t.token_type == TOKEN_BLOCK:
                if not t.contents.startswith(
                        (self.tranz_tag, self.tranzchoice_tag)):
                    continue

                is_tranzchoice = t.contents.startswith(
                    self.tranzchoice_tag +
                    " ")
                kwargs = {
                    "id": self._match_to_transvar(id_re, t.contents),
                    "number": self._match_to_transvar(number_re, t.contents),
                    "domain": self._match_to_transvar(domain_re, t.contents),
                    "locale": self._match_to_transvar(locale_re, t.contents),
                    "is_transchoice": is_tranzchoice, "parameters": TransVar(
                        [x.split("=")[0].strip() for x in properties_re.findall(t.contents) if x],
                        TransVar.LITERAL
                    ),
                    "lineno": t.lineno,
                }

                trans.append(Translation(**kwargs))
        return trans
313167
function parse (tmpl) {
  tmpl = tmpl || ''
  const parser = uritemplate.parse(tmpl)

  return function expand (params) {
    params = params || {}
    return parser.expand(params)
  }
}
190759
function generateNewQueryString(language) {
    var url = parseURL(location.search);
    if (url.language) {
      url.language = language;
      return stringifyURL(url);
    }
    return language;
  }
113493
def _build_url(url, _params):
    """"""

    # Support for unicode domain names and paths.
    scheme, netloc, path, params, query, fragment = urlparse(url)
    netloc = netloc.encode('idna').decode('utf-8')
    if not path:
        path = '/'

    if six.PY2:
        if isinstance(scheme, six.text_type):
            scheme = scheme.encode('utf-8')
        if isinstance(netloc, six.text_type):
            netloc = netloc.encode('utf-8')
        if isinstance(path, six.text_type):
            path = path.encode('utf-8')
        if isinstance(params, six.text_type):
            params = params.encode('utf-8')
        if isinstance(query, six.text_type):
            query = query.encode('utf-8')
        if isinstance(fragment, six.text_type):
            fragment = fragment.encode('utf-8')

    enc_params = _encode_params(_params)
    if enc_params:
        if query:
            query = '%s&%s' % (query, enc_params)
        else:
            query = enc_params
    url = (urlunparse([scheme, netloc, path, params, query, fragment]))
    return url
222420
@Override
    public void getXliffFromDocumentTranslationRequest(String trId,
            String srcLanguage, String trgLanguage, OutputStream outputXliff)
            throws ServiceException, IOException {
        if (trId == null || trId.isEmpty()) {
            throw new IllegalArgumentException("Non-empty trId must be specified.");
        }
        if (srcLanguage == null || srcLanguage.isEmpty()) {
            throw new IllegalArgumentException("Non-empty srcLanguage must be specified.");
        }
        if (trgLanguage == null || trgLanguage.isEmpty()) {
            throw new IllegalArgumentException("Non-empty trgLanguage must be specified.");
        }

        StringBuilder urlBuf = new StringBuilder();
        urlBuf
            .append(escapePathSegment(account.getInstanceId()))
            .append("/v2/doc-xliff/trs/")
            .append(trId)
            .append("/")
            .append(srcLanguage)
            .append("/")
            .append(trgLanguage);

        ApiResponse resp = null;
        try {
            resp = invokeApi("GET", urlBuf.toString(), null, null, false);
        } catch (Exception e) {
            String errMsg = "Error while processing API request GET " + urlBuf;
            throw new ServiceException(errMsg, e);
        }
        assert resp != null;

        if (resp.contentType == null || !resp.contentType.equalsIgnoreCase("application/xliff+xml")) {
            throw new ServiceException("Received HTTP status: " + resp.status
                    + " with non-XLIFF response (" + resp.contentType + ") from GET"
                    + " " + urlBuf.toString());
        }
        assert resp.body != null;
        outputXliff.write(resp.body);
    }