Upstream bug in python:
    https://bugs.python.org/issue26822
420680
def methodcaller(name, *args):
    
    func = operator.methodcaller(name, *args)
    return lambda obj, **kwargs: func(obj)
633671
def _process_dupe_code_violation(self, lines, current_line, message):
        
        src_paths = []
        message_match = self.dupe_code_violation_regex.match(message)
        if message_match:
            for _ in range(int(message_match.group(1))):
                current_line += 1
                match = self.multi_line_violation_regex.match(
                    lines[current_line]
                )
                src_path, l_number = match.groups()
                src_paths.append(('%s.py' % src_path, l_number))
        return src_paths
533323
def fix_pep_479(generator):
    
    @functools.wraps(generator)
    def _wrapped_generator(*args, **kwargs):
        try:
            for x in generator(*args, **kwargs):
                yield x
        except RuntimeError:
            return

    return _wrapped_generator
1049738
def as_issue(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.issue_url
        )
        return github.Issue.Issue(self._requester, headers, data, completed=True)
738489
def get_upstream_version(package):
    
    import apt_pkg
    cache = apt_cache()
    try:
        pkg = cache[package]
    except Exception:
        # the package is unknown to the current apt cache.
        return None

    if not pkg.current_ver:
        # package is known, but no version is currently installed.
        return None

    return apt_pkg.upstream_version(pkg.current_ver.ver_str)
918482
def prob_correction(self, f=1):
        
        total = {'rockyou': 32602160}
        return f * self._T[TOTALF_W] / total.get(self._leak, self._T[TOTALF_W])
971479
def dump_all_thread_tracebacks(exclude_thread_ids=None, file=None):
    
    if exclude_thread_ids is None:
        exclude_thread_ids = []
    if not file:
        file = sys.stdout
    import threading

    if hasattr(sys, "_current_frames"):
        print("", file=file)
        threads = {t.ident: t for t in threading.enumerate()}
        # noinspection PyProtectedMember
        for tid, stack in sys._current_frames().items():
            if tid in exclude_thread_ids:
                continue
            # This is a bug in earlier Python versions.
            # http://bugs.python.org/issue17094
            # Note that this leaves out all threads not created via the threading module.
            if tid not in threads:
                continue
            tags = []
            thread = threads.get(tid)
            if thread:
                assert isinstance(thread, threading.Thread)
                if thread is threading.currentThread():
                    tags += ["current"]
                # noinspection PyProtectedMember,PyUnresolvedReferences
                if isinstance(thread, threading._MainThread):
                    tags += ["main"]
                tags += [str(thread)]
            else:
                tags += ["unknown with id %i" % tid]
            print("Thread %s:" % ", ".join(tags), file=file)
            print_tb(stack, file=file)
            print("", file=file)
        print("That were all threads.", file=file)
    else:
        print("Does not have sys._current_frames, cannot get thread tracebacks.", file=file)
1083372
def list(self, path=None, with_metadata=False, include_partitions=False):
        ''''''
        return self.upstream.list(
            path,
            with_metadata=with_metadata,
            include_partitions=include_partitions)
588576
def forward_exception(self, etype, evalue, tb):
        
        self._excepthook(etype, evalue, tb)
476525
def build(self, bug: Bug):
        
        r = self.__api.post('bugs/{}/build'.format(bug.name))

        if r.status_code == 204:
            return
        if r.status_code == 200:
            raise Exception("bug already built: {}".format(bug.name))
        # TODO: implement ImageBuildFailed.from_dict
        if r.status_code == 400:
            raise Exception("build failure")
        if r.status_code == 404:
          raise KeyError("no bug found with given name: {}".format(bug.name))

        self.__api.handle_erroneous_response(r)
458049
def module2upstream(mod):
    
    for rule in OPENSTACK_UPSTREAM_PKG_MAP:
        pkglist = rule(mod, dist=None)
        if pkglist:
            return pkglist[0]
    return mod
260055
def _parse_bugs_callback(self, value):
        
        return list(map(lambda x: self._parse_bug(x), value['bugs']))
