Parses paths in the following formats:

        url: username/project/runs/run_id
        path: username/project/run_id
        docker: username/project:run_id

        username is optional and will fallback to the current logged in user.
973626
def _parse_path(self, path):
        
        run = self.settings['run']
        project = self.settings['project']
        username = self.settings['username']
        parts = path.replace("/runs/", "/").split("/")
        if ":" in parts[-1]:
            run = parts[-1].split(":")[-1]
            parts[-1] = parts[-1].split(":")[0]
        elif parts[-1]:
            run = parts[-1]
        if len(parts) > 1:
            project = parts[1]
            if username and run == project:
                project = parts[0]
            else:
                username = parts[0]
        else:
            project = parts[0]
        return (username, project, run)
666947
def run(self, path=""):
        """"""
        username, project, run = self._parse_path(path)
        if not self._runs.get(path):
            self._runs[path] = Run(self.client, username, project, run)
        return self._runs[path]
1074193
def login(self, registry, docker_secret_path):
        
        logger.info("logging in: registry '%s', secret path '%s'", registry, docker_secret_path)
        # Docker-py needs username
        dockercfg = Dockercfg(docker_secret_path)
        credentials = dockercfg.get_credentials(registry)
        unpacked_auth = dockercfg.unpack_auth_b64(registry)
        username = credentials.get('username')
        if unpacked_auth:
            username = unpacked_auth.username
        if not username:
            raise RuntimeError("Failed to extract a username from '%s'" % dockercfg)

        logger.info("found username %s for registry %s", username, registry)

        response = self.d.login(registry=registry, username=username,
                                dockercfg_path=dockercfg.json_secret_path)
        if not response:
            raise RuntimeError("Failed to login to '%s' with config '%s'" % (registry, dockercfg))
        if u'Status' in response and response[u'Status'] == u'Login Succeeded':
            logger.info("login succeeded")
        else:
            if not(isinstance(response, dict) and 'password' in response.keys()):
                # for some reason docker-py returns the contents of the dockercfg - we shouldn't
                # be displaying that
                logger.debug("response: %r", response)
119217
def load(*args)
      super(*args)
      self.id = self.uri.split('/').last if self.id.nil? and defined? self.uri
    end
1226522
def user_parse(data):
        """"""
        _user = data.get('oauth', {}).get('user', {})
        yield 'id', _user.get('id')
        yield 'username', _user.get('username')
        first_name, _, last_name = _user.get('display_name').partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
1164730
def strip_path_session_id(path):
    ''''''
    for pattern in SESSION_ID_PATH_PATTERNS:
        match = pattern.match(path)
        if match:
            path = match.group(1) + match.group(3)

    return path
311212
def path(project, credentials):
        """"""
        user, oauth_access_token = parsecredentials(credentials) #pylint: disable=unused-variable
        return settings.ROOT + "projects/" + user + '/' + project + "/"
643649
def parse(self):
        
        d = {
            'pathname': None,
            'protocols': self._get_protocols(),
            'protocol': 'ssh',
            'href': self._url,
            'resource': None,
            'user': None,
            'port': None,
            'name': None,
            'owner': None,
        }
        for regex in POSSIBLE_REGEXES:
            match = regex.search(self._url)
            if match:
                d.update(match.groupdict())
                break
        else:
            msg = "Invalid URL '{}'".format(self._url)
            raise ParserError(msg)

        return Parsed(**d)
15669
def _urlparse(path):
    
    url = urlparse.urlparse(path)
    _validate_url(url)
    if not url.scheme or url.scheme == 'file://':
        # Normalize path, and set scheme to "file" if missing
        path = os.path.abspath(
            os.path.expanduser(path))
        url = urlparse.urlparse('file://'+path)
    return url
1294762
function parsePath(path) {
        var lastSlash = path.lastIndexOf("/"), folder, rest;
        if (lastSlash === path.length - 1) {
            lastSlash = path.slice(0, path.length - 1).lastIndexOf("/");
        }
        if (lastSlash >= 0) {
            rest = " - " + (lastSlash ? path.slice(0, lastSlash) : "/");
            folder = path.slice(lastSlash + 1);
        } else {
            rest = "/";
            folder = path;
        }

        return {path: path, folder: folder, rest: rest};
    }
