code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def unhex(s):
"""Get the integer value of a hexadecimal number."""
bits = 0
for c in s:
if '0' <= c <= '9':
i = ord('0')
elif 'a' <= c <= 'f':
i = ord('a')-10
elif 'A' <= c <= 'F':
i = ord('A')-10
else:
break
bits = bits... | Get the integer value of a hexadecimal number. | unhex | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/quopri.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/quopri.py | MIT |
def __init__(self, x=None):
"""Initialize an instance.
Optional argument x controls seeding, as for Random.seed().
"""
self.seed(x)
self.gauss_next = None | Initialize an instance.
Optional argument x controls seeding, as for Random.seed().
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def seed(self, a=None):
"""Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If a is not None or an int or long, hash(a) is used instead.
"""
if a is None:
... | Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If a is not None or an int or long, hash(a) is used instead.
| seed | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def setstate(self, state):
"""Restore internal state from object returned by getstate()."""
version = state[0]
if version == 3:
version, internalstate, self.gauss_next = state
super(Random, self).setstate(internalstate)
elif version == 2:
version, inte... | Restore internal state from object returned by getstate(). | setstate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def jumpahead(self, n):
"""Change the internal state to one that is likely far away
from the current state. This method will not be in Py3.x,
so it is better to simply reseed.
"""
# The super.jumpahead() method uses shuffling to change state,
# so it needs a large and "i... | Change the internal state to one that is likely far away
from the current state. This method will not be in Py3.x,
so it is better to simply reseed.
| jumpahead | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def randrange(self, start, stop=None, step=1, _int=int, _maxwidth=1L<<BPF):
"""Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
"""
# This code is a bit messy t... | Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
| randrange | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def _randbelow(self, n, _log=_log, _int=int, _maxwidth=1L<<BPF,
_Method=_MethodType, _BuiltinMethod=_BuiltinMethodType):
"""Return a random int in the range [0,n)
Handles the case where n has more bits than returned
by a single call to the underlying generator.
"""
... | Return a random int in the range [0,n)
Handles the case where n has more bits than returned
by a single call to the underlying generator.
| _randbelow | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def shuffle(self, x, random=None):
"""x, random=random.random -> shuffle list x in place; return None.
Optional arg random is a 0-argument function returning a random
float in [0.0, 1.0); by default, the standard random.random.
"""
if random is None:
random = self.... | x, random=random.random -> shuffle list x in place; return None.
Optional arg random is a 0-argument function returning a random
float in [0.0, 1.0); by default, the standard random.random.
| shuffle | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def sample(self, population, k):
"""Chooses k unique random elements from a population sequence.
Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
in selection order so that all sub-slices will also be vali... | Chooses k unique random elements from a population sequence.
Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
in selection order so that all sub-slices will also be valid random
samples. This allows raffl... | sample | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def uniform(self, a, b):
"Get a random number in the range [a, b) or [a, b] depending on rounding."
return a + (b-a) * self.random() | Get a random number in the range [a, b) or [a, b] depending on rounding. | uniform | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def normalvariate(self, mu, sigma):
"""Normal distribution.
mu is the mean, and sigma is the standard deviation.
"""
# mu = mean, sigma = standard deviation
# Uses Kinderman and Monahan method. Reference: Kinderman,
# A.J. and Monahan, J.F., "Computer generation of ran... | Normal distribution.
mu is the mean, and sigma is the standard deviation.
| normalvariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def expovariate(self, lambd):
"""Exponential distribution.
lambd is 1.0 divided by the desired mean. It should be
nonzero. (The parameter would be called "lambda", but that is
a reserved word in Python.) Returned values range from 0 to
positive infinity if lambd is positive, ... | Exponential distribution.
lambd is 1.0 divided by the desired mean. It should be
nonzero. (The parameter would be called "lambda", but that is
a reserved word in Python.) Returned values range from 0 to
positive infinity if lambd is positive, and from negative
infinity to 0 i... | expovariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def vonmisesvariate(self, mu, kappa):
"""Circular data distribution.
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a u... | Circular data distribution.
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a uniform random angle over the range 0 to 2*pi.
... | vonmisesvariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def gammavariate(self, alpha, beta):
"""Gamma distribution. Not the gamma function!
Conditions on the parameters are alpha > 0 and beta > 0.
The probability distribution function is:
x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) = ------------------------------... | Gamma distribution. Not the gamma function!
Conditions on the parameters are alpha > 0 and beta > 0.
The probability distribution function is:
x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) = --------------------------------------
math.gamma(alpha)... | gammavariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def gauss(self, mu, sigma):
"""Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normalvariate() function.
Not thread-safe without a lock around calls.
"""
# When x and y are two variables from [0, 1), unifor... | Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normalvariate() function.
Not thread-safe without a lock around calls.
| gauss | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def betavariate(self, alpha, beta):
"""Beta distribution.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.
"""
# This version due to Janne Sinkkonen, and matches all the std
# texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta... | Beta distribution.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.
| betavariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def paretovariate(self, alpha):
"""Pareto distribution. alpha is the shape parameter."""
# Jain, pg. 495
u = 1.0 - self.random()
return 1.0 / pow(u, 1.0/alpha) | Pareto distribution. alpha is the shape parameter. | paretovariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def weibullvariate(self, alpha, beta):
"""Weibull distribution.
alpha is the scale parameter and beta is the shape parameter.
"""
# Jain, pg. 499; bug fix courtesy Bill Arms
u = 1.0 - self.random()
return alpha * pow(-_log(u), 1.0/beta) | Weibull distribution.
alpha is the scale parameter and beta is the shape parameter.
| weibullvariate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def seed(self, a=None):
"""Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If a is not None or an int or long, hash(a) is used instead.
If a is an int or long, a is... | Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If a is not None or an int or long, hash(a) is used instead.
If a is an int or long, a is used directly. Distinct values be... | seed | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def random(self):
"""Get the next random number in the range [0.0, 1.0)."""
# Wichman-Hill random number generator.
#
# Wichmann, B. A. & Hill, I. D. (1982)
# Algorithm AS 183:
# An efficient and portable pseudo-random number generator
# Applied Statistics 31 (19... | Get the next random number in the range [0.0, 1.0). | random | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def setstate(self, state):
"""Restore internal state from object returned by getstate()."""
version = state[0]
if version == 1:
version, self._seed, self.gauss_next = state
else:
raise ValueError("state with version %s passed to "
"Ran... | Restore internal state from object returned by getstate(). | setstate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def jumpahead(self, n):
"""Act as if n calls to random() were made, but quickly.
n is an int, greater than or equal to 0.
Example use: If you have 2 threads and know that each will
consume no more than a million random numbers, create two Random
objects r1 and r2, then do
... | Act as if n calls to random() were made, but quickly.
n is an int, greater than or equal to 0.
Example use: If you have 2 threads and know that each will
consume no more than a million random numbers, create two Random
objects r1 and r2, then do
r2.setstate(r1.getstate())
... | jumpahead | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def __whseed(self, x=0, y=0, z=0):
"""Set the Wichmann-Hill seed from (x, y, z).
These must be integers in the range [0, 256).
"""
if not type(x) == type(y) == type(z) == int:
raise TypeError('seeds must be integers')
if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z... | Set the Wichmann-Hill seed from (x, y, z).
These must be integers in the range [0, 256).
| __whseed | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def whseed(self, a=None):
"""Seed from hashable object's hash code.
None or no argument seeds from current time. It is not guaranteed
that objects with distinct hash codes lead to distinct internal
states.
This is obsolete, provided for compatibility with the seed routine
... | Seed from hashable object's hash code.
None or no argument seeds from current time. It is not guaranteed
that objects with distinct hash codes lead to distinct internal
states.
This is obsolete, provided for compatibility with the seed routine
used prior to Python 2.1. Use th... | whseed | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def getrandbits(self, k):
"""getrandbits(k) -> x. Generates a long int with k random bits."""
if k <= 0:
raise ValueError('number of bits must be greater than zero')
if k != int(k):
raise TypeError('number of bits should be an integer')
bytes = (k + 7) // 8 ... | getrandbits(k) -> x. Generates a long int with k random bits. | getrandbits | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def _notimplemented(self, *args, **kwds):
"Method should not be called for a system random number generator."
raise NotImplementedError('System entropy source does not have state.') | Method should not be called for a system random number generator. | _notimplemented | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/random.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/random.py | MIT |
def compile(pattern, flags=0):
"Compile a regular expression pattern, returning a pattern object."
return _compile(pattern, flags) | Compile a regular expression pattern, returning a pattern object. | compile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/re.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/re.py | MIT |
def template(pattern, flags=0):
"Compile a template pattern, returning a pattern object"
return _compile(pattern, flags|T) | Compile a template pattern, returning a pattern object | template | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/re.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/re.py | MIT |
def escape(pattern):
"Escape all non-alphanumeric characters in pattern."
s = list(pattern)
alphanum = _alphanum
for i, c in enumerate(pattern):
if c not in alphanum:
if c == "\000":
s[i] = "\\000"
else:
s[i] = "\\" + c
return pattern[:... | Escape all non-alphanumeric characters in pattern. | escape | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/re.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/re.py | MIT |
def r_exec(self, code):
"""Execute code within a restricted environment.
The code parameter must either be a string containing one or more
lines of Python code, or a compiled code object, which will be
executed in the restricted environment's __main__ module.
"""
m = se... | Execute code within a restricted environment.
The code parameter must either be a string containing one or more
lines of Python code, or a compiled code object, which will be
executed in the restricted environment's __main__ module.
| r_exec | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rexec.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rexec.py | MIT |
def r_eval(self, code):
"""Evaluate code within a restricted environment.
The code parameter must either be a string containing a Python
expression, or a compiled code object, which will be evaluated in
the restricted environment's __main__ module. The value of the
expression o... | Evaluate code within a restricted environment.
The code parameter must either be a string containing a Python
expression, or a compiled code object, which will be evaluated in
the restricted environment's __main__ module. The value of the
expression or code object will be returned.
... | r_eval | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rexec.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rexec.py | MIT |
def r_open(self, file, mode='r', buf=-1):
"""Method called when open() is called in the restricted environment.
The arguments are identical to those of the open() function, and a
file object (or a class instance compatible with file objects)
should be returned. RExec's default behaviou... | Method called when open() is called in the restricted environment.
The arguments are identical to those of the open() function, and a
file object (or a class instance compatible with file objects)
should be returned. RExec's default behaviour is allow opening
any file for reading, but ... | r_open | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rexec.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rexec.py | MIT |
def __init__(self, fp, seekable = 1):
"""Initialize the class instance and read the headers."""
if seekable == 1:
# Exercise tell() to make sure it works
# (and then assume seek() works, too)
try:
fp.tell()
except (AttributeError, IOError):... | Initialize the class instance and read the headers. | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def rewindbody(self):
"""Rewind the file to the start of the body (if seekable)."""
if not self.seekable:
raise IOError, "unseekable file"
self.fp.seek(self.startofbody) | Rewind the file to the start of the body (if seekable). | rewindbody | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def readheaders(self):
"""Read header lines.
Read header lines up to the entirely blank line that terminates them.
The (normally blank) line that ends the headers is skipped, but not
included in the returned list. If a non-header line ends the headers,
(which is an error), an a... | Read header lines.
Read header lines up to the entirely blank line that terminates them.
The (normally blank) line that ends the headers is skipped, but not
included in the returned list. If a non-header line ends the headers,
(which is an error), an attempt is made to backspace over i... | readheaders | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def isheader(self, line):
"""Determine whether a given line is a legal header.
This method should return the header name, suitably canonicalized.
You may override this method in order to use Message parsing on tagged
data in RFC 2822-like formats with special header formats.
"""... | Determine whether a given line is a legal header.
This method should return the header name, suitably canonicalized.
You may override this method in order to use Message parsing on tagged
data in RFC 2822-like formats with special header formats.
| isheader | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getallmatchingheaders(self, name):
"""Find all header lines matching a given header name.
Look through the list of headers and find all lines matching a given
header name (and their continuation lines). A list of the lines is
returned, without interpretation. If the header does no... | Find all header lines matching a given header name.
Look through the list of headers and find all lines matching a given
header name (and their continuation lines). A list of the lines is
returned, without interpretation. If the header does not occur, an
empty list is returned. If th... | getallmatchingheaders | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getfirstmatchingheader(self, name):
"""Get the first header line matching name.
This is similar to getallmatchingheaders, but it returns only the
first matching header (and its continuation lines).
"""
name = name.lower() + ':'
n = len(name)
lst = []
... | Get the first header line matching name.
This is similar to getallmatchingheaders, but it returns only the
first matching header (and its continuation lines).
| getfirstmatchingheader | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getrawheader(self, name):
"""A higher-level interface to getfirstmatchingheader().
Return a string containing the literal text of the header but with the
keyword stripped. All leading, trailing and embedded whitespace is
kept in the string, however. Return None if the header does ... | A higher-level interface to getfirstmatchingheader().
Return a string containing the literal text of the header but with the
keyword stripped. All leading, trailing and embedded whitespace is
kept in the string, however. Return None if the header does not
occur.
| getrawheader | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getheaders(self, name):
"""Get all values for a header.
This returns a list of values for headers given more than once; each
value in the result list is stripped in the same way as the result of
getheader(). If the header is not given, return an empty list.
"""
resu... | Get all values for a header.
This returns a list of values for headers given more than once; each
value in the result list is stripped in the same way as the result of
getheader(). If the header is not given, return an empty list.
| getheaders | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getaddr(self, name):
"""Get a single address from a header, as a tuple.
An example return value:
('Guido van Rossum', 'guido@cwi.nl')
"""
# New, by Ben Escoto
alist = self.getaddrlist(name)
if alist:
return alist[0]
else:
retur... | Get a single address from a header, as a tuple.
An example return value:
('Guido van Rossum', 'guido@cwi.nl')
| getaddr | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getaddrlist(self, name):
"""Get a list of addresses from a header.
Retrieves a list of addresses from a header, where each address is a
tuple as returned by getaddr(). Scans all named headers, so it works
properly with multiple To: or Cc: headers for example.
"""
ra... | Get a list of addresses from a header.
Retrieves a list of addresses from a header, where each address is a
tuple as returned by getaddr(). Scans all named headers, so it works
properly with multiple To: or Cc: headers for example.
| getaddrlist | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getdate(self, name):
"""Retrieve a date field from a header.
Retrieves a date field from the named header, returning a tuple
compatible with time.mktime().
"""
try:
data = self[name]
except KeyError:
return None
return parsedate(data) | Retrieve a date field from a header.
Retrieves a date field from the named header, returning a tuple
compatible with time.mktime().
| getdate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getdate_tz(self, name):
"""Retrieve a date field from a header as a 10-tuple.
The first 9 elements make up a tuple compatible with time.mktime(),
and the 10th is the offset of the poster's time zone from GMT/UTC.
"""
try:
data = self[name]
except KeyError... | Retrieve a date field from a header as a 10-tuple.
The first 9 elements make up a tuple compatible with time.mktime(),
and the 10th is the offset of the poster's time zone from GMT/UTC.
| getdate_tz | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def __setitem__(self, name, value):
"""Set the value of a header.
Note: This is not a perfect inversion of __getitem__, because any
changed headers get stuck at the end of the raw-headers list rather
than where the altered header was.
"""
del self[name] # Won't fail if i... | Set the value of a header.
Note: This is not a perfect inversion of __getitem__, because any
changed headers get stuck at the end of the raw-headers list rather
than where the altered header was.
| __setitem__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def __delitem__(self, name):
"""Delete all occurrences of a specific header, if it is present."""
name = name.lower()
if not name in self.dict:
return
del self.dict[name]
name = name + ':'
n = len(name)
lst = []
hit = 0
for i in range(l... | Delete all occurrences of a specific header, if it is present. | __delitem__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def parseaddr(address):
"""Parse an address into a (realname, mailaddr) tuple."""
a = AddressList(address)
lst = a.addresslist
if not lst:
return (None, None)
return lst[0] | Parse an address into a (realname, mailaddr) tuple. | parseaddr | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def __init__(self, field):
"""Initialize a new instance.
`field' is an unparsed address header field, containing one or more
addresses.
"""
self.specials = '()<>@,:;.\"[]'
self.pos = 0
self.LWS = ' \t'
self.CR = '\r\n'
self.atomends = self.special... | Initialize a new instance.
`field' is an unparsed address header field, containing one or more
addresses.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def gotonext(self):
"""Parse up to the start of the next address."""
while self.pos < len(self.field):
if self.field[self.pos] in self.LWS + '\n\r':
self.pos = self.pos + 1
elif self.field[self.pos] == '(':
self.commentlist.append(self.getcomment()... | Parse up to the start of the next address. | gotonext | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getaddrlist(self):
"""Parse all addresses.
Returns a list containing all of the addresses.
"""
result = []
ad = self.getaddress()
while ad:
result += ad
ad = self.getaddress()
return result | Parse all addresses.
Returns a list containing all of the addresses.
| getaddrlist | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getrouteaddr(self):
"""Parse a route address (Return-path value).
This method just skips all the route stuff and returns the addrspec.
"""
if self.field[self.pos] != '<':
return
expectroute = 0
self.pos += 1
self.gotonext()
adlist = ""
... | Parse a route address (Return-path value).
This method just skips all the route stuff and returns the addrspec.
| getrouteaddr | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getdomain(self):
"""Get the complete domain name from an address."""
sdlist = []
while self.pos < len(self.field):
if self.field[self.pos] in self.LWS:
self.pos += 1
elif self.field[self.pos] == '(':
self.commentlist.append(self.getcomm... | Get the complete domain name from an address. | getdomain | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def getphraselist(self):
"""Parse a sequence of RFC 2822 phrases.
A phrase is a sequence of words, which are in turn either RFC 2822
atoms or quoted-strings. Phrases are canonicalized by squeezing all
runs of continuous whitespace into one space.
"""
plist = []
... | Parse a sequence of RFC 2822 phrases.
A phrase is a sequence of words, which are in turn either RFC 2822
atoms or quoted-strings. Phrases are canonicalized by squeezing all
runs of continuous whitespace into one space.
| getphraselist | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def dump_address_pair(pair):
"""Dump a (name, address) pair in a canonicalized form."""
if pair[0]:
return '"' + pair[0] + '" <' + pair[1] + '>'
else:
return pair[1] | Dump a (name, address) pair in a canonicalized form. | dump_address_pair | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def parsedate_tz(data):
"""Convert a date string to a time tuple.
Accounts for military timezones.
"""
if not data:
return None
data = data.split()
if data[0][-1] in (',', '.') or data[0].lower() in _daynames:
# There's a dayname here. Skip it
del data[0]
else:
... | Convert a date string to a time tuple.
Accounts for military timezones.
| parsedate_tz | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def parsedate(data):
"""Convert a time string to a time tuple."""
t = parsedate_tz(data)
if t is None:
return t
return t[:9] | Convert a time string to a time tuple. | parsedate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def mktime_tz(data):
"""Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp."""
if data[9] is None:
# No zone info, so localtime is better assumption than GMT
return time.mktime(data[:8] + (-1,))
else:
t = time.mktime(data[:8] + (0,))
return t - data[9] - time.... | Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp. | mktime_tz | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def formatdate(timeval=None):
"""Returns time format preferred for Internet standards.
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
According to RFC 1123, day and month names must always be in
English. If not for that, this code could use strftime(). It
can't because strftime() ... | Returns time format preferred for Internet standards.
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
According to RFC 1123, day and month names must always be in
English. If not for that, this code could use strftime(). It
can't because strftime() honors the locale and could generate
... | formatdate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rfc822.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rfc822.py | MIT |
def __init__(self, namespace = None):
"""Create a new completer for the command line.
Completer([namespace]) -> completer instance.
If unspecified, the default namespace where completions are performed
is __main__ (technically, __main__.__dict__). Namespaces should be
given as ... | Create a new completer for the command line.
Completer([namespace]) -> completer instance.
If unspecified, the default namespace where completions are performed
is __main__ (technically, __main__.__dict__). Namespaces should be
given as dictionaries.
Completer instances should... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rlcompleter.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rlcompleter.py | MIT |
def complete(self, text, state):
"""Return the next possible completion for 'text'.
This is called successively with state == 0, 1, 2, ... until it
returns None. The completion should begin with 'text'.
"""
if self.use_main_ns:
self.namespace = __main__.__dict__
... | Return the next possible completion for 'text'.
This is called successively with state == 0, 1, 2, ... until it
returns None. The completion should begin with 'text'.
| complete | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rlcompleter.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rlcompleter.py | MIT |
def global_matches(self, text):
"""Compute matches when text is a simple name.
Return a list of all keywords, built-in functions and names currently
defined in self.namespace that match.
"""
import keyword
matches = []
seen = {"__builtins__"}
n = len(tex... | Compute matches when text is a simple name.
Return a list of all keywords, built-in functions and names currently
defined in self.namespace that match.
| global_matches | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rlcompleter.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rlcompleter.py | MIT |
def attr_matches(self, text):
"""Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions. (For class
insta... | Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions. (For class
instances, class members are also considered.)... | attr_matches | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/rlcompleter.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/rlcompleter.py | MIT |
def modified(self):
"""Sets the time the robots.txt file was last fetched to the
current time.
"""
import time
self.last_checked = time.time() | Sets the time the robots.txt file was last fetched to the
current time.
| modified | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def set_url(self, url):
"""Sets the URL referring to a robots.txt file."""
self.url = url
self.host, self.path = urlparse.urlparse(url)[1:3] | Sets the URL referring to a robots.txt file. | set_url | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def read(self):
"""Reads the robots.txt URL and feeds it to the parser."""
opener = URLopener()
f = opener.open(self.url)
lines = [line.strip() for line in f]
f.close()
self.errcode = opener.errcode
if self.errcode in (401, 403):
self.disallow_all = Tr... | Reads the robots.txt URL and feeds it to the parser. | read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def parse(self, lines):
"""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."""
# states:
# 0: start state
# 1: saw user-agent line
# 2: saw an allow or disallow line
stat... | 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. | parse | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def can_fetch(self, useragent, url):
"""using the parsed robots.txt decide if useragent can fetch url"""
if self.disallow_all:
return False
if self.allow_all:
return True
# Until the robots.txt file has been read or found not
# to exist, we must assume th... | using the parsed robots.txt decide if useragent can fetch url | can_fetch | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def applies_to(self, useragent):
"""check if this entry applies to the specified agent"""
# split the name token and make it lower case
useragent = useragent.split("/")[0].lower()
for agent in self.useragents:
if agent == '*':
# we have the catch-all agent
... | check if this entry applies to the specified agent | applies_to | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def allowance(self, filename):
"""Preconditions:
- our agent applies to this entry
- filename is URL decoded"""
for line in self.rulelines:
if line.applies_to(filename):
return line.allowance
return True | Preconditions:
- our agent applies to this entry
- filename is URL decoded | allowance | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/robotparser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/robotparser.py | MIT |
def _run_code(code, run_globals, init_globals=None,
mod_name=None, mod_fname=None,
mod_loader=None, pkg_name=None):
"""Helper to run code in nominated namespace"""
if init_globals is not None:
run_globals.update(init_globals)
run_globals.update(__name__ = mod_name,
... | Helper to run code in nominated namespace | _run_code | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/runpy.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/runpy.py | MIT |
def _run_module_code(code, init_globals=None,
mod_name=None, mod_fname=None,
mod_loader=None, pkg_name=None):
"""Helper to run code in new namespace with sys modified"""
with _TempModule(mod_name) as temp_module, _ModifiedArgv0(mod_fname):
mod_globals = temp_modul... | Helper to run code in new namespace with sys modified | _run_module_code | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/runpy.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/runpy.py | MIT |
def _run_module_as_main(mod_name, alter_argv=True):
"""Runs the designated module in the __main__ namespace
Note that the executed module will have full access to the
__main__ namespace. If this is not desirable, the run_module()
function should be used to run the module code in a fresh namesp... | Runs the designated module in the __main__ namespace
Note that the executed module will have full access to the
__main__ namespace. If this is not desirable, the run_module()
function should be used to run the module code in a fresh namespace.
At the very least, these variables in __main__... | _run_module_as_main | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/runpy.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/runpy.py | MIT |
def run_module(mod_name, init_globals=None,
run_name=None, alter_sys=False):
"""Execute a module's code without importing it
Returns the resulting top level namespace dictionary
"""
mod_name, loader, code, fname = _get_module_details(mod_name)
if run_name is None:
run_name... | Execute a module's code without importing it
Returns the resulting top level namespace dictionary
| run_module | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/runpy.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/runpy.py | MIT |
def run_path(path_name, init_globals=None, run_name=None):
"""Execute code located at the specified filesystem location
Returns the resulting top level namespace dictionary
The file path may refer directly to a Python script (i.e.
one that could be directly executed with execfile) or else
... | Execute code located at the specified filesystem location
Returns the resulting top level namespace dictionary
The file path may refer directly to a Python script (i.e.
one that could be directly executed with execfile) or else
it may refer to a zipfile or directory containing a top
... | run_path | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/runpy.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/runpy.py | MIT |
def __init__(self, timefunc, delayfunc):
"""Initialize a new instance, passing the time and delay
functions"""
self._queue = []
self.timefunc = timefunc
self.delayfunc = delayfunc | Initialize a new instance, passing the time and delay
functions | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sched.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sched.py | MIT |
def enterabs(self, time, priority, action, argument):
"""Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
"""
event = Event(time, priority, action, argument)
heapq.heappush(self._queue, event)
... | Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
| enterabs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sched.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sched.py | MIT |
def enter(self, delay, priority, action, argument):
"""A variant that specifies the time as a relative time.
This is actually the more commonly used interface.
"""
time = self.timefunc() + delay
return self.enterabs(time, priority, action, argument) | A variant that specifies the time as a relative time.
This is actually the more commonly used interface.
| enter | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sched.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sched.py | MIT |
def run(self):
"""Execute events until the queue is empty.
When there is a positive delay until the first event, the
delay function is called and the event is left in the queue;
otherwise, the event is removed from the queue and executed
(its action function is called, passing i... | Execute events until the queue is empty.
When there is a positive delay until the first event, the
delay function is called and the event is left in the queue;
otherwise, the event is removed from the queue and executed
(its action function is called, passing it the argument). If
... | run | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sched.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sched.py | MIT |
def queue(self):
"""An ordered list of upcoming events.
Events are named tuples with fields for:
time, priority, action, arguments
"""
# Use heapq to sort the queue rather than using 'sorted(self._queue)'.
# With heapq, two events scheduled at the same time will sho... | An ordered list of upcoming events.
Events are named tuples with fields for:
time, priority, action, arguments
| queue | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sched.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sched.py | MIT |
def __deepcopy__(self, memo):
"""Return a deep copy of a set; used by copy module."""
# This pre-creates the result and inserts it in the memo
# early, in case the deep copy recurses into another reference
# to this same set. A set can't be an element of itself, but
# it can cer... | Return a deep copy of a set; used by copy module. | __deepcopy__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __or__(self, other):
"""Return the union of two sets as a new set.
(I.e. all elements that are in either set.)
"""
if not isinstance(other, BaseSet):
return NotImplemented
return self.union(other) | Return the union of two sets as a new set.
(I.e. all elements that are in either set.)
| __or__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def union(self, other):
"""Return the union of two sets as a new set.
(I.e. all elements that are in either set.)
"""
result = self.__class__(self)
result._update(other)
return result | Return the union of two sets as a new set.
(I.e. all elements that are in either set.)
| union | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __and__(self, other):
"""Return the intersection of two sets as a new set.
(I.e. all elements that are in both sets.)
"""
if not isinstance(other, BaseSet):
return NotImplemented
return self.intersection(other) | Return the intersection of two sets as a new set.
(I.e. all elements that are in both sets.)
| __and__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def intersection(self, other):
"""Return the intersection of two sets as a new set.
(I.e. all elements that are in both sets.)
"""
if not isinstance(other, BaseSet):
other = Set(other)
if len(self) <= len(other):
little, big = self, other
else:
... | Return the intersection of two sets as a new set.
(I.e. all elements that are in both sets.)
| intersection | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __xor__(self, other):
"""Return the symmetric difference of two sets as a new set.
(I.e. all elements that are in exactly one of the sets.)
"""
if not isinstance(other, BaseSet):
return NotImplemented
return self.symmetric_difference(other) | Return the symmetric difference of two sets as a new set.
(I.e. all elements that are in exactly one of the sets.)
| __xor__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def symmetric_difference(self, other):
"""Return the symmetric difference of two sets as a new set.
(I.e. all elements that are in exactly one of the sets.)
"""
result = self.__class__()
data = result._data
value = True
selfdata = self._data
try:
... | Return the symmetric difference of two sets as a new set.
(I.e. all elements that are in exactly one of the sets.)
| symmetric_difference | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __sub__(self, other):
"""Return the difference of two sets as a new Set.
(I.e. all elements that are in this set and not in the other.)
"""
if not isinstance(other, BaseSet):
return NotImplemented
return self.difference(other) | Return the difference of two sets as a new Set.
(I.e. all elements that are in this set and not in the other.)
| __sub__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def difference(self, other):
"""Return the difference of two sets as a new Set.
(I.e. all elements that are in this set and not in the other.)
"""
result = self.__class__()
data = result._data
try:
otherdata = other._data
except AttributeError:
... | Return the difference of two sets as a new Set.
(I.e. all elements that are in this set and not in the other.)
| difference | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __contains__(self, element):
"""Report whether an element is a member of a set.
(Called in response to the expression `element in self'.)
"""
try:
return element in self._data
except TypeError:
transform = getattr(element, "__as_temporarily_immutable_... | Report whether an element is a member of a set.
(Called in response to the expression `element in self'.)
| __contains__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def issubset(self, other):
"""Report whether another set contains this set."""
self._binary_sanity_check(other)
if len(self) > len(other): # Fast check for obvious cases
return False
for elt in ifilterfalse(other._data.__contains__, self):
return False
re... | Report whether another set contains this set. | issubset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def issuperset(self, other):
"""Report whether this set contains another set."""
self._binary_sanity_check(other)
if len(self) < len(other): # Fast check for obvious cases
return False
for elt in ifilterfalse(self._data.__contains__, other):
return False
... | Report whether this set contains another set. | issuperset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __init__(self, iterable=None):
"""Construct an immutable set from an optional iterable."""
self._hashcode = None
self._data = {}
if iterable is not None:
self._update(iterable) | Construct an immutable set from an optional iterable. | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __init__(self, iterable=None):
"""Construct a set from an optional iterable."""
self._data = {}
if iterable is not None:
self._update(iterable) | Construct a set from an optional iterable. | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __ior__(self, other):
"""Update a set with the union of itself and another."""
self._binary_sanity_check(other)
self._data.update(other._data)
return self | Update a set with the union of itself and another. | __ior__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __iand__(self, other):
"""Update a set with the intersection of itself and another."""
self._binary_sanity_check(other)
self._data = (self & other)._data
return self | Update a set with the intersection of itself and another. | __iand__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def intersection_update(self, other):
"""Update a set with the intersection of itself and another."""
if isinstance(other, BaseSet):
self &= other
else:
self._data = (self.intersection(other))._data | Update a set with the intersection of itself and another. | intersection_update | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __ixor__(self, other):
"""Update a set with the symmetric difference of itself and another."""
self._binary_sanity_check(other)
self.symmetric_difference_update(other)
return self | Update a set with the symmetric difference of itself and another. | __ixor__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def symmetric_difference_update(self, other):
"""Update a set with the symmetric difference of itself and another."""
data = self._data
value = True
if not isinstance(other, BaseSet):
other = Set(other)
if self is other:
self.clear()
for elt in oth... | Update a set with the symmetric difference of itself and another. | symmetric_difference_update | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def __isub__(self, other):
"""Remove all elements of another set from this set."""
self._binary_sanity_check(other)
self.difference_update(other)
return self | Remove all elements of another set from this set. | __isub__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
def difference_update(self, other):
"""Remove all elements of another set from this set."""
data = self._data
if not isinstance(other, BaseSet):
other = Set(other)
if self is other:
self.clear()
for elt in ifilter(data.__contains__, other):
del... | Remove all elements of another set from this set. | difference_update | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sets.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sets.py | MIT |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.