183498
function issue(eat, value, silent) {
  var self = this
  var index
  var start
  var subvalue
  var href
  var now
  var exit
  var node

  if (value.charCodeAt(0) === CC_HASH) {
    index = 1
  } else if (value.slice(0, PREFIX.length).toLowerCase() === PREFIX) {
    index = PREFIX.length
  } else {
    return
  }

  start = index
  index = issueEnd(value, index)

  if (index === -1) {
    return
  }

  /* istanbul ignore if - maybe used by plug-ins */
  if (silent) {
    return true
  }

  now = eat.now()
  href = gh(self.githubRepo) + 'issues' + C_SLASH + value.slice(start, index)
  subvalue = value.slice(0, index)

  now.column += start

  exit = self.enterLink()

  node = eat(subvalue)({
    type: 'link',
    title: null,
    url: href,
    children: self.tokenizeInline(subvalue, now)
  })

  exit()

  return node
}
230221
function(err) {
    switch (err.code) {
      case 1:
        return Error('CURLE_UNSUPPORTED_PROTOCOL');
      case 2:
        return Error('CURLE_FAILED_INIT');
      case 3:
        return Error('CURLE_URL_MALFORMAT');
      case 4:
        return Error('CURLE_NOT_BUILT_IN');
      case 5:
        return Error('CURLE_COULDNT_RESOLVE_PROXY');
      case 6:
        return Error('CURLE_COULDNT_RESOLVE_HOST');
      case 7:
        return Error('CURLE_COULDNT_CONNECT');
      case 8:
        return Error('CURLE_FTP_WEIRD_SERVER_REPLY');
      case 9:
        return Error('CURLE_REMOTE_ACCESS_DENIED');
      case 10:
        return Error('CURLE_FTP_ACCEPT_FAILED');
      case 11:
        return Error('CURLE_FTP_WEIRD_PASS_REPLY');
      case 12:
        return Error('CURLE_FTP_ACCEPT_TIMEOUT');
      case 13:
        return Error('CURLE_FTP_WEIRD_PASV_REPLY');
      case 14:
        return Error('CURLE_FTP_WEIRD_227_FORMAT');
      case 15:
        return Error('CURLE_FTP_CANT_GET_HOST');
      case 17:
        return Error('CURLE_FTP_COULDNT_SET_TYPE');
      case 18:
        return Error('CURLE_PARTIAL_FILE');
      case 19:
        return Error('CURLE_FTP_COULDNT_RETR_FILE');
      case 21:
        return Error('CURLE_QUOTE_ERROR');
      case 22:
        return Error('CURLE_HTTP_RETURNED_ERROR');
      case 23:
        return Error('CURLE_WRITE_ERROR');
      case 25:
        return Error('CURLE_UPLOAD_FAILED');
      case 26:
        return Error('CURLE_READ_ERROR');
      case 27:
        return Error('CURLE_OUT_OF_MEMORY');
      case 28:
        return Error('CURLE_OPERATION_TIMEDOUT');
      case 30:
        return Error('CURLE_FTP_PORT_FAILED');
      case 31:
        return Error('CURLE_FTP_COULDNT_USE_REST');
      case 33:
        return Error('CURLE_RANGE_ERROR');
      case 34:
        return Error('CURLE_HTTP_POST_ERROR');
      case 35:
        return Error('CURLE_SSL_CONNECT_ERROR');
      case 36:
        return Error('CURLE_BAD_DOWNLOAD_RESUME');
      case 37:
        return Error('CURLE_FILE_COULDNT_READ_FILE');
      case 38:
        return Error('CURLE_LDAP_CANNOT_BIND');
      case 39:
        return Error('CURLE_LDAP_SEARCH_FAILED');
      case 41:
        return Error('CURLE_FUNCTION_NOT_FOUND');
      case 42:
        return Error('CURLE_ABORTED_BY_CALLBACK');
      case 43:
        return Error('CURLE_BAD_FUNCTION_ARGUMENT');
      case 45:
        return Error('CURLE_INTERFACE_FAILED');
      case 47:
        return Error('CURLE_TOO_MANY_REDIRECTS');
      case 48:
        return Error('CURLE_UNKNOWN_OPTION');
      case 49:
        return Error('CURLE_TELNET_OPTION_SYNTAX');
      case 51:
        return Error('CURLE_PEER_FAILED_VERIFICATION');
      case 52:
        return Error('CURLE_GOT_NOTHING');
      case 53:
        return Error('CURLE_SSL_ENGINE_NOTFOUND');
      case 54:
        return Error('CURLE_SSL_ENGINE_SETFAILED');
      case 55:
        return Error('CURLE_SEND_ERROR');
      case 56:
        return Error('CURLE_RECV_ERROR');
      case 58:
        return Error('CURLE_SSL_CERTPROBLEM');
      case 59:
        return Error('CURLE_SSL_CIPHER');
      case 60:
        return Error('CURLE_SSL_CACERT');
      case 61:
        return Error('CURLE_BAD_CONTENT_ENCODING');
      case 62:
        return Error('CURLE_LDAP_INVALID_URL');
      case 63:
        return Error('CURLE_FILESIZE_EXCEEDED');
      case 64:
        return Error('CURLE_USE_SSL_FAILED');
      case 65:
        return Error('CURLE_SEND_FAIL_REWIND');
      case 66:
        return Error('CURLE_SSL_ENGINE_INITFAILED');
      case 67:
        return Error('CURLE_LOGIN_DENIED');
      case 68:
        return Error('CURLE_TFTP_NOTFOUND');
      case 69:
        return Error('CURLE_TFTP_PERM');
      case 70:
        return Error('CURLE_REMOTE_DISK_FULL');
      case 71:
        return Error('CURLE_TFTP_ILLEGAL');
      case 72:
        return Error('CURLE_TFTP_UNKNOWNID');
      case 73:
        return Error('CURLE_REMOTE_FILE_EXISTS');
      case 74:
        return Error('CURLE_TFTP_NOSUCHUSER');
      case 75:
        return Error('CURLE_CONV_FAILED');
      case 76:
        return Error('CURLE_CONV_REQD');
      case 77:
        return Error('CURLE_SSL_CACERT_BADFILE');
      case 78:
        return Error('CURLE_REMOTE_FILE_NOT_FOUND');
      case 79:
        return Error('CURLE_SSH');
      case 80:
        return Error('CURLE_SSL_SHUTDOWN_FAILED');
      case 81:
        return Error('CURLE_AGAIN');
      case 82:
        return Error('CURLE_SSL_CRL_BADFILE');
      case 83:
        return Error('CURLE_SSL_ISSUER_ERROR');
      case 84:
        return Error('CURLE_FTP_PRET_FAILED');
      case 85:
        return Error('CURLE_RTSP_CSEQ_ERROR');
      case 86:
        return Error('CURLE_RTSP_SESSION_ERROR');
      case 87:
        return Error('CURLE_FTP_BAD_FILE_LIST');
      case 88:
        return Error('CURLE_CHUNK_FAILED');
      case 89:
        return Error('CURLE_NO_CONNECTION_AVAILABLE');
      default:
        return err;
    }
  }
