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 AutoProxy(token, serializer, manager=None, authkey=None,
exposed=None, incref=True):
'''
Return an auto-proxy for `token`
'''
_Client = listener_client[serializer][1]
if exposed is None:
conn = _Client(token.address, authkey=authkey)
try:
exposed = disp... |
Return an auto-proxy for `token`
| AutoProxy | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/managers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/managers.py | MIT |
def _join_exited_workers(self):
"""Cleanup after any worker processes which have exited due to reaching
their specified lifetime. Returns True if any workers were cleaned up.
"""
cleaned = False
for i in reversed(range(len(self._pool))):
worker = self._pool[i]
... | Cleanup after any worker processes which have exited due to reaching
their specified lifetime. Returns True if any workers were cleaned up.
| _join_exited_workers | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/pool.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/pool.py | MIT |
def _repopulate_pool(self):
"""Bring the number of pool processes up to the specified number,
for use after reaping workers which have exited.
"""
for i in range(self._processes - len(self._pool)):
w = self.Process(target=worker,
args=(self._inque... | Bring the number of pool processes up to the specified number,
for use after reaping workers which have exited.
| _repopulate_pool | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/pool.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/pool.py | MIT |
def imap(self, func, iterable, chunksize=1):
'''
Equivalent of `itertools.imap()` -- can be MUCH slower than `Pool.map()`
'''
assert self._state == RUN
if chunksize == 1:
result = IMapIterator(self._cache)
self._taskqueue.put((((result._job, i, func, (x,),... |
Equivalent of `itertools.imap()` -- can be MUCH slower than `Pool.map()`
| imap | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/pool.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/pool.py | MIT |
def imap_unordered(self, func, iterable, chunksize=1):
'''
Like `imap()` method but ordering of results is arbitrary
'''
assert self._state == RUN
if chunksize == 1:
result = IMapUnorderedIterator(self._cache)
self._taskqueue.put((((result._job, i, func, (... |
Like `imap()` method but ordering of results is arbitrary
| imap_unordered | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/pool.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/pool.py | MIT |
def exitcode(self):
'''
Return exit code of process or `None` if it has yet to stop
'''
if self._popen is None:
return self._popen
return self._popen.poll() |
Return exit code of process or `None` if it has yet to stop
| exitcode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/process.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/process.py | MIT |
def ident(self):
'''
Return identifier (PID) of process or `None` if it has yet to start
'''
if self is _current_process:
return os.getpid()
else:
return self._popen and self._popen.pid |
Return identifier (PID) of process or `None` if it has yet to start
| ident | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/process.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/process.py | MIT |
def RawValue(typecode_or_type, *args):
'''
Returns a ctypes object allocated from shared memory
'''
type_ = typecode_to_type.get(typecode_or_type, typecode_or_type)
obj = _new_value(type_)
ctypes.memset(ctypes.addressof(obj), 0, ctypes.sizeof(obj))
obj.__init__(*args)
return obj |
Returns a ctypes object allocated from shared memory
| RawValue | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/sharedctypes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/sharedctypes.py | MIT |
def RawArray(typecode_or_type, size_or_initializer):
'''
Returns a ctypes array allocated from shared memory
'''
type_ = typecode_to_type.get(typecode_or_type, typecode_or_type)
if isinstance(size_or_initializer, (int, long)):
type_ = type_ * size_or_initializer
obj = _new_value(type... |
Returns a ctypes array allocated from shared memory
| RawArray | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/sharedctypes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/sharedctypes.py | MIT |
def log_to_stderr(level=None):
'''
Turn on logging and add a handler which prints to stderr
'''
global _log_to_stderr
import logging
logger = get_logger()
formatter = logging.Formatter(DEFAULT_LOGGING_FORMAT)
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logg... |
Turn on logging and add a handler which prints to stderr
| log_to_stderr | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/util.py | MIT |
def __call__(self, wr=None):
'''
Run the callback unless it has already been called or cancelled
'''
try:
del _finalizer_registry[self._key]
except KeyError:
sub_debug('finalizer no longer registered')
else:
if self._pid != os.getpid():... |
Run the callback unless it has already been called or cancelled
| __call__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/util.py | MIT |
def _run_finalizers(minpriority=None):
'''
Run all finalizers whose exit priority is not None and at least minpriority
Finalizers with highest priority are called first; finalizers with
the same priority will be called in reverse order of creation.
'''
if _finalizer_registry is None:
# ... |
Run all finalizers whose exit priority is not None and at least minpriority
Finalizers with highest priority are called first; finalizers with
the same priority will be called in reverse order of creation.
| _run_finalizers | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/util.py | MIT |
def Manager():
'''
Returns a manager associated with a running server process
The managers methods such as `Lock()`, `Condition()` and `Queue()`
can be used to create shared objects.
'''
from multiprocessing.managers import SyncManager
m = SyncManager()
m.start()
return m |
Returns a manager associated with a running server process
The managers methods such as `Lock()`, `Condition()` and `Queue()`
can be used to create shared objects.
| Manager | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/__init__.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/__init__.py | MIT |
def cpu_count():
'''
Returns the number of CPUs in the system
'''
if sys.platform == 'win32':
try:
num = int(os.environ['NUMBER_OF_PROCESSORS'])
except (ValueError, KeyError):
num = 0
elif 'bsd' in sys.platform or sys.platform == 'darwin':
comm = '/sbi... |
Returns the number of CPUs in the system
| cpu_count | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/__init__.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/__init__.py | MIT |
def freeze_support():
'''
Check whether this is a fake forked process in a frozen executable.
If so then run code specified by commandline and exit.
'''
if sys.platform == 'win32' and getattr(sys, 'frozen', False):
from multiprocessing.forking import freeze_support
freeze_support() |
Check whether this is a fake forked process in a frozen executable.
If so then run code specified by commandline and exit.
| freeze_support | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/multiprocessing/__init__.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/multiprocessing/__init__.py | MIT |
def _iterdump(connection):
"""
Returns an iterator to the dump of the database in an SQL text format.
Used to produce an SQL dump of the database. Useful to save an in-memory
database for later restoration. This function should not be called
directly but instead called from the Connection method,... |
Returns an iterator to the dump of the database in an SQL text format.
Used to produce an SQL dump of the database. Useful to save an in-memory
database for later restoration. This function should not be called
directly but instead called from the Connection method, iterdump().
| _iterdump | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/sqlite3/dump.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/sqlite3/dump.py | MIT |
def skipIf(condition, reason):
"""
Skip a test if the condition is true.
"""
if condition:
return skip(reason)
return _id |
Skip a test if the condition is true.
| skipIf | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def skipUnless(condition, reason):
"""
Skip a test unless the condition is true.
"""
if not condition:
return skip(reason)
return _id |
Skip a test unless the condition is true.
| skipUnless | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def __init__(self, methodName='runTest'):
"""Create an instance of the class that will use the named test
method when executed. Raises a ValueError if the instance does
not have a method with the specified name.
"""
self._testMethodName = methodName
self._resultForD... | Create an instance of the class that will use the named test
method when executed. Raises a ValueError if the instance does
not have a method with the specified name.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def shortDescription(self):
"""Returns a one-line description of the test, or None if no
description has been provided.
The default implementation of this method returns the first line of
the specified test method's docstring.
"""
doc = self._testMethodDoc
return... | Returns a one-line description of the test, or None if no
description has been provided.
The default implementation of this method returns the first line of
the specified test method's docstring.
| shortDescription | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def doCleanups(self):
"""Execute all cleanup functions. Normally called for you after
tearDown."""
result = self._resultForDoCleanups
ok = True
while self._cleanups:
function, args, kwargs = self._cleanups.pop(-1)
try:
function(*args, **kwa... | Execute all cleanup functions. Normally called for you after
tearDown. | doCleanups | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def debug(self):
"""Run the test without collecting errors in a TestResult"""
self.setUp()
getattr(self, self._testMethodName)()
self.tearDown()
while self._cleanups:
function, args, kwargs = self._cleanups.pop(-1)
function(*args, **kwargs) | Run the test without collecting errors in a TestResult | debug | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertFalse(self, expr, msg=None):
"""Check that the expression is false."""
if expr:
msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
raise self.failureException(msg) | Check that the expression is false. | assertFalse | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertTrue(self, expr, msg=None):
"""Check that the expression is true."""
if not expr:
msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
raise self.failureException(msg) | Check that the expression is true. | assertTrue | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def _formatMessage(self, msg, standardMsg):
"""Honour the longMessage attribute when generating failure messages.
If longMessage is False this means:
* Use only an explicit message if it is provided
* Otherwise use the standard message for the assert
If longMessage is True:
... | Honour the longMessage attribute when generating failure messages.
If longMessage is False this means:
* Use only an explicit message if it is provided
* Otherwise use the standard message for the assert
If longMessage is True:
* Use the standard message
* If an explicit... | _formatMessage | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def _getAssertEqualityFunc(self, first, second):
"""Get a detailed comparison function for the types of the two args.
Returns: A callable accepting (first, second, msg=None) that will
raise a failure exception if first != second with a useful human
readable error message for those types... | Get a detailed comparison function for the types of the two args.
Returns: A callable accepting (first, second, msg=None) that will
raise a failure exception if first != second with a useful human
readable error message for those types.
| _getAssertEqualityFunc | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def _baseAssertEqual(self, first, second, msg=None):
"""The default assertEqual implementation, not type specific."""
if not first == second:
standardMsg = '%s != %s' % (safe_repr(first), safe_repr(second))
msg = self._formatMessage(msg, standardMsg)
raise self.failur... | The default assertEqual implementation, not type specific. | _baseAssertEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertEqual(self, first, second, msg=None):
"""Fail if the two objects are unequal as determined by the '=='
operator.
"""
assertion_func = self._getAssertEqualityFunc(first, second)
assertion_func(first, second, msg=msg) | Fail if the two objects are unequal as determined by the '=='
operator.
| assertEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertNotEqual(self, first, second, msg=None):
"""Fail if the two objects are equal as determined by the '!='
operator.
"""
if not first != second:
msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
... | Fail if the two objects are equal as determined by the '!='
operator.
| assertNotEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertAlmostEqual(self, first, second, places=None, msg=None, delta=None):
"""Fail if the two objects are unequal as determined by their
difference rounded to the given number of decimal places
(default 7) and comparing to zero, or by comparing that the
between the two objec... | Fail if the two objects are unequal as determined by their
difference rounded to the given number of decimal places
(default 7) and comparing to zero, or by comparing that the
between the two objects is more than the given delta.
Note that decimal places (from zero) are usua... | assertAlmostEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertNotAlmostEqual(self, first, second, places=None, msg=None, delta=None):
"""Fail if the two objects are equal as determined by their
difference rounded to the given number of decimal places
(default 7) and comparing to zero, or by comparing that the
between the two obje... | Fail if the two objects are equal as determined by their
difference rounded to the given number of decimal places
(default 7) and comparing to zero, or by comparing that the
between the two objects is less than the given delta.
Note that decimal places (from zero) are usuall... | assertNotAlmostEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
"""An equality assertion for ordered sequences (like lists and tuples).
For the purposes of this function, a valid ordered sequence type is one
which can be indexed, has a length, and has an equality operator.
Args:
... | An equality assertion for ordered sequences (like lists and tuples).
For the purposes of this function, a valid ordered sequence type is one
which can be indexed, has a length, and has an equality operator.
Args:
seq1: The first sequence to compare.
seq2: The second seq... | assertSequenceEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertSetEqual(self, set1, set2, msg=None):
"""A set-specific equality assertion.
Args:
set1: The first set to compare.
set2: The second set to compare.
msg: Optional message to use on failure instead of a list of
differences.
assertS... | A set-specific equality assertion.
Args:
set1: The first set to compare.
set2: The second set to compare.
msg: Optional message to use on failure instead of a list of
differences.
assertSetEqual uses ducktyping to support different types of sets,... | assertSetEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertIn(self, member, container, msg=None):
"""Just like self.assertTrue(a in b), but with a nicer default message."""
if member not in container:
standardMsg = '%s not found in %s' % (safe_repr(member),
safe_repr(container))
... | Just like self.assertTrue(a in b), but with a nicer default message. | assertIn | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertNotIn(self, member, container, msg=None):
"""Just like self.assertTrue(a not in b), but with a nicer default message."""
if member in container:
standardMsg = '%s unexpectedly found in %s' % (safe_repr(member),
safe_repr(conta... | Just like self.assertTrue(a not in b), but with a nicer default message. | assertNotIn | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertIs(self, expr1, expr2, msg=None):
"""Just like self.assertTrue(a is b), but with a nicer default message."""
if expr1 is not expr2:
standardMsg = '%s is not %s' % (safe_repr(expr1),
safe_repr(expr2))
self.fail(self._formatMes... | Just like self.assertTrue(a is b), but with a nicer default message. | assertIs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertIsNot(self, expr1, expr2, msg=None):
"""Just like self.assertTrue(a is not b), but with a nicer default message."""
if expr1 is expr2:
standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
self.fail(self._formatMessage(msg, standardMsg)) | Just like self.assertTrue(a is not b), but with a nicer default message. | assertIsNot | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertDictContainsSubset(self, expected, actual, msg=None):
"""Checks whether actual is a superset of expected."""
missing = []
mismatched = []
for key, value in expected.iteritems():
if key not in actual:
missing.append(key)
elif value != actu... | Checks whether actual is a superset of expected. | assertDictContainsSubset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertItemsEqual(self, expected_seq, actual_seq, msg=None):
"""An unordered sequence specific comparison. It asserts that
actual_seq and expected_seq have the same element counts.
Equivalent to::
self.assertEqual(Counter(iter(actual_seq)),
Counter(it... | An unordered sequence specific comparison. It asserts that
actual_seq and expected_seq have the same element counts.
Equivalent to::
self.assertEqual(Counter(iter(actual_seq)),
Counter(iter(expected_seq)))
Asserts that each element has the same count in... | assertItemsEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertMultiLineEqual(self, first, second, msg=None):
"""Assert that two multi-line strings are equal."""
self.assertIsInstance(first, basestring,
'First argument is not a string')
self.assertIsInstance(second, basestring,
'Second argument is not a string')
... | Assert that two multi-line strings are equal. | assertMultiLineEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertLess(self, a, b, msg=None):
"""Just like self.assertTrue(a < b), but with a nicer default message."""
if not a < b:
standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg)) | Just like self.assertTrue(a < b), but with a nicer default message. | assertLess | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertLessEqual(self, a, b, msg=None):
"""Just like self.assertTrue(a <= b), but with a nicer default message."""
if not a <= b:
standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg)) | Just like self.assertTrue(a <= b), but with a nicer default message. | assertLessEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertGreater(self, a, b, msg=None):
"""Just like self.assertTrue(a > b), but with a nicer default message."""
if not a > b:
standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg)) | Just like self.assertTrue(a > b), but with a nicer default message. | assertGreater | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertGreaterEqual(self, a, b, msg=None):
"""Just like self.assertTrue(a >= b), but with a nicer default message."""
if not a >= b:
standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg)) | Just like self.assertTrue(a >= b), but with a nicer default message. | assertGreaterEqual | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertIsNone(self, obj, msg=None):
"""Same as self.assertTrue(obj is None), with a nicer default message."""
if obj is not None:
standardMsg = '%s is not None' % (safe_repr(obj),)
self.fail(self._formatMessage(msg, standardMsg)) | Same as self.assertTrue(obj is None), with a nicer default message. | assertIsNone | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertIsInstance(self, obj, cls, msg=None):
"""Same as self.assertTrue(isinstance(obj, cls)), with a nicer
default message."""
if not isinstance(obj, cls):
standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
self.fail(self._formatMessage(msg, standardM... | Same as self.assertTrue(isinstance(obj, cls)), with a nicer
default message. | assertIsInstance | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertRaisesRegexp(self, expected_exception, expected_regexp,
callable_obj=None, *args, **kwargs):
"""Asserts that the message in a raised exception matches a regexp.
Args:
expected_exception: Exception class expected to be raised.
expected_regexp:... | Asserts that the message in a raised exception matches a regexp.
Args:
expected_exception: Exception class expected to be raised.
expected_regexp: Regexp (re pattern object or string) expected
to be found in error message.
callable_obj: Function to be cal... | assertRaisesRegexp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertRegexpMatches(self, text, expected_regexp, msg=None):
"""Fail the test unless the text matches the regular expression."""
if isinstance(expected_regexp, basestring):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(text):
msg = msg or ... | Fail the test unless the text matches the regular expression. | assertRegexpMatches | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
"""Fail the test if the text matches the regular expression."""
if isinstance(unexpected_regexp, basestring):
unexpected_regexp = re.compile(unexpected_regexp)
match = unexpected_regexp.search(text)
if match... | Fail the test if the text matches the regular expression. | assertNotRegexpMatches | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/case.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/case.py | MIT |
def loadTestsFromTestCase(self, testCaseClass):
"""Return a suite of all tests cases contained in testCaseClass"""
if issubclass(testCaseClass, suite.TestSuite):
raise TypeError("Test cases should not be derived from TestSuite." \
" Maybe you meant to derive f... | Return a suite of all tests cases contained in testCaseClass | loadTestsFromTestCase | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/loader.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/loader.py | MIT |
def loadTestsFromModule(self, module, use_load_tests=True):
"""Return a suite of all tests cases contained in the given module"""
tests = []
for name in dir(module):
obj = getattr(module, name)
if isinstance(obj, type) and issubclass(obj, case.TestCase):
t... | Return a suite of all tests cases contained in the given module | loadTestsFromModule | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/loader.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/loader.py | MIT |
def loadTestsFromName(self, name, module=None):
"""Return a suite of all tests cases given a string specifier.
The name may resolve either to a module, a test case class, a
test method within a test case class, or a callable object which
returns a TestCase or TestSuite instance.
... | Return a suite of all tests cases given a string specifier.
The name may resolve either to a module, a test case class, a
test method within a test case class, or a callable object which
returns a TestCase or TestSuite instance.
The method optionally resolves the names relative to a gi... | loadTestsFromName | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/loader.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/loader.py | MIT |
def getTestCaseNames(self, testCaseClass):
"""Return a sorted sequence of method names found within testCaseClass
"""
def isTestMethod(attrname, testCaseClass=testCaseClass,
prefix=self.testMethodPrefix):
return attrname.startswith(prefix) and \
... | Return a sorted sequence of method names found within testCaseClass
| getTestCaseNames | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/loader.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/loader.py | MIT |
def discover(self, start_dir, pattern='test*.py', top_level_dir=None):
"""Find and return all test modules from the specified start
directory, recursing into subdirectories to find them. Only test files
that match the pattern will be loaded. (Using shell style pattern
matching.)
... | Find and return all test modules from the specified start
directory, recursing into subdirectories to find them. Only test files
that match the pattern will be loaded. (Using shell style pattern
matching.)
All test modules must be importable from the top level of the project.
If... | discover | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/loader.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/loader.py | MIT |
def _find_tests(self, start_dir, pattern):
"""Used by discovery. Yields test suites it loads."""
paths = os.listdir(start_dir)
for path in paths:
full_path = os.path.join(start_dir, path)
if os.path.isfile(full_path):
if not VALID_MODULE_NAME.match(path):... | Used by discovery. Yields test suites it loads. | _find_tests | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/loader.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/loader.py | MIT |
def startTest(self, test):
"Called when the given test is about to be run"
self.testsRun += 1
self._mirrorOutput = False
self._setupStdout() | Called when the given test is about to be run | startTest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def startTestRun(self):
"""Called once before any tests are executed.
See startTest for a method called before each test.
""" | Called once before any tests are executed.
See startTest for a method called before each test.
| startTestRun | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def stopTest(self, test):
"""Called when the given test has been run"""
self._restoreStdout()
self._mirrorOutput = False | Called when the given test has been run | stopTest | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def stopTestRun(self):
"""Called once after all tests are executed.
See stopTest for a method called after each test.
""" | Called once after all tests are executed.
See stopTest for a method called after each test.
| stopTestRun | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def addError(self, test, err):
"""Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().
"""
self.errors.append((test, self._exc_info_to_string(err, test)))
self._mirrorOutput = True | Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().
| addError | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def addFailure(self, test, err):
"""Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info()."""
self.failures.append((test, self._exc_info_to_string(err, test)))
self._mirrorOutput = True | Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info(). | addFailure | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def addExpectedFailure(self, test, err):
"""Called when an expected failure/error occurred."""
self.expectedFailures.append(
(test, self._exc_info_to_string(err, test))) | Called when an expected failure/error occurred. | addExpectedFailure | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def wasSuccessful(self):
"Tells whether or not this result was a success"
return len(self.failures) == len(self.errors) == 0 | Tells whether or not this result was a success | wasSuccessful | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def stop(self):
"Indicates that the tests should be aborted"
self.shouldStop = True | Indicates that the tests should be aborted | stop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def _exc_info_to_string(self, err, test):
"""Converts a sys.exc_info()-style tuple of values into a string."""
exctype, value, tb = err
# Skip test runner traceback levels
while tb and self._is_relevant_tb_level(tb):
tb = tb.tb_next
if exctype is test.failureExceptio... | Converts a sys.exc_info()-style tuple of values into a string. | _exc_info_to_string | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/result.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/result.py | MIT |
def run(self, test):
"Run the given test case or test suite."
result = self._makeResult()
registerResult(result)
result.failfast = self.failfast
result.buffer = self.buffer
startTime = time.time()
startTestRun = getattr(result, 'startTestRun', None)
if sta... | Run the given test case or test suite. | run | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/runner.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/runner.py | MIT |
def _isnotsuite(test):
"A crude way to tell apart testcases and suites with duck-typing"
try:
iter(test)
except TypeError:
return True
return False | A crude way to tell apart testcases and suites with duck-typing | _isnotsuite | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/suite.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/suite.py | MIT |
def sorted_list_difference(expected, actual):
"""Finds elements in only one or the other of two, sorted input lists.
Returns a two-element tuple of lists. The first list contains those
elements in the "expected" list but not in the "actual" list, and the
second contains those elements in the "actual... | Finds elements in only one or the other of two, sorted input lists.
Returns a two-element tuple of lists. The first list contains those
elements in the "expected" list but not in the "actual" list, and the
second contains those elements in the "actual" list but not in the
"expected" list. Duplica... | sorted_list_difference | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/util.py | MIT |
def unorderable_list_difference(expected, actual, ignore_duplicate=False):
"""Same behavior as sorted_list_difference but
for lists of unorderable items (like dicts).
As it does a linear search per item (remove) it
has O(n*n) performance.
"""
missing = []
unexpected = []
while expected:... | Same behavior as sorted_list_difference but
for lists of unorderable items (like dicts).
As it does a linear search per item (remove) it
has O(n*n) performance.
| unorderable_list_difference | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/util.py | MIT |
def _count_diff_all_purpose(actual, expected):
'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
# elements need not be hashable
s, t = list(actual), list(expected)
m, n = len(s), len(t)
NULL = object()
result = []
for i, elem in enumerate(s):
if elem is NULL... | Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ | _count_diff_all_purpose | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/util.py | MIT |
def _ordered_count(iterable):
'Return dict of element counts, in the order they were first seen'
c = OrderedDict()
for elem in iterable:
c[elem] = c.get(elem, 0) + 1
return c | Return dict of element counts, in the order they were first seen | _ordered_count | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/util.py | MIT |
def _count_diff_hashable(actual, expected):
'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
# elements must be hashable
s, t = _ordered_count(actual), _ordered_count(expected)
result = []
for elem, cnt_s in s.items():
cnt_t = t.get(elem, 0)
if cnt_s != cnt_... | Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ | _count_diff_hashable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/unittest/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/unittest/util.py | MIT |
def setup_environ(self):
"""Set up the environment for one request"""
env = self.environ = self.os_environ.copy()
self.add_cgi_vars()
env['wsgi.input'] = self.get_stdin()
env['wsgi.errors'] = self.get_stderr()
env['wsgi.version'] = self.wsgi_version
... | Set up the environment for one request | setup_environ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def finish_response(self):
"""Send any iterable data, then close self and the iterable
Subclasses intended for use in asynchronous servers will
want to redefine this method, such that it sets up callbacks
in the event loop to iterate over the data, and to call
'self.close()' onc... | Send any iterable data, then close self and the iterable
Subclasses intended for use in asynchronous servers will
want to redefine this method, such that it sets up callbacks
in the event loop to iterate over the data, and to call
'self.close()' once the response is finished.
| finish_response | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def set_content_length(self):
"""Compute Content-Length or switch to chunked encoding if possible"""
try:
blocks = len(self.result)
except (TypeError,AttributeError,NotImplementedError):
pass
else:
if blocks==1:
self.headers['Content-Le... | Compute Content-Length or switch to chunked encoding if possible | set_content_length | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def write(self, data):
"""'write()' callable as specified by PEP 333"""
assert type(data) is StringType,"write() argument must be string"
if not self.status:
raise AssertionError("write() before start_response()")
elif not self.headers_sent:
# Before the first ... | 'write()' callable as specified by PEP 333 | write | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def finish_content(self):
"""Ensure headers and content have both been sent"""
if not self.headers_sent:
# Only zero Content-Length if not set by the application (so
# that HEAD requests can be satisfied properly, see #3839)
self.headers.setdefault('Content-Length', "... | Ensure headers and content have both been sent | finish_content | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def close(self):
"""Close the iterable (if needed) and reset all instance vars
Subclasses may want to also drop the client connection.
"""
try:
if hasattr(self.result,'close'):
self.result.close()
finally:
self.result = self.headers = self... | Close the iterable (if needed) and reset all instance vars
Subclasses may want to also drop the client connection.
| close | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def result_is_file(self):
"""True if 'self.result' is an instance of 'self.wsgi_file_wrapper'"""
wrapper = self.wsgi_file_wrapper
return wrapper is not None and isinstance(self.result,wrapper) | True if 'self.result' is an instance of 'self.wsgi_file_wrapper' | result_is_file | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def log_exception(self,exc_info):
"""Log the 'exc_info' tuple in the server log
Subclasses may override to retarget the output or change its format.
"""
try:
from traceback import print_exception
stderr = self.get_stderr()
print_exception(
... | Log the 'exc_info' tuple in the server log
Subclasses may override to retarget the output or change its format.
| log_exception | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def handle_error(self):
"""Log current error, and send error output to client if possible"""
self.log_exception(sys.exc_info())
if not self.headers_sent:
self.result = self.error_output(self.environ, self.start_response)
self.finish_response()
# XXX else: attempt ... | Log current error, and send error output to client if possible | handle_error | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/handlers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/handlers.py | MIT |
def _formatparam(param, value=None, quote=1):
"""Convenience function to format and return a key=value pair.
This will quote the value if needed or if quote is true.
"""
if value is not None and len(value) > 0:
if quote or tspecials.search(value):
value = value.replace('\\', '\\\\')... | Convenience function to format and return a key=value pair.
This will quote the value if needed or if quote is true.
| _formatparam | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/headers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/headers.py | MIT |
def __delitem__(self,name):
"""Delete all occurrences of a header, if present.
Does *not* raise an exception if the header is missing.
"""
name = name.lower()
self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name] | Delete all occurrences of a header, if present.
Does *not* raise an exception if the header is missing.
| __delitem__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/headers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/headers.py | MIT |
def get_all(self, name):
"""Return a list of all the values for the named field.
These will be sorted in the order they appeared in the original header
list or were added to this instance, and may contain duplicates. Any
fields deleted and re-inserted are always appended to the header ... | Return a list of all the values for the named field.
These will be sorted in the order they appeared in the original header
list or were added to this instance, and may contain duplicates. Any
fields deleted and re-inserted are always appended to the header list.
If no fields exist wit... | get_all | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/headers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/headers.py | MIT |
def get(self,name,default=None):
"""Get the first header value for 'name', or return 'default'"""
name = name.lower()
for k,v in self._headers:
if k.lower()==name:
return v
return default | Get the first header value for 'name', or return 'default' | get | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/headers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/headers.py | MIT |
def setdefault(self,name,value):
"""Return first matching header value for 'name', or 'value'
If there is no header named 'name', add a new header with name 'name'
and value 'value'."""
result = self.get(name)
if result is None:
self._headers.append((name,value))
... | Return first matching header value for 'name', or 'value'
If there is no header named 'name', add a new header with name 'name'
and value 'value'. | setdefault | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/headers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/headers.py | MIT |
def add_header(self, _name, _value, **_params):
"""Extended header setting.
_name is the header field to add. keyword arguments can be used to set
additional parameters for the header field, with underscores converted
to dashes. Normally the parameter will be added as key="value" unle... | Extended header setting.
_name is the header field to add. keyword arguments can be used to set
additional parameters for the header field, with underscores converted
to dashes. Normally the parameter will be added as key="value" unless
value is None, in which case only the key will b... | add_header | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/headers.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/headers.py | MIT |
def make_server(
host, port, app, server_class=WSGIServer, handler_class=WSGIRequestHandler
):
"""Create a new WSGI server listening on `host` and `port` for `app`"""
server = server_class((host, port), handler_class)
server.set_app(app)
return server | Create a new WSGI server listening on `host` and `port` for `app` | make_server | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/simple_server.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/simple_server.py | MIT |
def guess_scheme(environ):
"""Return a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
"""
if environ.get("HTTPS") in ('yes','on','1'):
return 'https'
else:
return 'http' | Return a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
| guess_scheme | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/util.py | MIT |
def application_uri(environ):
"""Return the application's base URI (no PATH_INFO or QUERY_STRING)"""
url = environ['wsgi.url_scheme']+'://'
from urllib import quote
if environ.get('HTTP_HOST'):
url += environ['HTTP_HOST']
else:
url += environ['SERVER_NAME']
if environ['wsgi... | Return the application's base URI (no PATH_INFO or QUERY_STRING) | application_uri | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/util.py | MIT |
def request_uri(environ, include_query=1):
"""Return the full request URI, optionally including the query string"""
url = application_uri(environ)
from urllib import quote
path_info = quote(environ.get('PATH_INFO',''),safe='/;=,')
if not environ.get('SCRIPT_NAME'):
url += path_info[1:]
e... | Return the full request URI, optionally including the query string | request_uri | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/util.py | MIT |
def shift_path_info(environ):
"""Shift a name from PATH_INFO to SCRIPT_NAME, returning it
If there are no remaining path segments in PATH_INFO, return None.
Note: 'environ' is modified in-place; use a copy if you need to keep
the original PATH_INFO or SCRIPT_NAME.
Note: when PATH_INFO is just a '/... | Shift a name from PATH_INFO to SCRIPT_NAME, returning it
If there are no remaining path segments in PATH_INFO, return None.
Note: 'environ' is modified in-place; use a copy if you need to keep
the original PATH_INFO or SCRIPT_NAME.
Note: when PATH_INFO is just a '/', this returns '' and appends a trai... | shift_path_info | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/util.py | MIT |
def setup_testing_defaults(environ):
"""Update 'environ' with trivial defaults for testing purposes
This adds various parameters required for WSGI, including HTTP_HOST,
SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
and all of the wsgi.* variables. It only supplies default values,
... | Update 'environ' with trivial defaults for testing purposes
This adds various parameters required for WSGI, including HTTP_HOST,
SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
and all of the wsgi.* variables. It only supplies default values,
and does not replace any existing setting... | setup_testing_defaults | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/util.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/util.py | MIT |
def validator(application):
"""
When applied between a WSGI server and a WSGI application, this
middleware will check for WSGI compliancy on a number of levels.
This middleware does not modify the request or response in any
way, but will raise an AssertionError if anything seems off
(except for... |
When applied between a WSGI server and a WSGI application, this
middleware will check for WSGI compliancy on a number of levels.
This middleware does not modify the request or response in any
way, but will raise an AssertionError if anything seems off
(except for a failure to close the application ... | validator | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/wsgiref/validate.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/wsgiref/validate.py | MIT |
def _good_enough(dom, features):
"_good_enough(dom, features) -> Return 1 if the dom offers the features"
for f,v in features:
if not dom.hasFeature(f,v):
return 0
return 1 | _good_enough(dom, features) -> Return 1 if the dom offers the features | _good_enough | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/xml/dom/domreg.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/xml/dom/domreg.py | MIT |
def getDOMImplementation(name = None, features = ()):
"""getDOMImplementation(name = None, features = ()) -> DOM implementation.
Return a suitable DOM implementation. The name is either
well-known, the module name of a DOM implementation, or None. If
it is not None, imports the corresponding module and... | getDOMImplementation(name = None, features = ()) -> DOM implementation.
Return a suitable DOM implementation. The name is either
well-known, the module name of a DOM implementation, or None. If
it is not None, imports the corresponding module and returns
DOMImplementation object if the import succeeds.... | getDOMImplementation | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/xml/dom/domreg.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/xml/dom/domreg.py | MIT |
def getParser(self):
"""Return the parser object, creating a new one if needed."""
if not self._parser:
self._parser = self.createParser()
self._intern_setdefault = self._parser.intern.setdefault
self._parser.buffer_text = True
self._parser.ordered_attribu... | Return the parser object, creating a new one if needed. | getParser | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/xml/dom/expatbuilder.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/xml/dom/expatbuilder.py | MIT |
def reset(self):
"""Free all data structures used during DOM construction."""
self.document = theDOMImplementation.createDocument(
EMPTY_NAMESPACE, None, None)
self.curNode = self.document
self._elem_info = self.document._elem_info
self._cdata = False | Free all data structures used during DOM construction. | reset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/xml/dom/expatbuilder.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/xml/dom/expatbuilder.py | MIT |
def install(self, parser):
"""Install the callbacks needed to build the DOM into the parser."""
# This creates circular references!
parser.StartDoctypeDeclHandler = self.start_doctype_decl_handler
parser.StartElementHandler = self.first_element_handler
parser.EndElementHandler = ... | Install the callbacks needed to build the DOM into the parser. | install | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/xml/dom/expatbuilder.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/xml/dom/expatbuilder.py | MIT |
def parseFile(self, file):
"""Parse a document from a file object, returning the document
node."""
parser = self.getParser()
first_buffer = True
try:
while 1:
buffer = file.read(16*1024)
if not buffer:
break
... | Parse a document from a file object, returning the document
node. | parseFile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/xml/dom/expatbuilder.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/xml/dom/expatbuilder.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 Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
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.