desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'IMAPrev1 extension THREAD command. (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)'
def thread(self, threading_algorithm, charset, *search_criteria):
name = 'THREAD' (typ, dat) = self._simple_command(name, threading_algorithm, charset, *search_criteria) return self._untagged_response(typ, dat, name)
'Execute "command arg ..." with messages identified by UID, rather than message number. (typ, [data]) = <instance>.uid(command, arg1, arg2, ...) Returns response appropriate to \'command\'.'
def uid(self, command, *args):
command = command.upper() if (not (command in Commands)): raise self.error(('Unknown IMAP4 UID command: %s' % command)) if (self.state not in Commands[command]): raise self.error(('command %s illegal in state %s, only allowed in states %s' % (command...
'Unsubscribe from old mailbox. (typ, [data]) = <instance>.unsubscribe(mailbox)'
def unsubscribe(self, mailbox):
return self._simple_command('UNSUBSCRIBE', mailbox)
'Allow simple extension commands notified by server in CAPABILITY response. Assumes command is legal in current state. (typ, [data]) = <instance>.xatom(name, arg, ...) Returns response appropriate to extension command `name\'.'
def xatom(self, name, *args):
name = name.upper() if (not (name in Commands)): Commands[name] = (self.state,) return self._simple_command(name, *args)
'Setup a stream connection. This connection will be used by the routines: read, readline, send, shutdown.'
def open(self, host=None, port=None):
self.host = None self.port = None self.sock = None self.file = None self.process = subprocess.Popen(self.command, bufsize=DEFAULT_BUFFER_SIZE, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, close_fds=True) self.writefile = self.process.stdin self.readfile = self.process.stdout
'Read \'size\' bytes from remote.'
def read(self, size):
return self.readfile.read(size)
'Read line from remote.'
def readline(self):
return self.readfile.readline()
'Send data to remote.'
def send(self, data):
self.writefile.write(data) self.writefile.flush()
'Close I/O established in "open".'
def shutdown(self):
self.readfile.close() self.writefile.close() self.process.wait()
'Close the temporary file, possibly deleting it.'
def close(self):
self._closer.close()
'Instantiate a line-oriented interpreter framework. The optional argument \'completekey\' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alter...
def __init__(self, completekey='tab', stdin=None, stdout=None):
if (stdin is not None): self.stdin = stdin else: self.stdin = sys.stdin if (stdout is not None): self.stdout = stdout else: self.stdout = sys.stdout self.cmdqueue = [] self.completekey = completekey
'Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.'
def cmdloop(self, intro=None):
self.preloop() if (self.use_rawinput and self.completekey): try: import readline self.old_completer = readline.get_completer() readline.set_completer(self.complete) readline.parse_and_bind((self.completekey + ': complete')) except ImportError: ...
'Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued.'
def precmd(self, line):
return line
'Hook method executed just after a command dispatch is finished.'
def postcmd(self, stop, line):
return stop
'Hook method executed once when the cmdloop() method is called.'
def preloop(self):
pass
'Hook method executed once when the cmdloop() method is about to return.'
def postloop(self):
pass
'Parse the line into a command name and a string containing the arguments. Returns a tuple containing (command, args, line). \'command\' and \'args\' may be None if the line couldn\'t be parsed.'
def parseline(self, line):
line = line.strip() if (not line): return (None, None, line) elif (line[0] == '?'): line = ('help ' + line[1:]) elif (line[0] == '!'): if hasattr(self, 'do_shell'): line = ('shell ' + line[1:]) else: return (None, None, line) (i, n) = (0,...
'Interpret the argument as though it had been typed in response to the prompt. This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation of commands by the interpreter should stop.'
def onecmd(self, line):
(cmd, arg, line) = self.parseline(line) if (not line): return self.emptyline() if (cmd is None): return self.default(line) self.lastcmd = line if (line == 'EOF'): self.lastcmd = '' if (cmd == ''): return self.default(line) else: try: func =...
'Called when an empty line is entered in response to the prompt. If this method is not overridden, it repeats the last nonempty command entered.'
def emptyline(self):
if self.lastcmd: return self.onecmd(self.lastcmd)
'Called on an input line when the command prefix is not recognized. If this method is not overridden, it prints an error message and returns.'
def default(self, line):
self.stdout.write(('*** Unknown syntax: %s\n' % line))
'Method called to complete an input line when no command-specific complete_*() method is available. By default, it returns an empty list.'
def completedefault(self, *ignored):
return []
'Return the next possible completion for \'text\'. If a command has not been entered, then complete against command list. Otherwise try to call complete_<command> to get list of completions.'
def complete(self, text, state):
if (state == 0): import readline origline = readline.get_line_buffer() line = origline.lstrip() stripped = (len(origline) - len(line)) begidx = (readline.get_begidx() - stripped) endidx = (readline.get_endidx() - stripped) if (begidx > 0): (cmd, ar...
'List available commands with "help" or detailed help with "help cmd".'
def do_help(self, arg):
if arg: try: func = getattr(self, ('help_' + arg)) except AttributeError: try: doc = getattr(self, ('do_' + arg)).__doc__ if doc: self.stdout.write(('%s\n' % str(doc))) return except Attribute...
'Display a list of strings as a compact set of columns. Each column is only as wide as necessary. Columns are separated by two spaces (one was not legible enough).'
def columnize(self, list, displaywidth=80):
if (not list): self.stdout.write('<empty>\n') return nonstrings = [i for i in range(len(list)) if (not isinstance(list[i], str))] if nonstrings: raise TypeError(('list[i] not a string for i in %s' % ', '.join(map(str, nonstrings)))) size = len(list) if...
'safe: bytes object.'
def __init__(self, safe):
self.safe = _ALWAYS_SAFE.union(safe)
'Returns the time the robots.txt file was last fetched. This is useful for long-running web spiders that need to check for new robots.txt files periodically.'
def mtime(self):
return self.last_checked
'Sets the time the robots.txt file was last fetched to the current time.'
def modified(self):
import time self.last_checked = time.time()
'Sets the URL referring to a robots.txt file.'
def set_url(self, url):
self.url = url (self.host, self.path) = urllib.parse.urlparse(url)[1:3]
'Reads the robots.txt URL and feeds it to the parser.'
def read(self):
try: f = urllib.request.urlopen(self.url) except urllib.error.HTTPError as err: if (err.code in (401, 403)): self.disallow_all = True elif ((err.code >= 400) and (err.code < 500)): self.allow_all = True else: raw = f.read() self.parse(raw.decod...
'Parse the input lines from a robots.txt file. We allow that a user-agent: line is not preceded by one or more blank lines.'
def parse(self, lines):
state = 0 entry = Entry() self.modified() for line in lines: if (not line): if (state == 1): entry = Entry() state = 0 elif (state == 2): self._add_entry(entry) entry = Entry() state = 0 ...
'using the parsed robots.txt decide if useragent can fetch url'
def can_fetch(self, useragent, url):
if self.disallow_all: return False if self.allow_all: return True if (not self.last_checked): return False parsed_url = urllib.parse.urlparse(urllib.parse.unquote(url)) url = urllib.parse.urlunparse(('', '', parsed_url.path, parsed_url.params, parsed_url.query, parsed_url.fra...
'check if this entry applies to the specified agent'
def applies_to(self, useragent):
useragent = useragent.split('/')[0].lower() for agent in self.useragents: if (agent == '*'): return True agent = agent.lower() if (agent in useragent): return True return False
'Preconditions: - our agent applies to this entry - filename is URL decoded'
def allowance(self, filename):
for line in self.rulelines: if line.applies_to(filename): return line.allowance return True
'Initializes a new ThreadPoolExecutor instance. Args: max_workers: The maximum number of threads that can be used to execute the given calls.'
def __init__(self, max_workers):
self._max_workers = max_workers self._work_queue = queue.Queue() self._threads = set() self._shutdown = False self._shutdown_lock = threading.Lock()
'Initializes a new ProcessPoolExecutor instance. Args: max_workers: The maximum number of processes that can be used to execute the given calls. If None or not given then as many worker processes will be created as the machine has processors.'
def __init__(self, max_workers=None):
_check_system_limits() if (max_workers is None): self._max_workers = (os.cpu_count() or 1) else: self._max_workers = max_workers self._call_queue = multiprocessing.Queue((self._max_workers + EXTRA_QUEUED_CALLS)) self._call_queue._ignore_epipe = True self._result_queue = SimpleQue...
'Initialize an ordered dictionary. The signature is the same as regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary.'
def __init__(self, *args, **kwds):
if (len(args) > 1): raise TypeError(('expected at most 1 arguments, got %d' % len(args))) try: self.__root except AttributeError: self.__hardroot = _Link() self.__root = root = _proxy(self.__hardroot) root.prev = root.next = root self.__map =...
'od.__setitem__(i, y) <==> od[i]=y'
def __setitem__(self, key, value, dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link):
if (key not in self): self.__map[key] = link = Link() root = self.__root last = root.prev (link.prev, link.next, link.key) = (last, root, key) last.next = link root.prev = proxy(link) dict_setitem(self, key, value)
'od.__delitem__(y) <==> del od[y]'
def __delitem__(self, key, dict_delitem=dict.__delitem__):
dict_delitem(self, key) link = self.__map.pop(key) link_prev = link.prev link_next = link.next link_prev.next = link_next link_next.prev = link_prev
'od.__iter__() <==> iter(od)'
def __iter__(self):
root = self.__root curr = root.next while (curr is not root): (yield curr.key) curr = curr.next
'od.__reversed__() <==> reversed(od)'
def __reversed__(self):
root = self.__root curr = root.prev while (curr is not root): (yield curr.key) curr = curr.prev
'od.clear() -> None. Remove all items from od.'
def clear(self):
root = self.__root root.prev = root.next = root self.__map.clear() dict.clear(self)
'od.popitem() -> (k, v), return and remove a (key, value) pair. Pairs are returned in LIFO order if last is true or FIFO order if false.'
def popitem(self, last=True):
if (not self): raise KeyError('dictionary is empty') root = self.__root if last: link = root.prev link_prev = link.prev link_prev.next = root root.prev = link_prev else: link = root.next link_next = link.next root.next = link_next ...
'Move an existing element to the end (or beginning if last==False). Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key).'
def move_to_end(self, key, last=True):
link = self.__map[key] link_prev = link.prev link_next = link.next link_prev.next = link_next link_next.prev = link_prev root = self.__root if last: last = root.prev link.prev = last link.next = root last.next = root.prev = link else: first = root....
'od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.'
def pop(self, key, default=__marker):
if (key in self): result = self[key] del self[key] return result if (default is self.__marker): raise KeyError(key) return default
'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
def setdefault(self, key, default=None):
if (key in self): return self[key] self[key] = default return default
'od.__repr__() <==> repr(od)'
@_recursive_repr() def __repr__(self):
if (not self): return ('%s()' % (self.__class__.__name__,)) return ('%s(%r)' % (self.__class__.__name__, list(self.items())))
'Return state information for pickling'
def __reduce__(self):
inst_dict = vars(self).copy() for k in vars(OrderedDict()): inst_dict.pop(k, None) return (self.__class__, (), (inst_dict or None), None, iter(self.items()))
'od.copy() -> a shallow copy of od'
def copy(self):
return self.__class__(self)
'OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S. If not specified, the value defaults to None.'
@classmethod def fromkeys(cls, iterable, value=None):
self = cls() for key in iterable: self[key] = value return self
'od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive.'
def __eq__(self, other):
if isinstance(other, OrderedDict): return (dict.__eq__(self, other) and all(map(_eq, self, other))) return dict.__eq__(self, other)
'Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter(\'gallahad\') # a new counter from an iterable >>> c =...
def __init__(self, iterable=None, **kwds):
super().__init__() self.update(iterable, **kwds)
'The count of elements not in the Counter is zero.'
def __missing__(self, key):
return 0
'List the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter(\'abcdeabcdabcaba\').most_common(3) [(\'a\', 5), (\'b\', 4), (\'c\', 3)]'
def most_common(self, n=None):
if (n is None): return sorted(self.items(), key=_itemgetter(1), reverse=True) return _heapq.nlargest(n, self.items(), key=_itemgetter(1))
'Iterator over elements repeating each as many times as its count. >>> c = Counter(\'ABCABC\') >>> sorted(c.elements()) [\'A\', \'A\', \'B\', \'B\', \'C\', \'C\'] # Knuth\'s example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> product = 1 >>> for factor in prime_f...
def elements(self):
return _chain.from_iterable(_starmap(_repeat, self.items()))
'Like dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter(\'which\') >>> c.update(\'witch\') # add elements from another iterable >>> d = Counter(\'watch\') >>> c.update(d) # add elements from another cou...
def update(self, iterable=None, **kwds):
if (iterable is not None): if isinstance(iterable, Mapping): if self: self_get = self.get for (elem, count) in iterable.items(): self[elem] = (count + self_get(elem, 0)) else: super().update(iterable) else: ...
'Like dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter(\'which\') >>> c.subtract(\'witch\') # sub...
def subtract(self, iterable=None, **kwds):
if (iterable is not None): self_get = self.get if isinstance(iterable, Mapping): for (elem, count) in iterable.items(): self[elem] = (self_get(elem, 0) - count) else: for elem in iterable: self[elem] = (self_get(elem, 0) - 1) if kwd...
'Return a shallow copy.'
def copy(self):
return self.__class__(self)
'Like dict.__delitem__() but does not raise KeyError for missing values.'
def __delitem__(self, elem):
if (elem in self): super().__delitem__(elem)
'Add counts from two counters. >>> Counter(\'abbb\') + Counter(\'bcc\') Counter({\'b\': 4, \'c\': 2, \'a\': 1})'
def __add__(self, other):
if (not isinstance(other, Counter)): return NotImplemented result = Counter() for (elem, count) in self.items(): newcount = (count + other[elem]) if (newcount > 0): result[elem] = newcount for (elem, count) in other.items(): if ((elem not in self) and (count >...
'Subtract count, but keep only results with positive counts. >>> Counter(\'abbbc\') - Counter(\'bccd\') Counter({\'b\': 2, \'a\': 1})'
def __sub__(self, other):
if (not isinstance(other, Counter)): return NotImplemented result = Counter() for (elem, count) in self.items(): newcount = (count - other[elem]) if (newcount > 0): result[elem] = newcount for (elem, count) in other.items(): if ((elem not in self) and (count <...
'Union is the maximum of value in either of the input counters. >>> Counter(\'abbb\') | Counter(\'bcc\') Counter({\'b\': 3, \'c\': 2, \'a\': 1})'
def __or__(self, other):
if (not isinstance(other, Counter)): return NotImplemented result = Counter() for (elem, count) in self.items(): other_count = other[elem] newcount = (other_count if (count < other_count) else count) if (newcount > 0): result[elem] = newcount for (elem, count)...
'Intersection is the minimum of corresponding counts. >>> Counter(\'abbb\') & Counter(\'bcc\') Counter({\'b\': 1})'
def __and__(self, other):
if (not isinstance(other, Counter)): return NotImplemented result = Counter() for (elem, count) in self.items(): other_count = other[elem] newcount = (count if (count < other_count) else other_count) if (newcount > 0): result[elem] = newcount return result
'Adds an empty counter, effectively stripping negative and zero counts'
def __pos__(self):
return (self + Counter())
'Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts.'
def __neg__(self):
return (Counter() - self)
'Internal method to strip elements with a negative or zero count'
def _keep_positive(self):
nonpositive = [elem for (elem, count) in self.items() if (not (count > 0))] for elem in nonpositive: del self[elem] return self
'Inplace add from another counter, keeping only positive counts. >>> c = Counter(\'abbb\') >>> c += Counter(\'bcc\') >>> c Counter({\'b\': 4, \'c\': 2, \'a\': 1})'
def __iadd__(self, other):
for (elem, count) in other.items(): self[elem] += count return self._keep_positive()
'Inplace subtract counter, but keep only results with positive counts. >>> c = Counter(\'abbbc\') >>> c -= Counter(\'bccd\') >>> c Counter({\'b\': 2, \'a\': 1})'
def __isub__(self, other):
for (elem, count) in other.items(): self[elem] -= count return self._keep_positive()
'Inplace union is the maximum of value from either counter. >>> c = Counter(\'abbb\') >>> c |= Counter(\'bcc\') >>> c Counter({\'b\': 3, \'c\': 2, \'a\': 1})'
def __ior__(self, other):
for (elem, other_count) in other.items(): count = self[elem] if (other_count > count): self[elem] = other_count return self._keep_positive()
'Inplace intersection is the minimum of corresponding counts. >>> c = Counter(\'abbb\') >>> c &= Counter(\'bcc\') >>> c Counter({\'b\': 1})'
def __iand__(self, other):
for (elem, count) in self.items(): other_count = other[elem] if (other_count < count): self[elem] = other_count return self._keep_positive()
'Initialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used.'
def __init__(self, *maps):
self.maps = (list(maps) or [{}])
'Create a ChainMap with a single dict created from the iterable.'
@classmethod def fromkeys(cls, iterable, *args):
return cls(dict.fromkeys(iterable, *args))
'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]'
def copy(self):
return self.__class__(self.maps[0].copy(), *self.maps[1:])
'New ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used.'
def new_child(self, m=None):
if (m is None): m = {} return self.__class__(m, *self.maps)
'New ChainMap from maps[1:].'
@property def parents(self):
return self.__class__(*self.maps[1:])
'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.'
def popitem(self):
try: return self.maps[0].popitem() except KeyError: raise KeyError('No keys found in the first mapping.')
'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].'
def pop(self, key, *args):
try: return self.maps[0].pop(key, *args) except KeyError: raise KeyError('Key not found in the first mapping: {!r}'.format(key))
'Clear maps[0], leaving maps[1:] intact.'
def clear(self):
self.maps[0].clear()
'Send user name, return response (should indicate password required).'
def user(self, user):
return self._shortcmd(('USER %s' % user))
'Send password, return response (response includes message count, mailbox size). NB: mailbox is locked by server from here to \'quit()\''
def pass_(self, pswd):
return self._shortcmd(('PASS %s' % pswd))
'Get mailbox status. Result is tuple of 2 ints (message count, mailbox size)'
def stat(self):
retval = self._shortcmd('STAT') rets = retval.split() if self._debugging: print ('*stat*', repr(rets)) numMessages = int(rets[1]) sizeMessages = int(rets[2]) return (numMessages, sizeMessages)
'Request listing, return result. Result without a message number argument is in form [\'response\', [\'mesg_num octets\', ...], octets]. Result when a message number argument is given is a single response: the "scan listing" for that message.'
def list(self, which=None):
if (which is not None): return self._shortcmd(('LIST %s' % which)) return self._longcmd('LIST')
'Retrieve whole message number \'which\'. Result is in form [\'response\', [\'line\', ...], octets].'
def retr(self, which):
return self._longcmd(('RETR %s' % which))
'Delete message number \'which\'. Result is \'response\'.'
def dele(self, which):
return self._shortcmd(('DELE %s' % which))
'Does nothing. One supposes the response indicates the server is alive.'
def noop(self):
return self._shortcmd('NOOP')
'Unmark all messages marked for deletion.'
def rset(self):
return self._shortcmd('RSET')
'Signoff: commit changes on server, unlock mailbox, close connection.'
def quit(self):
resp = self._shortcmd('QUIT') self.close() return resp
'Close the connection without assuming anything about it.'
def close(self):
if (self.file is not None): self.file.close() if (self.sock is not None): try: self.sock.shutdown(socket.SHUT_RDWR) except OSError as e: if (e.errno != errno.ENOTCONN): raise finally: self.sock.close() self.file = self.sock ...
'Not sure what this does.'
def rpop(self, user):
return self._shortcmd(('RPOP %s' % user))
'Authorisation - only possible if server has supplied a timestamp in initial greeting. Args: user - mailbox user; password - mailbox password. NB: mailbox is locked by server from here to \'quit()\''
def apop(self, user, password):
secret = bytes(password, self.encoding) m = self.timestamp.match(self.welcome) if (not m): raise error_proto('-ERR APOP not supported by server') import hashlib digest = (m.group(1) + secret) digest = hashlib.md5(digest).hexdigest() return self._shortcmd(('APOP %s ...
'Retrieve message header of message number \'which\' and first \'howmuch\' lines of message body. Result is in form [\'response\', [\'line\', ...], octets].'
def top(self, which, howmuch):
return self._longcmd(('TOP %s %s' % (which, howmuch)))
'Return message digest (unique id) list. If \'which\', result contains unique id for that message in the form \'response mesgnum uid\', otherwise result is the list [\'response\', [\'mesgnum uid\', ...], octets]'
def uidl(self, which=None):
if (which is not None): return self._shortcmd(('UIDL %s' % which)) return self._longcmd('UIDL')
'Return server capabilities (RFC 2449) as a dictionary >>> c=poplib.POP3(\'localhost\') >>> c.capa() {\'IMPLEMENTATION\': [\'Cyrus\', \'POP3\', \'server\', \'v2.2.12\'], \'TOP\': [], \'LOGIN-DELAY\': [\'0\'], \'AUTH-RESP-CODE\': [], \'EXPIRE\': [\'NEVER\'], \'USER\': [], \'STLS\': [], \'PIPELINING\': [], \'UIDL\': [], ...
def capa(self):
def _parsecap(line): lst = line.decode('ascii').split() return (lst[0], lst[1:]) caps = {} try: resp = self._longcmd('CAPA') rawcaps = resp[1] for capline in rawcaps: (capnm, capargs) = _parsecap(capline) caps[capnm] = capargs except error_...
'Start a TLS session on the active connection as specified in RFC 2595. context - a ssl.SSLContext'
def stls(self, context=None):
if (not HAVE_SSL): raise error_proto('-ERR TLS support missing') if self._tls_established: raise error_proto('-ERR TLS session already established') caps = self.capa() if (not ('STLS' in caps)): raise error_proto('-ERR STLS not supported by ser...
'Set the input delimiter. Can be a fixed string of any length, an integer, or None.'
def set_terminator(self, term):
if (isinstance(term, str) and self.use_encoding): term = bytes(term, self.encoding) elif (isinstance(term, int) and (term < 0)): raise ValueError('the number of received bytes must be positive') self.terminator = term
'predicate for inclusion in the readable for select()'
def readable(self):
return 1
'predicate for inclusion in the writable for select()'
def writable(self):
return (self.producer_fifo or (not self.connected))
'automatically close this channel once the outgoing queue is empty'
def close_when_done(self):
self.producer_fifo.append(None)
'Logs deprecation message which is log level WARN if the ``removal_version`` is > 1 minor release away and log level ERROR otherwise. removal_version should be the version that the deprecated feature is expected to be removed in, so something that will not exist in version 1.7, but will in 1.6 would have a removal_vers...
def deprecated(self, removal_version, msg, *args, **kwargs):
from pip import __version__ if should_warn(__version__, removal_version): self.warn(msg, *args, **kwargs) else: self.error(msg, *args, **kwargs)
'Should we display download progress?'
def _show_progress(self):
return (self.stdout_level_matches(self.NOTIFY) and sys.stdout.isatty())
'If we are in a progress scope, and no log messages have been shown, write out another \'.\''
def show_progress(self, message=None):
if self.in_progress_hanging: if (message is None): sys.stdout.write('.') sys.stdout.flush() else: if self.last_message: padding = (' ' * max(0, (len(self.last_message) - len(message)))) else: padding = '' ...