167294
def _get_registry_auth(registry_url, config_path):
        
        username = None
        password = None
        try:
            docker_config = json.load(open(config_path))
        except ValueError:
            # The configuration file is empty
            return username, password
        if docker_config.get('auths'):
            docker_config = docker_config['auths']
        auth_key = docker_config.get(registry_url, {}).get('auth', None)
        if auth_key:
            username, password = base64.b64decode(auth_key).split(':', 1)
        return username, password
707331
function parsePathParams (req, res, next) {
    if (util.isSwaggerRequest(req)) {
      req.pathParams = {};

      if (req.swagger.pathName.indexOf("{") >= 0) {
        // Convert the Swagger path to a RegExp
        let paramNames = [];
        let pathPattern = req.swagger.pathName.replace(util.swaggerParamRegExp, (match, paramName) => {
          paramNames.push(paramName);
          return "([^\/]+)";
        });

        // Exec the RegExp to get the path param values from the URL
        let values = new RegExp(pathPattern + "\/?$", "i").exec(req.path);

        // Parse each path param
        for (let i = 1; i < values.length; i++) {
          let paramName = paramNames[i - 1];
          let paramValue = decodeURIComponent(values[i]);
          let param = _.find(req.swagger.params, { in: "path", name: paramName });

          util.debug('    Parsing the "%s" path parameter', paramName);
          req.pathParams[paramName] = paramParser.parseParameter(param, paramValue, param);
        }
      }
    }

    next();
  }
811791
def parse_users(self, user, params):
        
        if user['UserName'] in self.users:
            return
        api_client = params['api_client']
        # Ensure consistent attribute names across resource types
        user['id'] = user.pop('UserId')
        user['name'] = user.pop('UserName')
        user['arn'] = user.pop('Arn')
        policies = self.__get_inline_policies(api_client, 'user', user['id'], user['name'])
        if len(policies):
            user['inline_policies'] = policies
        user['inline_policies_count'] = len(policies)
        user['groups'] = []
        groups = handle_truncated_response(api_client.list_groups_for_user, {'UserName': user['name']}, ['Groups'])['Groups']
        for group in groups:
            user['groups'].append(group['GroupName'])
        try:
            user['LoginProfile'] = api_client.get_login_profile(UserName = user['name'])['LoginProfile']
        except Exception as e:
            pass
        user['AccessKeys'] = api_client.list_access_keys(UserName = user['name'])['AccessKeyMetadata']
        user['MFADevices'] = api_client.list_mfa_devices(UserName = user['name'])['MFADevices']
        # TODO: Users signing certss
        self.users[user['id']] = user
507656
def _get_path_for_op_id(self, id: str) -> Optional[str]:
        
        for path_key, path_value in self._get_spec()['paths'].items():
            for method in self.METHODS:
                if method in path_value:
                    if self.OPERATION_ID_KEY in path_value[method]:
                        if path_value[method][self.OPERATION_ID_KEY] == id:
                            return path_key
        return None
782528
def websocket_query(self, path, params={}):
        

        url = "http://docker/v" + self._api_version + "/" + path
        connection = yield from self._session.ws_connect(url,
                                                         origin="http://docker",
                                                         autoping=True)
        return connection
357193
def _parse_path(self, path):
        """"""
        # Support specifying another host via hdfs://host:port/path syntax
        # We ignore the scheme and piece together the query and fragment
        # Note that HDFS URIs are not URL encoded, so a '?' or a '#' in the URI is part of the
        # path
        parts = urlsplit(path, allow_fragments=False)
        if not parts.path.startswith('/'):
            raise ValueError("Path must be absolute, was given {}".format(path))
        if parts.scheme not in ('', 'hdfs', 'hftp', 'webhdfs'):
            warnings.warn("Unexpected scheme {}".format(parts.scheme))
        assert not parts.fragment
        path = parts.path
        if parts.query:
            path += '?' + parts.query
        if parts.netloc:
            hosts = self._parse_hosts(parts.netloc)
        else:
            hosts = self.hosts
        return hosts, path
737335
def parse_config_path(args=sys.argv):
    

    config = CONFIG_PATH
    if '--config' in args:
        idx = args.index('--config')
        if len(args) > idx + 1:
            config = args.pop(idx + 1)
        args.pop(idx)
    return config