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 __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | Inherit all other methods from the underlying stream.
| __getattr__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __init__(self, stream, errors='strict'):
""" Creates a StreamReader instance.
stream must be a file-like object open for reading
(binary) data.
The StreamReader may use different error handling
schemes by providing the errors keyword argument. These
... | Creates a StreamReader instance.
stream must be a file-like object open for reading
(binary) data.
The StreamReader may use different error handling
schemes by providing the errors keyword argument. These
parameters are predefined:
'strict' - ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def read(self, size=-1, chars=-1, firstline=False):
""" Decodes data from the stream self.stream and returns the
resulting object.
chars indicates the number of characters to read from the
stream. read() will never return more than chars
characters, but it might... | Decodes data from the stream self.stream and returns the
resulting object.
chars indicates the number of characters to read from the
stream. read() will never return more than chars
characters, but it might return less, if there are not enough
characters ava... | read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def readline(self, size=None, keepends=True):
""" Read one line from the input stream and return the
decoded data.
size, if given, is passed as size argument to the
read() method.
"""
# If we have lines cached from an earlier read, return
# them unc... | Read one line from the input stream and return the
decoded data.
size, if given, is passed as size argument to the
read() method.
| readline | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def reset(self):
""" Resets the codec buffers used for keeping state.
Note that no stream repositioning should take place.
This method is primarily intended to be able to recover
from decoding errors.
"""
self.bytebuffer = ""
self.charbuffer = u""
... | Resets the codec buffers used for keeping state.
Note that no stream repositioning should take place.
This method is primarily intended to be able to recover
from decoding errors.
| reset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def next(self):
""" Return the next decoded line from the input stream."""
line = self.readline()
if line:
return line
raise StopIteration | Return the next decoded line from the input stream. | next | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | Inherit all other methods from the underlying stream.
| __getattr__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __init__(self, stream, Reader, Writer, errors='strict'):
""" Creates a StreamReaderWriter instance.
stream must be a Stream-like object.
Reader, Writer must be factory functions or classes
providing the StreamReader, StreamWriter interface resp.
Error hand... | Creates a StreamReaderWriter instance.
stream must be a Stream-like object.
Reader, Writer must be factory functions or classes
providing the StreamReader, StreamWriter interface resp.
Error handling is done in the same way as defined for the
StreamWriter/... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | Inherit all other methods from the underlying stream.
| __getattr__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __init__(self, stream, encode, decode, Reader, Writer,
errors='strict'):
""" Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
input to .read() and output of .write()) while
Reader and Wri... | Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
input to .read() and output of .write()) while
Reader and Writer work on the backend (reading and
writing to the stream).
You can use these ob... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def next(self):
""" Return the next decoded line from the input stream."""
data = self.reader.next()
data, bytesencoded = self.encode(data, self.errors)
return data | Return the next decoded line from the input stream. | next | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | Inherit all other methods from the underlying stream.
| __getattr__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):
""" Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding.
Note: The wrapped version will only accept the object format
defined by the codecs, i.e. Unicode o... | Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding.
Note: The wrapped version will only accept the object format
defined by the codecs, i.e. Unicode objects for most builtin
codecs. Output is also codec dependent and will usua... | open | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
""" Return a wrapped version of file which provides transparent
encoding translation.
Strings written to the wrapped file are interpreted according
to the given data_encoding and then written to the original
... | Return a wrapped version of file which provides transparent
encoding translation.
Strings written to the wrapped file are interpreted according
to the given data_encoding and then written to the original
file as string using file_encoding. The intermediate encoding
will usually... | EncodedFile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def getincrementalencoder(encoding):
""" Lookup up the codec for the given encoding and return
its IncrementalEncoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental encoder.
"""
encoder = lookup(enc... | Lookup up the codec for the given encoding and return
its IncrementalEncoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental encoder.
| getincrementalencoder | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def getincrementaldecoder(encoding):
""" Lookup up the codec for the given encoding and return
its IncrementalDecoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental decoder.
"""
decoder = lookup(enc... | Lookup up the codec for the given encoding and return
its IncrementalDecoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental decoder.
| getincrementaldecoder | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def iterencode(iterator, encoding, errors='strict', **kwargs):
"""
Encoding iterator.
Encodes the input strings from the iterator using a IncrementalEncoder.
errors and kwargs are passed through to the IncrementalEncoder
constructor.
"""
encoder = getincrementalencoder(encoding)(errors, **... |
Encoding iterator.
Encodes the input strings from the iterator using a IncrementalEncoder.
errors and kwargs are passed through to the IncrementalEncoder
constructor.
| iterencode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def iterdecode(iterator, encoding, errors='strict', **kwargs):
"""
Decoding iterator.
Decodes the input strings from the iterator using a IncrementalDecoder.
errors and kwargs are passed through to the IncrementalDecoder
constructor.
"""
decoder = getincrementaldecoder(encoding)(errors, **... |
Decoding iterator.
Decodes the input strings from the iterator using a IncrementalDecoder.
errors and kwargs are passed through to the IncrementalDecoder
constructor.
| iterdecode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def make_identity_dict(rng):
""" make_identity_dict(rng) -> dict
Return a dictionary where elements of the rng sequence are
mapped to themselves.
"""
res = {}
for i in rng:
res[i]=i
return res | make_identity_dict(rng) -> dict
Return a dictionary where elements of the rng sequence are
mapped to themselves.
| make_identity_dict | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def make_encoding_map(decoding_map):
""" Creates an encoding map from a decoding map.
If a target mapping in the decoding map occurs multiple
times, then that target is mapped to None (undefined mapping),
causing an exception when encountered by the charmap codec
during translation... | Creates an encoding map from a decoding map.
If a target mapping in the decoding map occurs multiple
times, then that target is mapped to None (undefined mapping),
causing an exception when encountered by the charmap codec
during translation.
One example where this happens is ... | make_encoding_map | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __init__(*args, **kwds):
'''Initialize an ordered dictionary. The signature is the same as
regular dictionaries, but keyword arguments are not recommended because
their insertion order is arbitrary.
'''
if not args:
raise TypeError("descriptor '__init__' of 'Ord... | Initialize an ordered dictionary. The signature is the same as
regular dictionaries, but keyword arguments are not recommended because
their insertion order is arbitrary.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def clear(self):
'od.clear() -> None. Remove all items from od.'
root = self.__root
root[:] = [root, root, None]
self.__map.clear()
dict.clear(self) | od.clear() -> None. Remove all items from od. | clear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def values(self):
'od.values() -> list of values in od'
return [self[key] for key in self] | od.values() -> list of values in od | values | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def items(self):
'od.items() -> list of (key, value) pairs in od'
return [(key, self[key]) for key in self] | od.items() -> list of (key, value) pairs in od | items | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def itervalues(self):
'od.itervalues -> an iterator over the values in od'
for k in self:
yield self[k] | od.itervalues -> an iterator over the values in od | itervalues | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def iteritems(self):
'od.iteritems -> an iterator over the (key, value) pairs in od'
for k in self:
yield (k, self[k]) | od.iteritems -> an iterator over the (key, value) pairs in od | iteritems | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def pop(self, key, default=__marker):
'''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.
'''
if key in self:
result = self[key]
del self[key]
... | 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.
| pop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def setdefault(self, key, default=None):
'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
if key in self:
return self[key]
self[key] = default
return default | od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od | setdefault | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def popitem(self, last=True):
'''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.
'''
if not self:
raise KeyError('dictionary is empty')
key = next(reversed(self) if last else iter... | 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.
| popitem | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def fromkeys(cls, iterable, value=None):
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
If not specified, the value defaults to None.
'''
self = cls()
for key in iterable:
self[key] = value
return self | OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
If not specified, the value defaults to None.
| fromkeys | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __eq__(self, other):
'''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.
'''
if isinstance(other, OrderedDict):
return dict.__eq__(self, other) and all(_imap(_eq, self, other))
retur... | od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.
| __eq__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def namedtuple(typename, field_names, verbose=False, rename=False):
"""Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate wit... | Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # ind... | namedtuple | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __init__(*args, **kwds):
'''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 = Counte... | 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 co... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __missing__(self, key):
'The count of elements not in the Counter is zero.'
# Needed so that self[missing_item] does not raise KeyError
return 0 | The count of elements not in the Counter is zero. | __missing__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def most_common(self, n=None):
'''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)]
'''
# Emulate Bag.sortedByCoun... | 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)]
| most_common | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def elements(self):
'''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... | 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})
>>> pro... | elements | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def update(*args, **kwds):
'''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'... | 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) ... | update | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def subtract(*args, **kwds):
'''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.
... | 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')
>>> ... | subtract | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __delitem__(self, elem):
'Like dict.__delitem__() but does not raise KeyError for missing values.'
if elem in self:
super(Counter, self).__delitem__(elem) | Like dict.__delitem__() but does not raise KeyError for missing values. | __delitem__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __add__(self, other):
'''Add counts from two counters.
>>> Counter('abbb') + Counter('bcc')
Counter({'b': 4, 'c': 2, 'a': 1})
'''
if not isinstance(other, Counter):
return NotImplemented
result = Counter()
for elem, count in self.items():
... | Add counts from two counters.
>>> Counter('abbb') + Counter('bcc')
Counter({'b': 4, 'c': 2, 'a': 1})
| __add__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __sub__(self, other):
''' Subtract count, but keep only results with positive counts.
>>> Counter('abbbc') - Counter('bccd')
Counter({'b': 2, 'a': 1})
'''
if not isinstance(other, Counter):
return NotImplemented
result = Counter()
for elem, count... | Subtract count, but keep only results with positive counts.
>>> Counter('abbbc') - Counter('bccd')
Counter({'b': 2, 'a': 1})
| __sub__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __or__(self, other):
'''Union is the maximum of value in either of the input counters.
>>> Counter('abbb') | Counter('bcc')
Counter({'b': 3, 'c': 2, 'a': 1})
'''
if not isinstance(other, Counter):
return NotImplemented
result = Counter()
for elem... | Union is the maximum of value in either of the input counters.
>>> Counter('abbb') | Counter('bcc')
Counter({'b': 3, 'c': 2, 'a': 1})
| __or__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def __and__(self, other):
''' Intersection is the minimum of corresponding counts.
>>> Counter('abbb') & Counter('bcc')
Counter({'b': 1})
'''
if not isinstance(other, Counter):
return NotImplemented
result = Counter()
for elem, count in self.items():... | Intersection is the minimum of corresponding counts.
>>> Counter('abbb') & Counter('bcc')
Counter({'b': 1})
| __and__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/collections.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/collections.py | MIT |
def getstatus(file):
"""Return output of "ls -ld <file>" in a string."""
import warnings
warnings.warn("commands.getstatus() is deprecated", DeprecationWarning, 2)
return getoutput('ls -ld' + mkarg(file)) | Return output of "ls -ld <file>" in a string. | getstatus | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/commands.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/commands.py | MIT |
def getstatusoutput(cmd):
"""Return (status, output) of executing cmd in a shell."""
import os
pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
text = pipe.read()
sts = pipe.close()
if sts is None: sts = 0
if text[-1:] == '\n': text = text[:-1]
return sts, text | Return (status, output) of executing cmd in a shell. | getstatusoutput | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/commands.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/commands.py | MIT |
def compile_dir(dir, maxlevels=10, ddir=None,
force=0, rx=None, quiet=0):
"""Byte-compile all modules in the given directory tree.
Arguments (only dir is required):
dir: the directory to byte-compile
maxlevels: maximum recursion level (default 10)
ddir: the directory tha... | Byte-compile all modules in the given directory tree.
Arguments (only dir is required):
dir: the directory to byte-compile
maxlevels: maximum recursion level (default 10)
ddir: the directory that will be prepended to the path to the
file as it is compiled into each byte-code ... | compile_dir | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compileall.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compileall.py | MIT |
def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
"""Byte-compile one file.
Arguments (only fullname is required):
fullname: the file to byte-compile
ddir: if given, the directory name compiled in to the
byte-code file.
force: if 1, force compilation, even ... | Byte-compile one file.
Arguments (only fullname is required):
fullname: the file to byte-compile
ddir: if given, the directory name compiled in to the
byte-code file.
force: if 1, force compilation, even if timestamps are up-to-date
quiet: if 1, be quiet during compila... | compile_file | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compileall.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compileall.py | MIT |
def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
"""Byte-compile all module on sys.path.
Arguments (all optional):
skip_curdir: if true, skip current directory (default true)
maxlevels: max recursion level (default 0)
force: as for compile_dir() (default 0)
quiet: as for compi... | Byte-compile all module on sys.path.
Arguments (all optional):
skip_curdir: if true, skip current directory (default true)
maxlevels: max recursion level (default 0)
force: as for compile_dir() (default 0)
quiet: as for compile_dir() (default 0)
| compile_path | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compileall.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compileall.py | MIT |
def expand_args(args, flist):
"""read names in flist and append to args"""
expanded = args[:]
if flist:
try:
if flist == '-':
fd = sys.stdin
else:
fd = open(flist)
while 1:
line = fd.readline()
if not... | read names in flist and append to args | expand_args | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compileall.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compileall.py | MIT |
def add_section(self, section):
"""Create a new section in the configuration.
Raise DuplicateSectionError if a section by the specified name
already exists. Raise ValueError if name is DEFAULT or any of it's
case-insensitive variants.
"""
if section.lower() == "default":... | Create a new section in the configuration.
Raise DuplicateSectionError if a section by the specified name
already exists. Raise ValueError if name is DEFAULT or any of it's
case-insensitive variants.
| add_section | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def options(self, section):
"""Return a list of option names for the given section name."""
try:
opts = self._sections[section].copy()
except KeyError:
raise NoSectionError(section)
opts.update(self._defaults)
if '__name__' in opts:
del opts['_... | Return a list of option names for the given section name. | options | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def read(self, filenames):
"""Read and parse a filename or a list of filenames.
Files that cannot be opened are silently ignored; this is
designed so that you can specify a list of potential
configuration file locations (e.g. current directory, user's
home directory, systemwide ... | Read and parse a filename or a list of filenames.
Files that cannot be opened are silently ignored; this is
designed so that you can specify a list of potential
configuration file locations (e.g. current directory, user's
home directory, systemwide directory), and all existing
c... | read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def readfp(self, fp, filename=None):
"""Like read() but the argument must be a file-like object.
The `fp' argument must have a `readline' method. Optional
second argument is the `filename', which if not given, is
taken from fp.name. If fp has no `name' attribute, `<???>' is
us... | Like read() but the argument must be a file-like object.
The `fp' argument must have a `readline' method. Optional
second argument is the `filename', which if not given, is
taken from fp.name. If fp has no `name' attribute, `<???>' is
used.
| readfp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def has_option(self, section, option):
"""Check for the existence of a given option in a given section."""
if not section or section == DEFAULTSECT:
option = self.optionxform(option)
return option in self._defaults
elif section not in self._sections:
return Fa... | Check for the existence of a given option in a given section. | has_option | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def write(self, fp):
"""Write an .ini-format representation of the configuration state."""
if self._defaults:
fp.write("[%s]\n" % DEFAULTSECT)
for (key, value) in self._defaults.items():
fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
f... | Write an .ini-format representation of the configuration state. | write | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def _read(self, fp, fpname):
"""Parse a sectioned setup file.
The sections in setup file contains a title line at the top,
indicated by a name in square brackets (`[]'), plus key/value
options lines, indicated by `name: value' format lines.
Continuations are represented by an em... | Parse a sectioned setup file.
The sections in setup file contains a title line at the top,
indicated by a name in square brackets (`[]'), plus key/value
options lines, indicated by `name: value' format lines.
Continuations are represented by an embedded newline then
leading whit... | _read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def get(self, section, option, raw=False, vars=None):
"""Get an option value for a given section.
If `vars' is provided, it must be a dictionary. The option is looked up
in `vars' (if provided), `section', and in `defaults' in that order.
All % interpolations are expanded in the return... | Get an option value for a given section.
If `vars' is provided, it must be a dictionary. The option is looked up
in `vars' (if provided), `section', and in `defaults' in that order.
All % interpolations are expanded in the return values, unless the
optional argument `raw' is true. Valu... | get | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def items(self, section, raw=False, vars=None):
"""Return a list of tuples with (name, value) for each option
in the section.
All % interpolations are expanded in the return values, based on the
defaults passed into the constructor, unless the optional argument
`raw' is true. A... | Return a list of tuples with (name, value) for each option
in the section.
All % interpolations are expanded in the return values, based on the
defaults passed into the constructor, unless the optional argument
`raw' is true. Additional substitutions may be provided using the
`... | items | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def set(self, section, option, value=None):
"""Set an option. Extend ConfigParser.set: check for string values."""
# The only legal non-string value if we allow valueless
# options is None, so we need to check if the value is a
# string if:
# - we do not allow valueless options,... | Set an option. Extend ConfigParser.set: check for string values. | set | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ConfigParser.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ConfigParser.py | MIT |
def contextmanager(func):
"""@contextmanager decorator.
Typical usage:
@contextmanager
def some_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
This makes this:
with some_generator(<argument... | @contextmanager decorator.
Typical usage:
@contextmanager
def some_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
This makes this:
with some_generator(<arguments>) as <variable>:
<b... | contextmanager | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/contextlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/contextlib.py | MIT |
def nested(*managers):
"""Combine multiple context managers into a single nested context manager.
This function has been deprecated in favour of the multiple manager form
of the with statement.
The one advantage of this function over the multiple manager form of the
with statement is that argument unp... | Combine multiple context managers into a single nested context manager.
This function has been deprecated in favour of the multiple manager form
of the with statement.
The one advantage of this function over the multiple manager form of the
with statement is that argument unpacking allows it to be
used... | nested | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/contextlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/contextlib.py | MIT |
def value_encode(self, val):
"""real_value, coded_value = value_encode(VALUE)
Called prior to setting a cookie's value from the dictionary
representation. The VALUE is the value being assigned.
Override this function to modify the behavior of cookies.
"""
strval = str(va... | real_value, coded_value = value_encode(VALUE)
Called prior to setting a cookie's value from the dictionary
representation. The VALUE is the value being assigned.
Override this function to modify the behavior of cookies.
| value_encode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Cookie.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Cookie.py | MIT |
def __set(self, key, real_value, coded_value):
"""Private method for setting a cookie's value"""
M = self.get(key, Morsel())
M.set(key, real_value, coded_value)
dict.__setitem__(self, key, M) | Private method for setting a cookie's value | __set | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Cookie.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Cookie.py | MIT |
def load(self, rawdata):
"""Load cookies from a string (presumably HTTP_COOKIE) or
from a dictionary. Loading cookies from a dictionary 'd'
is equivalent to calling:
map(Cookie.__setitem__, d.keys(), d.values())
"""
if type(rawdata) == type(""):
self.__Pa... | Load cookies from a string (presumably HTTP_COOKIE) or
from a dictionary. Loading cookies from a dictionary 'd'
is equivalent to calling:
map(Cookie.__setitem__, d.keys(), d.values())
| load | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Cookie.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Cookie.py | MIT |
def time2isoz(t=None):
"""Return a string representing time in seconds since epoch, t.
If the function is called without an argument, it will use the current
time.
The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
representing Universal Time (UTC, aka GMT). An example of this form... | Return a string representing time in seconds since epoch, t.
If the function is called without an argument, it will use the current
time.
The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
representing Universal Time (UTC, aka GMT). An example of this format is:
1994-11-24 08:49:3... | time2isoz | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def time2netscape(t=None):
"""Return a string representing time in seconds since epoch, t.
If the function is called without an argument, it will use the current
time.
The format of the returned string is like this:
Wed, DD-Mon-YYYY HH:MM:SS GMT
"""
if t is None: t = time.time()
year... | Return a string representing time in seconds since epoch, t.
If the function is called without an argument, it will use the current
time.
The format of the returned string is like this:
Wed, DD-Mon-YYYY HH:MM:SS GMT
| time2netscape | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def http2time(text):
"""Returns time in seconds since epoch of time represented by a string.
Return value is an integer.
None is returned if the format of str is unrecognized, the time is outside
the representable range, or the timezone string is not recognized. If the
string contains no timezone... | Returns time in seconds since epoch of time represented by a string.
Return value is an integer.
None is returned if the format of str is unrecognized, the time is outside
the representable range, or the timezone string is not recognized. If the
string contains no timezone, UTC is assumed.
The t... | http2time | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def iso2time(text):
"""
As for http2time, but parses the ISO 8601 formats:
1994-02-03 14:15:29 -0100 -- ISO 8601 format
1994-02-03 14:15:29 -- zone is optional
1994-02-03 -- only date
1994-02-03T14:15:29 -- Use T as separator
19940203T141529Z ... |
As for http2time, but parses the ISO 8601 formats:
1994-02-03 14:15:29 -0100 -- ISO 8601 format
1994-02-03 14:15:29 -- zone is optional
1994-02-03 -- only date
1994-02-03T14:15:29 -- Use T as separator
19940203T141529Z -- ISO 8601 compact form... | iso2time | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def split_header_words(header_values):
r"""Parse header values into a list of lists containing key,value pairs.
The function knows how to deal with ",", ";" and "=" as well as quoted
values after "=". A list of space separated tokens are parsed as if they
were separated by ";".
If the header_valu... | Parse header values into a list of lists containing key,value pairs.
The function knows how to deal with ",", ";" and "=" as well as quoted
values after "=". A list of space separated tokens are parsed as if they
were separated by ";".
If the header_values passed as argument contains multiple values,... | split_header_words | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def join_header_words(lists):
"""Do the inverse (almost) of the conversion done by split_header_words.
Takes a list of lists of (key, value) pairs and produces a single header
value. Attribute values are quoted if needed.
>>> join_header_words([[("text/plain", None), ("charset", "iso-8859/1")]])
... | Do the inverse (almost) of the conversion done by split_header_words.
Takes a list of lists of (key, value) pairs and produces a single header
value. Attribute values are quoted if needed.
>>> join_header_words([[("text/plain", None), ("charset", "iso-8859/1")]])
'text/plain; charset="iso-8859/1"'
... | join_header_words | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def parse_ns_headers(ns_headers):
"""Ad-hoc parser for Netscape protocol cookie-attributes.
The old Netscape cookie format for Set-Cookie can for instance contain
an unquoted "," in the expires field, so we have to use this ad-hoc
parser instead of split_header_words.
XXX This may not make the bes... | Ad-hoc parser for Netscape protocol cookie-attributes.
The old Netscape cookie format for Set-Cookie can for instance contain
an unquoted "," in the expires field, so we have to use this ad-hoc
parser instead of split_header_words.
XXX This may not make the best possible effort to parse all the crap
... | parse_ns_headers | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def is_HDN(text):
"""Return True if text is a host domain name."""
# XXX
# This may well be wrong. Which RFC is HDN defined in, if any (for
# the purposes of RFC 2965)?
# For the current implementation, what about IPv6? Remember to look
# at other uses of IPV4_RE also, if change this.
if... | Return True if text is a host domain name. | is_HDN | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def domain_match(A, B):
"""Return True if domain A domain-matches domain B, according to RFC 2965.
A and B may be host domain names or IP addresses.
RFC 2965, section 1:
Host names can be specified either as an IP address or a HDN string.
Sometimes we compare one host name with another. (Such co... | Return True if domain A domain-matches domain B, according to RFC 2965.
A and B may be host domain names or IP addresses.
RFC 2965, section 1:
Host names can be specified either as an IP address or a HDN string.
Sometimes we compare one host name with another. (Such comparisons SHALL
be case-ins... | domain_match | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def liberal_is_HDN(text):
"""Return True if text is a sort-of-like a host domain name.
For accepting/blocking domains.
"""
if IPV4_RE.search(text):
return False
return True | Return True if text is a sort-of-like a host domain name.
For accepting/blocking domains.
| liberal_is_HDN | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def user_domain_match(A, B):
"""For blocking/accepting domains.
A and B may be host domain names or IP addresses.
"""
A = A.lower()
B = B.lower()
if not (liberal_is_HDN(A) and liberal_is_HDN(B)):
if A == B:
# equal IP addresses
return True
return False
... | For blocking/accepting domains.
A and B may be host domain names or IP addresses.
| user_domain_match | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def request_host(request):
"""Return request-host, as defined by RFC 2965.
Variation from RFC: returned value is lowercased, for convenient
comparison.
"""
url = request.get_full_url()
host = urlparse.urlparse(url)[1]
if host == "":
host = request.get_header("Host", "")
# remo... | Return request-host, as defined by RFC 2965.
Variation from RFC: returned value is lowercased, for convenient
comparison.
| request_host | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def eff_request_host(request):
"""Return a tuple (request-host, effective request-host name).
As defined by RFC 2965, except both are lowercased.
"""
erhn = req_host = request_host(request)
if req_host.find(".") == -1 and not IPV4_RE.search(req_host):
erhn = req_host + ".local"
return ... | Return a tuple (request-host, effective request-host name).
As defined by RFC 2965, except both are lowercased.
| eff_request_host | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def request_path(request):
"""Path component of request-URI, as defined by RFC 2965."""
url = request.get_full_url()
parts = urlparse.urlsplit(url)
path = escape_path(parts.path)
if not path.startswith("/"):
# fix bad RFC 2396 absoluteURI
path = "/" + path
return path | Path component of request-URI, as defined by RFC 2965. | request_path | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def escape_path(path):
"""Escape any invalid characters in HTTP URL, and uppercase all escapes."""
# There's no knowing what character encoding was used to create URLs
# containing %-escapes, but since we have to pick one to escape invalid
# path characters, we pick UTF-8, as recommended in the HTML 4.0... | Escape any invalid characters in HTTP URL, and uppercase all escapes. | escape_path | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def reach(h):
"""Return reach of host h, as defined by RFC 2965, section 1.
The reach R of a host name H is defined as follows:
* If
- H is the host domain name of a host; and,
- H has the form A.B; and
- A has no embedded (that is, interior) dots; and
- ... | Return reach of host h, as defined by RFC 2965, section 1.
The reach R of a host name H is defined as follows:
* If
- H is the host domain name of a host; and,
- H has the form A.B; and
- A has no embedded (that is, interior) dots; and
- B has at least one e... | reach | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def is_third_party(request):
"""
RFC 2965, section 3.3.6:
An unverifiable transaction is to a third-party host if its request-
host U does not domain-match the reach R of the request-host O in the
origin transaction.
"""
req_host = request_host(request)
if not domain_match... |
RFC 2965, section 3.3.6:
An unverifiable transaction is to a third-party host if its request-
host U does not domain-match the reach R of the request-host O in the
origin transaction.
| is_third_party | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def __init__(self,
blocked_domains=None, allowed_domains=None,
netscape=True, rfc2965=False,
rfc2109_as_netscape=None,
hide_cookie2=False,
strict_domain=False,
strict_rfc2965_unverifiable=True,
strict_... | Constructor arguments should be passed as keyword arguments only. | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def set_allowed_domains(self, allowed_domains):
"""Set the sequence of allowed domains, or None."""
if allowed_domains is not None:
allowed_domains = tuple(allowed_domains)
self._allowed_domains = allowed_domains | Set the sequence of allowed domains, or None. | set_allowed_domains | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def set_ok(self, cookie, request):
"""
If you override .set_ok(), be sure to call this method. If it returns
false, so should your subclass (assuming your subclass wants to be more
strict about which cookies to accept).
"""
_debug(" - checking cookie %s=%s", cookie.name... |
If you override .set_ok(), be sure to call this method. If it returns
false, so should your subclass (assuming your subclass wants to be more
strict about which cookies to accept).
| set_ok | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def return_ok(self, cookie, request):
"""
If you override .return_ok(), be sure to call this method. If it
returns false, so should your subclass (assuming your subclass wants to
be more strict about which cookies to return).
"""
# Path has already been checked by .path... |
If you override .return_ok(), be sure to call this method. If it
returns false, so should your subclass (assuming your subclass wants to
be more strict about which cookies to return).
| return_ok | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def deepvalues(mapping):
"""Iterates over nested mapping, depth-first, in sorted order by key."""
values = vals_sorted_by_key(mapping)
for obj in values:
mapping = False
try:
obj.items
except AttributeError:
pass
else:
mapping = True
... | Iterates over nested mapping, depth-first, in sorted order by key. | deepvalues | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def _cookies_for_request(self, request):
"""Return a list of cookies to be returned to server."""
cookies = []
for domain in self._cookies.keys():
cookies.extend(self._cookies_for_domain(domain, request))
return cookies | Return a list of cookies to be returned to server. | _cookies_for_request | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def _cookie_attrs(self, cookies):
"""Return a list of cookie-attributes to be returned to server.
like ['foo="bar"; $Path="/"', ...]
The $Version attribute is also added when appropriate (currently only
once per request).
"""
# add cookies in order of most specific (ie... | Return a list of cookie-attributes to be returned to server.
like ['foo="bar"; $Path="/"', ...]
The $Version attribute is also added when appropriate (currently only
once per request).
| _cookie_attrs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def add_cookie_header(self, request):
"""Add correct Cookie: header to request (urllib2.Request object).
The Cookie2 header is also added unless policy.hide_cookie2 is true.
"""
_debug("add_cookie_header")
self._cookies_lock.acquire()
try:
self._policy._now... | Add correct Cookie: header to request (urllib2.Request object).
The Cookie2 header is also added unless policy.hide_cookie2 is true.
| add_cookie_header | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def _normalized_cookie_tuples(self, attrs_set):
"""Return list of tuples containing normalised cookie information.
attrs_set is the list of lists of key,value pairs extracted from
the Set-Cookie or Set-Cookie2 headers.
Tuples are name, value, standard, rest, where name and value are th... | Return list of tuples containing normalised cookie information.
attrs_set is the list of lists of key,value pairs extracted from
the Set-Cookie or Set-Cookie2 headers.
Tuples are name, value, standard, rest, where name and value are the
cookie name and value, standard is a dictionary c... | _normalized_cookie_tuples | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def make_cookies(self, response, request):
"""Return sequence of Cookie objects extracted from response object."""
# get cookie-attributes for RFC 2965 and Netscape protocols
headers = response.info()
rfc2965_hdrs = headers.getheaders("Set-Cookie2")
ns_hdrs = headers.getheaders("... | Return sequence of Cookie objects extracted from response object. | make_cookies | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def set_cookie_if_ok(self, cookie, request):
"""Set a cookie if policy says it's OK to do so."""
self._cookies_lock.acquire()
try:
self._policy._now = self._now = int(time.time())
if self._policy.set_ok(cookie, request):
self.set_cookie(cookie)
... | Set a cookie if policy says it's OK to do so. | set_cookie_if_ok | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def set_cookie(self, cookie):
"""Set a cookie, without checking whether or not it should be set."""
c = self._cookies
self._cookies_lock.acquire()
try:
if cookie.domain not in c: c[cookie.domain] = {}
c2 = c[cookie.domain]
if cookie.path not in c2: c2[... | Set a cookie, without checking whether or not it should be set. | set_cookie | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def extract_cookies(self, response, request):
"""Extract cookies from response, where allowable given the request."""
_debug("extract_cookies: %s", response.info())
self._cookies_lock.acquire()
try:
self._policy._now = self._now = int(time.time())
for cookie in s... | Extract cookies from response, where allowable given the request. | extract_cookies | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def clear(self, domain=None, path=None, name=None):
"""Clear some cookies.
Invoking this method without arguments will clear all cookies. If
given a single argument, only cookies belonging to that domain will be
removed. If given two arguments, cookies belonging to the specified
... | Clear some cookies.
Invoking this method without arguments will clear all cookies. If
given a single argument, only cookies belonging to that domain will be
removed. If given two arguments, cookies belonging to the specified
path within that domain are removed. If given three argumen... | clear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def clear_session_cookies(self):
"""Discard all session cookies.
Note that the .save() method won't save session cookies anyway, unless
you ask otherwise by passing a true ignore_discard argument.
"""
self._cookies_lock.acquire()
try:
for cookie in self:
... | Discard all session cookies.
Note that the .save() method won't save session cookies anyway, unless
you ask otherwise by passing a true ignore_discard argument.
| clear_session_cookies | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def clear_expired_cookies(self):
"""Discard all expired cookies.
You probably don't need to call this method: expired cookies are never
sent back to the server (provided you're using DefaultCookiePolicy),
this method is called by CookieJar itself every so often, and the
.save() ... | Discard all expired cookies.
You probably don't need to call this method: expired cookies are never
sent back to the server (provided you're using DefaultCookiePolicy),
this method is called by CookieJar itself every so often, and the
.save() method won't save expired cookies anyway (un... | clear_expired_cookies | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def __init__(self, filename=None, delayload=False, policy=None):
"""
Cookies are NOT loaded from the named file until either the .load() or
.revert() method is called.
"""
CookieJar.__init__(self, policy)
if filename is not None:
try:
filename... |
Cookies are NOT loaded from the named file until either the .load() or
.revert() method is called.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def revert(self, filename=None,
ignore_discard=False, ignore_expires=False):
"""Clear all cookies and reload cookies from a saved file.
Raises LoadError (or IOError) if reversion is not successful; the
object's state will not be altered if this happens.
"""
if fi... | Clear all cookies and reload cookies from a saved file.
Raises LoadError (or IOError) if reversion is not successful; the
object's state will not be altered if this happens.
| revert | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cookielib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cookielib.py | MIT |
def copy(x):
"""Shallow copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
"""
cls = type(x)
copier = _copy_dispatch.get(cls)
if copier:
return copier(x)
copier = getattr(cls, "__copy__", None)
if copier:
return copier(x)
r... | Shallow copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
| copy | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/copy.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/copy.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.