187375
async def error(self, status=500, allowredirect = True, close = True, showerror = None, headers = []):
        
        if showerror is None:
            showerror = self.showerrorinfo
        if self._sendHeaders:
            if showerror:
                typ, exc, tb = sys.exc_info()
                if exc:
                    await self.write('<span style="white-space:pre-wrap">\n', buffering = False)
                    await self.writelines((self.nl2br(self.escape(v)) for v in traceback.format_exception(typ, exc, tb)), buffering = False)
                    await self.write('</span>\n', close, False)
        elif allowredirect and status in self.protocol.errorrewrite:
            await self.rewrite(self.protocol.errorrewrite[status], b'GET')
        elif allowredirect and status in self.protocol.errorredirect:
            await self.redirect(self.protocol.errorredirect[status])
        else:
            self.start_response(status, headers)
            typ, exc, tb = sys.exc_info()
            if showerror and exc:
                await self.write('<span style="white-space:pre-wrap">\n', buffering = False)
                await self.writelines((self.nl2br(self.escape(v)) for v in traceback.format_exception(typ, exc, tb)), buffering = False)
                await self.write('</span>\n', close, False)
            else:
                await self.write(b'<h1>' + _createstatus(status) + b'</h1>', close, False)
893452
def _handle_bugged_tarfile(self, destination, skip_top_level):
        
        args = ['tar', '-xzf', self.destination, '-C', destination]
        if skip_top_level:
            args.extend(['--strip-components', '1'])
        subprocess.check_call(args)
1288539
function(path, fn, upstream, binds) {
		this.assertNotDestroyed('subscribe', path);
		path = parsePath(path);

		if (path[path.length - 1] === '*')
			throw new Error('no more * subscribe allowed - use upstreams instead : ' + path.join('.'));

		var space;
		switch (path[0]) {
			case '$this':
				space = this.map;
				break;
			case '$env':
				return this.env.subscribe(path.slice(1), fn, upstream, binds);
			case '$parent':
				this.assertHasParent(path);
				return this.parent.subscribe(path.slice(1), fn, upstream, binds);
			default:
				space = utils.getProp(this.map, path);
		}
		if (upstream) {
			if (!space)
				utils.setProp(this.map, path, {
					_upstreams: [fn]
				});
			else
				(space._upstreams = space._upstreams || []).push(fn);
		} else if (!space)
			utils.setProp(this.map, path, {
				_listeners: [fn]
			});
		else
			(space._listeners = space._listeners || []).push(fn);
		if (binds)
			binds.push(unsub(this, path, fn, upstream));
		return this;
	}