Duplicate and remove excess baggage from the provided URI
503841
def clean_uri(uri)
      uri = uri.dup
      uri.path     = ""
      uri.query    = nil
      uri.fragment = nil
      uri
    end
1153490
def clean_uri(self):
        
        if self.instance.fixed:
            return self.instance.uri

        uri = self.cleaned_data['uri']
        # todo: URI validation
        return uri
69005
def clean_iri(uri_string):
    ''''''
    uri_string = str(uri_string).strip()
    if uri_string[:1] == "<" and uri_string[len(uri_string)-1:] == ">":
        uri_string = uri_string[1:len(uri_string)-1]
    return uri_string
1105805
public String removeRequestBaggage(String key) {
        if (BAGGAGE_ENABLE && key != null) {
            return requestBaggage.remove(key);
        }
        return null;
    }
868836
def processURI(self, uri, prefix=''):
        
        components = urlparse.urlparse(uri)
        query = dict(urlparse.parse_qsl(components.query))
        bust = True
        bust &= bool(query)  # bust the cache if the query has stuff in it
        # bust the cache if the query key 'cache' isn't true
        bust &= query.get('cache') != 'true'
        return prefix + components.path, bust
1008883
def atexit_rmglob(path,
                  glob=glob.glob,
                  isdir=os.path.isdir,
                  isfile=os.path.isfile,
                  remove=os.remove,
                  rmtree=shutil.rmtree):  # pragma: no cover
    """"""
    for p in glob(path):
        if isfile(p):
            remove(p)
        elif isdir(p):
            rmtree(p)
466438
private String sanitizeUri(String uri) {
        if (uri == null || uri.length() == 0) {
            return null;
        }
        try {
            return new URI(uri).toString();
        } catch (URISyntaxException e) {
            return null;
        }
    }
901697
function it_retains_the_original_state_of_the_instance_duplicated_with_new_scheme()
    {
        $original_uri = (string) $this->getWrappedObject();

        $new_scheme = $this->withScheme("http");

        $this->__toString()->shouldReturn($original_uri);
    }
291215
def clean_url(self):
        """"""
        raw_url = self.request['url']
        parsed_url = urlparse(raw_url)
        qsl = parse_qsl(parsed_url.query)
        for qs in qsl:
            new_url = self._join_url(parsed_url,
                                     [i for i in qsl if i is not qs])
            new_request = deepcopy(self.request)
            new_request['url'] = new_url
            self._add_task('qsl', qs, new_request)
        return self
319498
static public Collection<URI> removeRedundantPaths(Collection<URI> uris) {
		List<URI> result = new ArrayList<URI>();
		for (URI uri : uris) {
			String path = uri.getPath();
			if (!path.endsWith("/")) {  //$NON-NLS-1$
				path += "/"; //$NON-NLS-1$
			}
			boolean addIt = true;
			for (int i = 0; i < result.size(); i++) {
				URI testUri = result.get(i);
				if (!StringUtils.equals(testUri.getScheme(), uri.getScheme()) ||
						!StringUtils.equals(testUri.getHost(), uri.getHost()) ||
						testUri.getPort() != uri.getPort()) {
					continue;
				}
				String test = testUri.getPath();
				if (!test.endsWith("/")) { //$NON-NLS-1$
					test += "/"; //$NON-NLS-1$
				}
				if (path.equals(test) || path.startsWith(test)) {
					addIt = false;
					break;
				} else if (test.startsWith(path)) {
					result.remove(i);
				}
			}
			if (addIt)
				result.add(uri);
		}
		// Now copy the trimmed list back to the original
		return result;
	}
1301200
def rm(self, path):
        """"""

        resp = self._sendRequest("DELETE", path)
        # By documentation server must return 200 "OK", but I get 204 "No Content".
        # Anyway file or directory have been removed.
        if not (resp.status_code in (200, 204)):
            raise YaDiskException(resp.status_code, resp.content)
198221
function removeDirIfOk(p) {
  return globP(path.join(p, '*' + consts.DIFF_PNG_SUFFIX))
    .then(function(res) {
      if (res.length === 0) {
        return rimrafP(p);
      }
      return Promise.resolve();
    });
}
310628
def delt(self, *args, **kargs):
        """"""
        self.invalidate_cache()
        route = self.make_route(*args, **kargs)
        try:
            i = self.routes.index(route)
            del(self.routes[i])
        except ValueError:
            warning("no matching route found")
54869
function removeDuplicates(files, duplicates) {
        var i;
        var ret = [];
        var found = {};

        if (duplicates) {
            for (i=0; i < duplicates.length; i++) {
                found[duplicates[i].dst] = true;
            }
        }

        for (i=0; i < files.length; i++) {
            if (!found[files[i].dst]) {
                found[files[i].dst] = true;
                ret.push(files[i]);
            }
        }
        return ret;
    }
1372177
def deleteUnused(self):
        
        (count, size) = (0, 0)

        for (diff, path) in self.extraKeys.items():
            if path.startswith("/"):
                continue

            keyName = self._keyName(diff.toUUID, diff.fromUUID, path)

            count += 1
            size += diff.size

            if self._skipDryRun(logger, 'INFO')("Trash: %s", diff):
                continue

            try:
                self.bucket.copy_key(theTrashPrefix + keyName, self.bucket.name, keyName)
                self.bucket.delete_key(keyName)
            except boto.exception.S3ResponseError as error:
                logger.error("%s: %s", error.code, error.message)

            try:
                keyName = os.path.dirname(keyName) + Store.theInfoExtension
                self.bucket.copy_key(theTrashPrefix + keyName, self.bucket.name, keyName)
                self.bucket.delete_key(keyName)
            except boto.exception.S3ResponseError as error:
                logger.debug("%s: %s", error.code, error.message)

        logger.info("Trashed %d diffs (%s)", count, humanize(size))
680291
def delete(expnum, ccd, version, ext, prefix=None):
    
    uri = get_uri(expnum, ccd=ccd, version=version, ext=ext, prefix=prefix)
    remove(uri)
1213190
function (req, res, next) {
                    req.mounted = true
                    req.url     = req.url.replace(remove, '')

                    // clear cached req.path
                    delete req._path
                    delete req._pathLength

                    next()
                }