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 docroutine(self, object, name, mod=None,
funcs={}, classes={}, methods={}, cl=None):
"""Produce HTML documentation for a function or method object."""
anchor = (cl and cl.__name__ or '') + '-' + name
note = ''
title = '<a name="%s"><strong>%s</strong></a>' % (
... | Produce HTML documentation for a function or method object. | docroutine | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/DocXMLRPCServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/DocXMLRPCServer.py | MIT |
def docserver(self, server_name, package_documentation, methods):
"""Produce HTML documentation for an XML-RPC server."""
fdict = {}
for key, value in methods.items():
fdict[key] = '#-' + key
fdict[value] = fdict[key]
server_name = self.escape(server_name)
... | Produce HTML documentation for an XML-RPC server. | docserver | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/DocXMLRPCServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/DocXMLRPCServer.py | MIT |
def generate_html_documentation(self):
"""generate_html_documentation() => html documentation for the server
Generates HTML documentation for the server using introspection for
installed functions and instances that do not implement the
_dispatch method. Alternatively, instances can cho... | generate_html_documentation() => html documentation for the server
Generates HTML documentation for the server using introspection for
installed functions and instances that do not implement the
_dispatch method. Alternatively, instances can choose to implement
the _get_method_argstring... | generate_html_documentation | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/DocXMLRPCServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/DocXMLRPCServer.py | MIT |
def do_GET(self):
"""Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.
"""
# Check that the path is legal
if not self.is_rpc_path_valid():
self.report_404()
return
response = self.server.g... | Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.
| do_GET | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/DocXMLRPCServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/DocXMLRPCServer.py | MIT |
def handle_get(self):
"""Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.
"""
response = self.generate_html_documentation()
print 'Content-Type: text/html'
print 'Content-Length: %d' % len(response)
pri... | Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.
| handle_get | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/DocXMLRPCServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/DocXMLRPCServer.py | MIT |
def open(file, flag=None, mode=0666):
"""Open the database file, filename, and return corresponding object.
The flag argument, used to control how the database is opened in the
other DBM implementations, is ignored in the dumbdbm module; the
database is always opened for update, and will be created if ... | Open the database file, filename, and return corresponding object.
The flag argument, used to control how the database is opened in the
other DBM implementations, is ignored in the dumbdbm module; the
database is always opened for update, and will be created if it does
not exist.
The optional mode... | open | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dumbdbm.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dumbdbm.py | MIT |
def start_new_thread(function, args, kwargs={}):
"""Dummy implementation of thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
and it is SystemExit (which can be done by thread.exit()) it is
caugh... | Dummy implementation of thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
and it is SystemExit (which can be done by thread.exit()) it is
caught and nothing is done; all other exceptions are printed ... | start_new_thread | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dummy_thread.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dummy_thread.py | MIT |
def acquire(self, waitflag=None):
"""Dummy implementation of acquire().
For blocking calls, self.locked_status is automatically set to
True and returned appropriately based on value of
``waitflag``. If it is non-blocking, then the value is
actually checked and not set if it is ... | Dummy implementation of acquire().
For blocking calls, self.locked_status is automatically set to
True and returned appropriately based on value of
``waitflag``. If it is non-blocking, then the value is
actually checked and not set if it is already acquired. This
is all done s... | acquire | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dummy_thread.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dummy_thread.py | MIT |
def interrupt_main():
"""Set _interrupt flag to True to have start_new_thread raise
KeyboardInterrupt upon exiting."""
if _main:
raise KeyboardInterrupt
else:
global _interrupt
_interrupt = True | Set _interrupt flag to True to have start_new_thread raise
KeyboardInterrupt upon exiting. | interrupt_main | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/dummy_thread.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/dummy_thread.py | MIT |
def cmp(f1, f2, shallow=1):
"""Compare two files.
Arguments:
f1 -- First file name
f2 -- Second file name
shallow -- Just check stat signature (do not read the files).
defaults to 1.
Return value:
True if the files are the same, False otherwise.
This function uses a... | Compare two files.
Arguments:
f1 -- First file name
f2 -- Second file name
shallow -- Just check stat signature (do not read the files).
defaults to 1.
Return value:
True if the files are the same, False otherwise.
This function uses a cache for past comparisons and the... | cmp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/filecmp.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/filecmp.py | MIT |
def cmpfiles(a, b, common, shallow=1):
"""Compare common files in two directories.
a, b -- directory names
common -- list of file names found in both directories
shallow -- if true, do comparison based solely on stat() information
Returns a tuple of three lists:
files that compare equal
... | Compare common files in two directories.
a, b -- directory names
common -- list of file names found in both directories
shallow -- if true, do comparison based solely on stat() information
Returns a tuple of three lists:
files that compare equal
files that are different
filenames tha... | cmpfiles | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/filecmp.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/filecmp.py | MIT |
def input(files=None, inplace=0, backup="", bufsize=0,
mode="r", openhook=None):
"""Return an instance of the FileInput class, which can be iterated.
The parameters are passed to the constructor of the FileInput class.
The returned instance, in addition to being an iterator,
keeps global stat... | Return an instance of the FileInput class, which can be iterated.
The parameters are passed to the constructor of the FileInput class.
The returned instance, in addition to being an iterator,
keeps global state for the functions of this module,.
| input | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def nextfile():
"""
Close the current file so that the next iteration will read the first
line from the next file (if any); lines not read from the file will
not count towards the cumulative line count. The filename is not
changed until after the first line of the next file has been read.
Before... |
Close the current file so that the next iteration will read the first
line from the next file (if any); lines not read from the file will
not count towards the cumulative line count. The filename is not
changed until after the first line of the next file has been read.
Before the first line has bee... | nextfile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def filename():
"""
Return the name of the file currently being read.
Before the first line has been read, returns None.
"""
if not _state:
raise RuntimeError, "no active input()"
return _state.filename() |
Return the name of the file currently being read.
Before the first line has been read, returns None.
| filename | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def lineno():
"""
Return the cumulative line number of the line that has just been read.
Before the first line has been read, returns 0. After the last line
of the last file has been read, returns the line number of that line.
"""
if not _state:
raise RuntimeError, "no active input()"
... |
Return the cumulative line number of the line that has just been read.
Before the first line has been read, returns 0. After the last line
of the last file has been read, returns the line number of that line.
| lineno | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def filelineno():
"""
Return the line number in the current file. Before the first line
has been read, returns 0. After the last line of the last file has
been read, returns the line number of that line within the file.
"""
if not _state:
raise RuntimeError, "no active input()"
retur... |
Return the line number in the current file. Before the first line
has been read, returns 0. After the last line of the last file has
been read, returns the line number of that line within the file.
| filelineno | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def fileno():
"""
Return the file number of the current file. When no file is currently
opened, returns -1.
"""
if not _state:
raise RuntimeError, "no active input()"
return _state.fileno() |
Return the file number of the current file. When no file is currently
opened, returns -1.
| fileno | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def isfirstline():
"""
Returns true the line just read is the first line of its file,
otherwise returns false.
"""
if not _state:
raise RuntimeError, "no active input()"
return _state.isfirstline() |
Returns true the line just read is the first line of its file,
otherwise returns false.
| isfirstline | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def isstdin():
"""
Returns true if the last line was read from sys.stdin,
otherwise returns false.
"""
if not _state:
raise RuntimeError, "no active input()"
return _state.isstdin() |
Returns true if the last line was read from sys.stdin,
otherwise returns false.
| isstdin | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fileinput.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fileinput.py | MIT |
def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
Patterns are Unix shell style:
* matches everything
? matches any single character
[seq] matches any character in seq
[!seq] matches any char not in seq
An initial period in FILENAME is not special.
Both ... | Test whether FILENAME matches PATTERN.
Patterns are Unix shell style:
* matches everything
? matches any single character
[seq] matches any character in seq
[!seq] matches any char not in seq
An initial period in FILENAME is not special.
Both FILENAME and PATTERN are first ... | fnmatch | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fnmatch.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fnmatch.py | MIT |
def filter(names, pat):
"""Return the subset of the list NAMES that match PAT"""
import os,posixpath
result=[]
pat=os.path.normcase(pat)
try:
re_pat = _cache[pat]
except KeyError:
res = translate(pat)
if len(_cache) >= _MAXCACHE:
_cache.clear()
_cache[... | Return the subset of the list NAMES that match PAT | filter | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fnmatch.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fnmatch.py | MIT |
def fnmatchcase(name, pat):
"""Test whether FILENAME matches PATTERN, including case.
This is a version of fnmatch() which doesn't case-normalize
its arguments.
"""
try:
re_pat = _cache[pat]
except KeyError:
res = translate(pat)
if len(_cache) >= _MAXCACHE:
... | Test whether FILENAME matches PATTERN, including case.
This is a version of fnmatch() which doesn't case-normalize
its arguments.
| fnmatchcase | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fnmatch.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fnmatch.py | MIT |
def translate(pat):
"""Translate a shell PATTERN to a regular expression.
There is no way to quote meta-characters.
"""
i, n = 0, len(pat)
res = ''
while i < n:
c = pat[i]
i = i+1
if c == '*':
res = res + '.*'
elif c == '?':
res = res + '... | Translate a shell PATTERN to a regular expression.
There is no way to quote meta-characters.
| translate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fnmatch.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fnmatch.py | MIT |
def extract(s):
"""Return (sign, intpart, fraction, expo) or raise an exception:
sign is '+' or '-'
intpart is 0 or more digits beginning with a nonzero
fraction is 0 or more digits
expo is an integer"""
res = decoder.match(s)
if res is None: raise NotANumber, s
sign, intpart, fraction, ... | Return (sign, intpart, fraction, expo) or raise an exception:
sign is '+' or '-'
intpart is 0 or more digits beginning with a nonzero
fraction is 0 or more digits
expo is an integer | extract | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fpformat.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fpformat.py | MIT |
def unexpo(intpart, fraction, expo):
"""Remove the exponent by changing intpart and fraction."""
if expo > 0: # Move the point left
f = len(fraction)
intpart, fraction = intpart + fraction[:expo], fraction[expo:]
if expo > f:
intpart = intpart + '0'*(expo-f)
elif expo < 0... | Remove the exponent by changing intpart and fraction. | unexpo | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fpformat.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fpformat.py | MIT |
def roundfrac(intpart, fraction, digs):
"""Round or extend the fraction to size digs."""
f = len(fraction)
if f <= digs:
return intpart, fraction + '0'*(digs-f)
i = len(intpart)
if i+digs < 0:
return '0'*-digs, ''
total = intpart + fraction
nextdigit = total[i+digs]
if ne... | Round or extend the fraction to size digs. | roundfrac | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fpformat.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fpformat.py | MIT |
def fix(x, digs):
"""Format x as [-]ddd.ddd with 'digs' digits after the point
and at least one digit before.
If digs <= 0, the point is suppressed."""
if type(x) != type(''): x = repr(x)
try:
sign, intpart, fraction, expo = extract(x)
except NotANumber:
return x
intpart, fra... | Format x as [-]ddd.ddd with 'digs' digits after the point
and at least one digit before.
If digs <= 0, the point is suppressed. | fix | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fpformat.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fpformat.py | MIT |
def sci(x, digs):
"""Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point
and exactly one digit before.
If digs is <= 0, one digit is kept and the point is suppressed."""
if type(x) != type(''): x = repr(x)
sign, intpart, fraction, expo = extract(x)
if not intpart:
while fract... | Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point
and exactly one digit before.
If digs is <= 0, one digit is kept and the point is suppressed. | sci | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fpformat.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fpformat.py | MIT |
def gcd(a, b):
"""Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
"""
while b:
a, b = b, a%b
return a | Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
| gcd | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def __new__(cls, numerator=0, denominator=None):
"""Constructs a Fraction.
Takes a string like '3/2' or '1.5', another Rational instance, a
numerator/denominator pair, or a float.
Examples
--------
>>> Fraction(10, -8)
Fraction(-5, 4)
>>> Fraction(Fract... | Constructs a Fraction.
Takes a string like '3/2' or '1.5', another Rational instance, a
numerator/denominator pair, or a float.
Examples
--------
>>> Fraction(10, -8)
Fraction(-5, 4)
>>> Fraction(Fraction(1, 7), 5)
Fraction(1, 35)
>>> Fraction(F... | __new__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def from_float(cls, f):
"""Converts a finite float to a rational number, exactly.
Beware that Fraction.from_float(0.3) != Fraction(3, 10).
"""
if isinstance(f, numbers.Integral):
return cls(f)
elif not isinstance(f, float):
raise TypeError("%s.from_float... | Converts a finite float to a rational number, exactly.
Beware that Fraction.from_float(0.3) != Fraction(3, 10).
| from_float | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def from_decimal(cls, dec):
"""Converts a finite Decimal instance to a rational number, exactly."""
from decimal import Decimal
if isinstance(dec, numbers.Integral):
dec = Decimal(int(dec))
elif not isinstance(dec, Decimal):
raise TypeError(
"%s.fr... | Converts a finite Decimal instance to a rational number, exactly. | from_decimal | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def _operator_fallbacks(monomorphic_operator, fallback_operator):
"""Generates forward and reverse operators given a purely-rational
operator and a function from the operator module.
Use this like:
__op__, __rop__ = _operator_fallbacks(just_rational_op, operator.op)
In general,... | Generates forward and reverse operators given a purely-rational
operator and a function from the operator module.
Use this like:
__op__, __rop__ = _operator_fallbacks(just_rational_op, operator.op)
In general, we want to implement the arithmetic operations so
that mixed-mode op... | _operator_fallbacks | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def __pow__(a, b):
"""a ** b
If b is not an integer, the result will be a float or complex
since roots are generally irrational. If b is an integer, the
result will be rational.
"""
if isinstance(b, Rational):
if b.denominator == 1:
power = b... | a ** b
If b is not an integer, the result will be a float or complex
since roots are generally irrational. If b is an integer, the
result will be rational.
| __pow__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def __hash__(self):
"""hash(self)
Tricky because values that are exactly representable as a
float must have the same hash as that float.
"""
# XXX since this method is expensive, consider caching the result
if self._denominator == 1:
# Get integers right.
... | hash(self)
Tricky because values that are exactly representable as a
float must have the same hash as that float.
| __hash__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def _richcmp(self, other, op):
"""Helper for comparison operators, for internal use only.
Implement comparison between a Rational instance `self`, and
either another Rational instance or a float `other`. If
`other` is not a Rational instance or a float, return
NotImplemented. `... | Helper for comparison operators, for internal use only.
Implement comparison between a Rational instance `self`, and
either another Rational instance or a float `other`. If
`other` is not a Rational instance or a float, return
NotImplemented. `op` should be one of the six standard
... | _richcmp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/fractions.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/fractions.py | MIT |
def connect(self, host='', port=0, timeout=-999):
'''Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
- port: port to connect to (integer, default previous port)
'''
if host != '':
self.host = host
if port > 0:
... | Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
- port: port to connect to (integer, default previous port)
| connect | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def getwelcome(self):
'''Get the welcome message from the server.
(this is read and squirreled away by connect())'''
if self.debugging:
print '*welcome*', self.sanitize(self.welcome)
return self.welcome | Get the welcome message from the server.
(this is read and squirreled away by connect()) | getwelcome | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def abort(self):
'''Abort a file transfer. Uses out-of-band data.
This does not follow the procedure from the RFC to send Telnet
IP and Synch; that doesn't seem to work with the servers I've
tried. Instead, just send the ABOR command as OOB data.'''
line = 'ABOR' + CRLF
... | Abort a file transfer. Uses out-of-band data.
This does not follow the procedure from the RFC to send Telnet
IP and Synch; that doesn't seem to work with the servers I've
tried. Instead, just send the ABOR command as OOB data. | abort | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def sendport(self, host, port):
'''Send a PORT command with the current host and the given
port number.
'''
hbytes = host.split('.')
pbytes = [repr(port//256), repr(port%256)]
bytes = hbytes + pbytes
cmd = 'PORT ' + ','.join(bytes)
return self.voidcmd(cmd) | Send a PORT command with the current host and the given
port number.
| sendport | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def sendeprt(self, host, port):
'''Send a EPRT command with the current host and the given port number.'''
af = 0
if self.af == socket.AF_INET:
af = 1
if self.af == socket.AF_INET6:
af = 2
if af == 0:
raise error_proto, 'unsupported address fam... | Send a EPRT command with the current host and the given port number. | sendeprt | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def makeport(self):
'''Create a new socket and send a PORT command for it.'''
err = None
sock = None
for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
af, socktype, proto, canonname, sa = res
try:
sock = soc... | Create a new socket and send a PORT command for it. | makeport | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def ntransfercmd(self, cmd, rest=None):
"""Initiate a transfer over the data connection.
If the transfer is active, send a port command and the
transfer command, and accept the connection. If the server is
passive, send a pasv command, connect to it, and start the
transfer comm... | Initiate a transfer over the data connection.
If the transfer is active, send a port command and the
transfer command, and accept the connection. If the server is
passive, send a pasv command, connect to it, and start the
transfer command. Either way, return the socket for the
... | ntransfercmd | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
"""Retrieve data in binary mode. A new port is created for you.
Args:
cmd: A RETR command.
callback: A single parameter callable to be called on each
block of data read.
blocksize: The max... | Retrieve data in binary mode. A new port is created for you.
Args:
cmd: A RETR command.
callback: A single parameter callable to be called on each
block of data read.
blocksize: The maximum number of bytes to read from the
socket at one ti... | retrbinary | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def retrlines(self, cmd, callback = None):
"""Retrieve data in line mode. A new port is created for you.
Args:
cmd: A RETR, LIST, NLST, or MLSD command.
callback: An optional single parameter callable that is called
for each line with the trailing CRLF stripped.... | Retrieve data in line mode. A new port is created for you.
Args:
cmd: A RETR, LIST, NLST, or MLSD command.
callback: An optional single parameter callable that is called
for each line with the trailing CRLF stripped.
[default: print_line()]
... | retrlines | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
"""Store a file in binary mode. A new port is created for you.
Args:
cmd: A STOR command.
fp: A file-like object with a read(num_bytes) method.
blocksize: The maximum data size to read from fp and se... | Store a file in binary mode. A new port is created for you.
Args:
cmd: A STOR command.
fp: A file-like object with a read(num_bytes) method.
blocksize: The maximum data size to read from fp and send over
the connection at once. [default: 8192]
call... | storbinary | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def storlines(self, cmd, fp, callback=None):
"""Store a file in line mode. A new port is created for you.
Args:
cmd: A STOR command.
fp: A file-like object with a readline() method.
callback: An optional single parameter callable that is called on
each... | Store a file in line mode. A new port is created for you.
Args:
cmd: A STOR command.
fp: A file-like object with a readline() method.
callback: An optional single parameter callable that is called on
each line after it is sent. [default: None]
Return... | storlines | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def nlst(self, *args):
'''Return a list of files in a given directory (default the current).'''
cmd = 'NLST'
for arg in args:
cmd = cmd + (' ' + arg)
files = []
self.retrlines(cmd, files.append)
return files | Return a list of files in a given directory (default the current). | nlst | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def dir(self, *args):
'''List a directory in long form.
By default list current directory to stdout.
Optional last argument is callback function; all
non-empty arguments before it are concatenated to the
LIST command. (This *should* only be used for a pathname.)'''
cmd =... | List a directory in long form.
By default list current directory to stdout.
Optional last argument is callback function; all
non-empty arguments before it are concatenated to the
LIST command. (This *should* only be used for a pathname.) | dir | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def close(self):
'''Close the connection without assuming anything about it.'''
try:
file = self.file
self.file = None
if file is not None:
file.close()
finally:
sock = self.sock
self.sock = None
if sock is n... | Close the connection without assuming anything about it. | close | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def auth(self):
'''Set up secure control connection by using TLS/SSL.'''
if isinstance(self.sock, ssl.SSLSocket):
raise ValueError("Already using TLS")
if self.ssl_version >= ssl.PROTOCOL_SSLv23:
resp = self.voidcmd('AUTH TLS')
else:
... | Set up secure control connection by using TLS/SSL. | auth | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def prot_c(self):
'''Set up clear text data connection.'''
resp = self.voidcmd('PROT C')
self._prot_p = False
return resp | Set up clear text data connection. | prot_c | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def parse150(resp):
'''Parse the '150' response for a RETR request.
Returns the expected transfer size or None; size is not guaranteed to
be present in the 150 message.
'''
if resp[:3] != '150':
raise error_reply, resp
global _150_re
if _150_re is None:
import re
_150... | Parse the '150' response for a RETR request.
Returns the expected transfer size or None; size is not guaranteed to
be present in the 150 message.
| parse150 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def parse227(resp):
'''Parse the '227' response for a PASV request.
Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'
Return ('host.addr.as.numbers', port#) tuple.'''
if resp[:3] != '227':
raise error_reply, resp
global _227_re
if _227_re is None:
import re
... | Parse the '227' response for a PASV request.
Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'
Return ('host.addr.as.numbers', port#) tuple. | parse227 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def parse229(resp, peer):
'''Parse the '229' response for a EPSV request.
Raises error_proto if it does not contain '(|||port|)'
Return ('host.addr.as.numbers', port#) tuple.'''
if resp[:3] != '229':
raise error_reply, resp
left = resp.find('(')
if left < 0: raise error_proto, resp
... | Parse the '229' response for a EPSV request.
Raises error_proto if it does not contain '(|||port|)'
Return ('host.addr.as.numbers', port#) tuple. | parse229 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def parse257(resp):
'''Parse the '257' response for a MKD or PWD request.
This is a response to a MKD or PWD request: a directory name.
Returns the directoryname in the 257 reply.'''
if resp[:3] != '257':
raise error_reply, resp
if resp[3:5] != ' "':
return '' # Not compliant to RFC... | Parse the '257' response for a MKD or PWD request.
This is a response to a MKD or PWD request: a directory name.
Returns the directoryname in the 257 reply. | parse257 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
'''Copy file from one FTP-instance to another.'''
if not targetname: targetname = sourcename
type = 'TYPE ' + type
source.voidcmd(type)
target.voidcmd(type)
sourcehost, sourceport = parse227(source.sendcmd('PASV'))
target.se... | Copy file from one FTP-instance to another. | ftpcp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def get_account(self, host):
"""Returns login information for the named host.
The return value is a triple containing userid,
password, and the accounting field.
"""
host = host.lower()
user = passwd = acct = None
if host in self.__hosts:
user, passw... | Returns login information for the named host.
The return value is a triple containing userid,
password, and the accounting field.
| get_account | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def test():
'''Test program.
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
-d dir
-l list
-p password
'''
if len(sys.argv) < 2:
print test.__doc__
sys.exit(0)
debugging = 0
rcfile = None
while sys.argv[1] == '-d':
debugging = debug... | Test program.
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
-d dir
-l list
-p password
| test | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/ftplib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/ftplib.py | MIT |
def update_wrapper(wrapper,
wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):
"""Update a wrapper function to look like the wrapped function
wrapper is the function to be updated
wrapped is the original function
assign... | Update a wrapper function to look like the wrapped function
wrapper is the function to be updated
wrapped is the original function
assigned is a tuple naming the attributes assigned directly
from the wrapped function to the wrapper function (defaults to
functools.WRAPPER_ASSIGNMENTS)... | update_wrapper | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/functools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/functools.py | MIT |
def wraps(wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):
"""Decorator factory to apply update_wrapper() to a wrapper function
Returns a decorator that invokes update_wrapper() with the decorated
function as the wrapper argument and the arguments to wraps() as... | Decorator factory to apply update_wrapper() to a wrapper function
Returns a decorator that invokes update_wrapper() with the decorated
function as the wrapper argument and the arguments to wraps() as the
remaining arguments. Default arguments are as for update_wrapper().
This is a convenien... | wraps | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/functools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/functools.py | MIT |
def total_ordering(cls):
"""Class decorator that fills in missing ordering methods"""
convert = {
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
('__le__', lambda self, other: self < other or self == other),
('__ge__', lambda self, o... | Class decorator that fills in missing ordering methods | total_ordering | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/functools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/functools.py | MIT |
def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
class K(object):
__slots__ = ['obj']
def __init__(self, obj, *args):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
... | Convert a cmp= function into a key= function | cmp_to_key | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/functools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/functools.py | MIT |
def exists(path):
"""Test whether a path exists. Returns False for broken symbolic links"""
try:
os.stat(path)
except os.error:
return False
return True | Test whether a path exists. Returns False for broken symbolic links | exists | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/genericpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/genericpath.py | MIT |
def isfile(path):
"""Test whether a path is a regular file"""
try:
st = os.stat(path)
except os.error:
return False
return stat.S_ISREG(st.st_mode) | Test whether a path is a regular file | isfile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/genericpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/genericpath.py | MIT |
def isdir(s):
"""Return true if the pathname refers to an existing directory."""
try:
st = os.stat(s)
except os.error:
return False
return stat.S_ISDIR(st.st_mode) | Return true if the pathname refers to an existing directory. | isdir | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/genericpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/genericpath.py | MIT |
def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m: return ''
s1 = min(m)
s2 = max(m)
for i, c in enumerate(s1):
if c != s2[i]:
return s1[:i]
return s1 | Given a list of pathnames, returns the longest common leading component | commonprefix | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/genericpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/genericpath.py | MIT |
def _splitext(p, sep, altsep, extsep):
"""Split the extension from a pathname.
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty."""
sepIndex = p.rfind(sep)
if altsep:
altsepIndex = p.rfind(altsep)
sepIndex = max(s... | Split the extension from a pathname.
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty. | _splitext | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/genericpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/genericpath.py | MIT |
def getopt(args, shortopts, longopts = []):
"""getopt(args, options[, long_options]) -> opts, args
Parses command line options and parameter list. args is the
argument list to be parsed, without the leading reference to the
running program. Typically, this means "sys.argv[1:]". shortopts
is the ... | getopt(args, options[, long_options]) -> opts, args
Parses command line options and parameter list. args is the
argument list to be parsed, without the leading reference to the
running program. Typically, this means "sys.argv[1:]". shortopts
is the string of option letters that the script wants to
... | getopt | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/getopt.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/getopt.py | MIT |
def gnu_getopt(args, shortopts, longopts = []):
"""getopt(args, options[, long_options]) -> opts, args
This function works like getopt(), except that GNU style scanning
mode is used by default. This means that option and non-option
arguments may be intermixed. The getopt() function stops
processing... | getopt(args, options[, long_options]) -> opts, args
This function works like getopt(), except that GNU style scanning
mode is used by default. This means that option and non-option
arguments may be intermixed. The getopt() function stops
processing options as soon as a non-option argument is
encoun... | gnu_getopt | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/getopt.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/getopt.py | MIT |
def unix_getpass(prompt='Password: ', stream=None):
"""Prompt for a password, with echo turned off.
Args:
prompt: Written on stream to ask for the input. Default: 'Password: '
stream: A writable file object to display the prompt. Defaults to
the tty. If no tty is available defaults... | Prompt for a password, with echo turned off.
Args:
prompt: Written on stream to ask for the input. Default: 'Password: '
stream: A writable file object to display the prompt. Defaults to
the tty. If no tty is available defaults to sys.stderr.
Returns:
The seKr3t input.
Ra... | unix_getpass | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/getpass.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/getpass.py | MIT |
def win_getpass(prompt='Password: ', stream=None):
"""Prompt for password with echo off, using Windows getch()."""
if sys.stdin is not sys.__stdin__:
return fallback_getpass(prompt, stream)
import msvcrt
for c in prompt:
msvcrt.putch(c)
pw = ""
while 1:
c = msvcrt.getch()... | Prompt for password with echo off, using Windows getch(). | win_getpass | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/getpass.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/getpass.py | MIT |
def getuser():
"""Get the username from the environment or password database.
First try various environment variables, then the password
database. This works on Windows as long as USERNAME is set.
"""
import os
for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
user = os.environ.... | Get the username from the environment or password database.
First try various environment variables, then the password
database. This works on Windows as long as USERNAME is set.
| getuser | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/getpass.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/getpass.py | MIT |
def test(condition, true, false):
"""
Implements the C expression:
condition ? true : false
Required to correctly interpret plural forms.
"""
if condition:
return true
else:
return false |
Implements the C expression:
condition ? true : false
Required to correctly interpret plural forms.
| test | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/gettext.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/gettext.py | MIT |
def c2py(plural):
"""Gets a C expression as used in PO files for plural forms and returns a
Python lambda function that implements an equivalent expression.
"""
# Security check, allow only the "n" identifier
try:
from cStringIO import StringIO
except ImportError:
from StringIO i... | Gets a C expression as used in PO files for plural forms and returns a
Python lambda function that implements an equivalent expression.
| c2py | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/gettext.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/gettext.py | MIT |
def _parse(self, fp):
"""Override this method to support alternative .mo formats."""
unpack = struct.unpack
filename = getattr(fp, 'name', '')
# Parse the .mo file header, which consists of 5 little endian 32
# bit words.
self._catalog = catalog = {}
self.plural =... | Override this method to support alternative .mo formats. | _parse | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/gettext.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/gettext.py | MIT |
def iglob(pathname):
"""Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
"""
dirna... | Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
| iglob | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/glob.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/glob.py | MIT |
def _check_closed(self):
"""Raises a ValueError if the underlying file object has been closed.
"""
if self.closed:
raise ValueError('I/O operation on closed file.') | Raises a ValueError if the underlying file object has been closed.
| _check_closed | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/gzip.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/gzip.py | MIT |
def rewind(self):
'''Return the uncompressed stream file position indicator to the
beginning of the file'''
if self.mode != READ:
raise IOError("Can't rewind in write mode")
self.fileobj.seek(0)
self._new_member = True
self.extrabuf = ""
self.extrasize... | Return the uncompressed stream file position indicator to the
beginning of the file | rewind | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/gzip.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/gzip.py | MIT |
def __hash_new(name, string=''):
"""new(name, string='') - Return a new hashing object using the named algorithm;
optionally initialized with a string.
"""
try:
return _hashlib.new(name, string)
except ValueError:
# If the _hashlib module (OpenSSL) doesn't support the named
#... | new(name, string='') - Return a new hashing object using the named algorithm;
optionally initialized with a string.
| __hash_new | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/hashlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/hashlib.py | MIT |
def pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None):
"""Password based key derivation function 2 (PKCS #5 v2.0)
This Python implementations based on the hmac module about as fast
as OpenSSL's PKCS5_PBKDF2_HMAC for short passwords and much faster
for long passwords.
... | Password based key derivation function 2 (PKCS #5 v2.0)
This Python implementations based on the hmac module about as fast
as OpenSSL's PKCS5_PBKDF2_HMAC for short passwords and much faster
for long passwords.
| pbkdf2_hmac | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/hashlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/hashlib.py | MIT |
def heappush(heap, item):
"""Push item onto heap, maintaining the heap invariant."""
heap.append(item)
_siftdown(heap, 0, len(heap)-1) | Push item onto heap, maintaining the heap invariant. | heappush | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def heappop(heap):
"""Pop the smallest item off the heap, maintaining the heap invariant."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else:
returnitem = lastelt
return ret... | Pop the smallest item off the heap, maintaining the heap invariant. | heappop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def heapreplace(heap, item):
"""Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable use... | Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable uses of
this routine unless written... | heapreplace | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def heappushpop(heap, item):
"""Fast version of a heappush followed by a heappop."""
if heap and cmp_lt(heap[0], item):
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item | Fast version of a heappush followed by a heappop. | heappushpop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def heapify(x):
"""Transform list into a heap, in-place, in O(len(x)) time."""
n = len(x)
# Transform bottom-up. The largest index there's any point to looking at
# is the largest with a child index in-range, so must have 2*i + 1 < n,
# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2... | Transform list into a heap, in-place, in O(len(x)) time. | heapify | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def _heappushpop_max(heap, item):
"""Maxheap version of a heappush followed by a heappop."""
if heap and cmp_lt(item, heap[0]):
item, heap[0] = heap[0], item
_siftup_max(heap, 0)
return item | Maxheap version of a heappush followed by a heappop. | _heappushpop_max | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def _heapify_max(x):
"""Transform list into a maxheap, in-place, in O(len(x)) time."""
n = len(x)
for i in reversed(range(n//2)):
_siftup_max(x, i) | Transform list into a maxheap, in-place, in O(len(x)) time. | _heapify_max | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def nlargest(n, iterable):
"""Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, reverse=True)[:n]
"""
if n < 0:
return []
it = iter(iterable)
result = list(islice(it, n))
if not result:
return result
heapify(result)
_heappushpop = heappushpop... | Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, reverse=True)[:n]
| nlargest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def nsmallest(n, iterable):
"""Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable)[:n]
"""
if n < 0:
return []
it = iter(iterable)
result = list(islice(it, n))
if not result:
return result
_heapify_max(result)
_heappushpop = _heappushpop_max
... | Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable)[:n]
| nsmallest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def merge(*iterables):
'''Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to largest).
>>> list(m... | Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to largest).
>>> list(merge([1,3,5,7], [0,2,4,8], [5,... | merge | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def nsmallest(n, iterable, key=None):
"""Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n]
"""
# Short-cut for n==1 is to use min() when len(iterable)>0
if n == 1:
it = iter(iterable)
head = list(islice(it, 1))
if not head:
... | Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n]
| nsmallest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def nlargest(n, iterable, key=None):
"""Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
"""
# Short-cut for n==1 is to use max() when len(iterable)>0
if n == 1:
it = iter(iterable)
head = list(islice(it, 1))
if not head:... | Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
| nlargest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/heapq.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/heapq.py | MIT |
def __init__(self, key, msg = None, digestmod = None):
"""Create a new HMAC object.
key: key for the keyed hash object.
msg: Initial input for the hash, if provided.
digestmod: A module supporting PEP 247. *OR*
A hashlib constructor returning a new hash o... | Create a new HMAC object.
key: key for the keyed hash object.
msg: Initial input for the hash, if provided.
digestmod: A module supporting PEP 247. *OR*
A hashlib constructor returning a new hash object.
Defaults to hashlib.md5.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/hmac.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/hmac.py | MIT |
def copy(self):
"""Return a separate copy of this hashing object.
An update to this copy won't affect the original object.
"""
other = self.__class__(_secret_backdoor_key)
other.digest_cons = self.digest_cons
other.digest_size = self.digest_size
other.inner = sel... | Return a separate copy of this hashing object.
An update to this copy won't affect the original object.
| copy | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/hmac.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/hmac.py | MIT |
def _current(self):
"""Return a hash object for the current state.
To be used only internally with digest() and hexdigest().
"""
h = self.outer.copy()
h.update(self.inner.digest())
return h | Return a hash object for the current state.
To be used only internally with digest() and hexdigest().
| _current | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/hmac.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/hmac.py | MIT |
def __init__(self, formatter, verbose=0):
"""Creates an instance of the HTMLParser class.
The formatter parameter is the formatter instance associated with
the parser.
"""
sgmllib.SGMLParser.__init__(self, verbose)
self.formatter = formatter | Creates an instance of the HTMLParser class.
The formatter parameter is the formatter instance associated with
the parser.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/htmllib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/htmllib.py | MIT |
def save_end(self):
"""Ends buffering character data and returns all data saved since
the preceding call to the save_bgn() method.
If the nofill flag is false, whitespace is collapsed to single
spaces. A call to this method without a preceding call to the
save_bgn() method will... | Ends buffering character data and returns all data saved since
the preceding call to the save_bgn() method.
If the nofill flag is false, whitespace is collapsed to single
spaces. A call to this method without a preceding call to the
save_bgn() method will raise a TypeError exception.
... | save_end | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/htmllib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/htmllib.py | MIT |
def anchor_bgn(self, href, name, type):
"""This method is called at the start of an anchor region.
The arguments correspond to the attributes of the <A> tag with
the same names. The default implementation maintains a list of
hyperlinks (defined by the HREF attribute for <A> tags) withi... | This method is called at the start of an anchor region.
The arguments correspond to the attributes of the <A> tag with
the same names. The default implementation maintains a list of
hyperlinks (defined by the HREF attribute for <A> tags) within
the document. The list of hyperlinks is ... | anchor_bgn | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/htmllib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/htmllib.py | MIT |
def anchor_end(self):
"""This method is called at the end of an anchor region.
The default implementation adds a textual footnote marker using an
index into the list of hyperlinks created by the anchor_bgn()method.
"""
if self.anchor:
self.handle_data("[%d]" % len(s... | This method is called at the end of an anchor region.
The default implementation adds a textual footnote marker using an
index into the list of hyperlinks created by the anchor_bgn()method.
| anchor_end | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/htmllib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/htmllib.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.