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 _writecheck(self, zinfo):
"""Check for errors before writing a file to the archive."""
if zinfo.filename in self.NameToInfo:
import warnings
warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3)
if self.mode not in ("w", "a"):
raise RuntimeErr... | Check for errors before writing a file to the archive. | _writecheck | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/zipfile.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/zipfile.py | MIT |
def write(self, filename, arcname=None, compress_type=None):
"""Put the bytes from filename into the archive under the name
arcname."""
if not self.fp:
raise RuntimeError(
"Attempt to write to ZIP archive that was already closed")
st = os.stat(filename)
... | Put the bytes from filename into the archive under the name
arcname. | write | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/zipfile.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/zipfile.py | MIT |
def writestr(self, zinfo_or_arcname, bytes, compress_type=None):
"""Write a file into the archive. The contents is the string
'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive."""
if not isinstance(zinfo_or_arcname, ZipInfo):
zi... | Write a file into the archive. The contents is the string
'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive. | writestr | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/zipfile.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/zipfile.py | MIT |
def close(self):
"""Close the file, and for mode "w" and "a" write the ending
records."""
if self.fp is None:
return
try:
if self.mode in ("w", "a") and self._didModify: # write ending records
pos1 = self.fp.tell()
for zinfo in sel... | Close the file, and for mode "w" and "a" write the ending
records. | close | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/zipfile.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/zipfile.py | MIT |
def writepy(self, pathname, basename = ""):
"""Add all files from "pathname" to the ZIP archive.
If pathname is a package directory, search the directory and
all package subdirectories recursively for all *.py and enter
the modules into the archive. If pathname is a plain
direc... | Add all files from "pathname" to the ZIP archive.
If pathname is a package directory, search the directory and
all package subdirectories recursively for all *.py and enter
the modules into the archive. If pathname is a plain
directory, listdir *.py and enter all modules. Else, pathna... | writepy | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/zipfile.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/zipfile.py | MIT |
def _get_codename(self, pathname, basename):
"""Return (filename, archivename) for the path.
Given a module name path, return the correct file path and
archive name, compiling if necessary. For example, given
/python/lib/string, return (/python/lib/string.pyc, string).
"""
... | Return (filename, archivename) for the path.
Given a module name path, return the correct file path and
archive name, compiling if necessary. For example, given
/python/lib/string, return (/python/lib/string.pyc, string).
| _get_codename | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/zipfile.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/zipfile.py | MIT |
def isdisjoint(self, other):
'Return True if two sets have a null intersection.'
for value in other:
if value in self:
return False
return True | Return True if two sets have a null intersection. | isdisjoint | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def _hash(self):
"""Compute the hash value of a set.
Note that we don't define __hash__: not all sets are hashable.
But if you define a hashable set type, its __hash__ should
call this function.
This must be compatible __eq__.
All sets ought to compare equal if they co... | Compute the hash value of a set.
Note that we don't define __hash__: not all sets are hashable.
But if you define a hashable set type, its __hash__ should
call this function.
This must be compatible __eq__.
All sets ought to compare equal if they contain the same
eleme... | _hash | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def remove(self, value):
"""Remove an element. If not a member, raise a KeyError."""
if value not in self:
raise KeyError(value)
self.discard(value) | Remove an element. If not a member, raise a KeyError. | remove | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def pop(self):
"""Return the popped value. Raise KeyError if empty."""
it = iter(self)
try:
value = next(it)
except StopIteration:
raise KeyError
self.discard(value)
return value | Return the popped value. Raise KeyError if empty. | pop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def clear(self):
"""This is slow (creates N new iterators!) but effective."""
try:
while True:
self.pop()
except KeyError:
pass | This is slow (creates N new iterators!) but effective. | clear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def get(self, key, default=None):
'D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.'
try:
return self[key]
except KeyError:
return default | D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. | get | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def itervalues(self):
'D.itervalues() -> an iterator over the values of D'
for key in self:
yield self[key] | D.itervalues() -> an iterator over the values of D | itervalues | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def iteritems(self):
'D.iteritems() -> an iterator over the (key, value) items of D'
for key in self:
yield (key, self[key]) | D.iteritems() -> an iterator over the (key, value) items of D | iteritems | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def items(self):
"D.items() -> list of D's (key, value) pairs, as 2-tuples"
return [(key, self[key]) for key in self] | D.items() -> list of D's (key, value) pairs, as 2-tuples | items | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def pop(self, key, default=__marker):
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
'''
try:
value = self[key]
except KeyError:
if default is self... | D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
| pop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def popitem(self):
'''D.popitem() -> (k, v), remove and return some (key, value) pair
as a 2-tuple; but raise KeyError if D is empty.
'''
try:
key = next(iter(self))
except StopIteration:
raise KeyError
value = self[key]
del self[key]
... | D.popitem() -> (k, v), remove and return some (key, value) pair
as a 2-tuple; but raise KeyError if D is empty.
| popitem | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def clear(self):
'D.clear() -> None. Remove all items from D.'
try:
while True:
self.popitem()
except KeyError:
pass | D.clear() -> None. Remove all items from D. | clear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def update(*args, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is foll... | D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] =... | update | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def setdefault(self, key, default=None):
'D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D'
try:
return self[key]
except KeyError:
self[key] = default
return default | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D | setdefault | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def index(self, value):
'''S.index(value) -> integer -- return first index of value.
Raises ValueError if the value is not present.
'''
for i, v in enumerate(self):
if v == value:
return i
raise ValueError | S.index(value) -> integer -- return first index of value.
Raises ValueError if the value is not present.
| index | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def count(self, value):
'S.count(value) -> integer -- return number of occurrences of value'
return sum(1 for v in self if v == value) | S.count(value) -> integer -- return number of occurrences of value | count | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def extend(self, values):
'S.extend(iterable) -- extend sequence by appending elements from the iterable'
for v in values:
self.append(v) | S.extend(iterable) -- extend sequence by appending elements from the iterable | extend | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def pop(self, index=-1):
'''S.pop([index]) -> item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
'''
v = self[index]
del self[index]
return v | S.pop([index]) -> item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
| pop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_abcoll.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_abcoll.py | MIT |
def lwp_cookie_str(cookie):
"""Return string representation of Cookie in the LWP cookie file format.
Actually, the format is extended a bit -- see module docstring.
"""
h = [(cookie.name, cookie.value),
("path", cookie.path),
("domain", cookie.domain)]
if cookie.port is not None:... | Return string representation of Cookie in the LWP cookie file format.
Actually, the format is extended a bit -- see module docstring.
| lwp_cookie_str | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_LWPCookieJar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_LWPCookieJar.py | MIT |
def as_lwp_str(self, ignore_discard=True, ignore_expires=True):
"""Return cookies as a string of "\\n"-separated "Set-Cookie3" headers.
ignore_discard and ignore_expires: see docstring for FileCookieJar.save
"""
now = time.time()
r = []
for cookie in self:
i... | Return cookies as a string of "\n"-separated "Set-Cookie3" headers.
ignore_discard and ignore_expires: see docstring for FileCookieJar.save
| as_lwp_str | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_LWPCookieJar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_LWPCookieJar.py | MIT |
def _find_executable(executable, path=None):
"""Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
"""
if path is None:
path = os.environ... | Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
| _find_executable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _read_output(commandstring):
"""Output from successful command execution or None"""
# Similar to os.popen(commandstring, "r").read(),
# but without actually using os.popen because that
# function is not usable during python bootstrap.
# tempfile is also not available then.
import contextlib
... | Output from successful command execution or None | _read_output | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _find_build_tool(toolname):
"""Find a build tool on current path or using xcrun"""
return (_find_executable(toolname)
or _read_output("/usr/bin/xcrun -find %s" % (toolname,))
or ''
) | Find a build tool on current path or using xcrun | _find_build_tool | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _get_system_version():
"""Return the OS X system version as a string"""
# Reading this plist is a documented way to get the system
# version (see the documentation for the Gestalt Manager)
# We avoid using platform.mac_ver to avoid possible bootstrap issues during
# the build of Python itself (d... | Return the OS X system version as a string | _get_system_version | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _remove_original_values(_config_vars):
"""Remove original unmodified values for testing"""
# This is needed for higher-level cross-platform tests of get_platform.
for k in list(_config_vars):
if k.startswith(_INITPRE):
del _config_vars[k] | Remove original unmodified values for testing | _remove_original_values | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _save_modified_value(_config_vars, cv, newvalue):
"""Save modified and original unmodified value of configuration var"""
oldvalue = _config_vars.get(cv, '')
if (oldvalue != newvalue) and (_INITPRE + cv not in _config_vars):
_config_vars[_INITPRE + cv] = oldvalue
_config_vars[cv] = newvalue | Save modified and original unmodified value of configuration var | _save_modified_value | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _supports_universal_builds():
"""Returns True if universal builds are supported on this system"""
# As an approximation, we assume that if we are running on 10.4 or above,
# then we are running with an Xcode environment that supports universal
# builds, in particular -isysroot and -arch arguments to... | Returns True if universal builds are supported on this system | _supports_universal_builds | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _find_appropriate_compiler(_config_vars):
"""Find appropriate C compiler for extension module builds"""
# Issue #13590:
# The OSX location for the compiler varies between OSX
# (or rather Xcode) releases. With older releases (up-to 10.5)
# the compiler is in /usr/bin, with newer relea... | Find appropriate C compiler for extension module builds | _find_appropriate_compiler | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _remove_universal_flags(_config_vars):
"""Remove all universal build arguments from config vars"""
for cv in _UNIVERSAL_CONFIG_VARS:
# Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
... | Remove all universal build arguments from config vars | _remove_universal_flags | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _remove_unsupported_archs(_config_vars):
"""Remove any unsupported archs from config vars"""
# Different Xcode releases support different sets for '-arch'
# flags. In particular, Xcode 4.x no longer supports the
# PPC architectures.
#
# This code automatically removes '-arch ppc' and '-arch ... | Remove any unsupported archs from config vars | _remove_unsupported_archs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _override_all_archs(_config_vars):
"""Allow override of all archs with ARCHFLAGS env var"""
# NOTE: This name was introduced by Apple in OSX 10.5 and
# is used by several scripting languages distributed with
# that OS release.
if 'ARCHFLAGS' in os.environ:
arch = os.environ['ARCHFLAGS']
... | Allow override of all archs with ARCHFLAGS env var | _override_all_archs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def _check_for_unavailable_sdk(_config_vars):
"""Remove references to any SDKs not available"""
# If we're on OSX 10.5 or later and the user tries to
# compile an extension using an SDK that is not present
# on the current machine it is better to not use an SDK
# than to fail. This is particularly ... | Remove references to any SDKs not available | _check_for_unavailable_sdk | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def compiler_fixup(compiler_so, cc_args):
"""
This function will strip '-isysroot PATH' and '-arch ARCH' from the
compile flags if the user has specified one them in extra_compile_flags.
This is needed because '-arch ARCH' adds another architecture to the
build, without a way to remove an architect... |
This function will strip '-isysroot PATH' and '-arch ARCH' from the
compile flags if the user has specified one them in extra_compile_flags.
This is needed because '-arch ARCH' adds another architecture to the
build, without a way to remove an architecture. Furthermore GCC will
barf if multiple '-... | compiler_fixup | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def customize_config_vars(_config_vars):
"""Customize Python build configuration variables.
Called internally from sysconfig with a mutable mapping
containing name/value pairs parsed from the configured
makefile used to build this interpreter. Returns
the mapping updated as needed to reflect the e... | Customize Python build configuration variables.
Called internally from sysconfig with a mutable mapping
containing name/value pairs parsed from the configured
makefile used to build this interpreter. Returns
the mapping updated as needed to reflect the environment
in which the interpreter is runni... | customize_config_vars | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def customize_compiler(_config_vars):
"""Customize compiler path and configuration variables.
This customization is performed when the first
extension module build is requested
in distutils.sysconfig.customize_compiler).
"""
# Find a compiler to use for extension module builds
_find_approp... | Customize compiler path and configuration variables.
This customization is performed when the first
extension module build is requested
in distutils.sysconfig.customize_compiler).
| customize_compiler | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_osx_support.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_osx_support.py | MIT |
def flush(self):
"""Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
"""
self._checkClosed()
# XXX Should this return the number of bytes written??? | Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
| flush | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def close(self):
"""Flush and close the IO object.
This method has no effect if the file is already closed.
"""
if not self.__closed:
try:
self.flush()
finally:
self.__closed = True | Flush and close the IO object.
This method has no effect if the file is already closed.
| close | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def _checkSeekable(self, msg=None):
"""Internal: raise an IOError if file is not seekable
"""
if not self.seekable():
raise IOError("File or stream is not seekable."
if msg is None else msg) | Internal: raise an IOError if file is not seekable
| _checkSeekable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def _checkReadable(self, msg=None):
"""Internal: raise an IOError if file is not readable
"""
if not self.readable():
raise IOError("File or stream is not readable."
if msg is None else msg) | Internal: raise an IOError if file is not readable
| _checkReadable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def _checkWritable(self, msg=None):
"""Internal: raise an IOError if file is not writable
"""
if not self.writable():
raise IOError("File or stream is not writable."
if msg is None else msg) | Internal: raise an IOError if file is not writable
| _checkWritable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def _checkClosed(self, msg=None):
"""Internal: raise a ValueError if file is closed
"""
if self.closed:
raise ValueError("I/O operation on closed file."
if msg is None else msg) | Internal: raise a ValueError if file is closed
| _checkClosed | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def readlines(self, hint=None):
"""Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
"""
if hint is not None and not isin... | Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
| readlines | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def read(self, n=-1):
"""Read and return up to n bytes.
Returns an empty bytes object on EOF, or None if the object is
set not to block and has no data to read.
"""
if n is None:
n = -1
if n < 0:
return self.readall()
b = bytearray(n.__ind... | Read and return up to n bytes.
Returns an empty bytes object on EOF, or None if the object is
set not to block and has no data to read.
| read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def readall(self):
"""Read until EOF, using multiple read() call."""
res = bytearray()
while True:
data = self.read(DEFAULT_BUFFER_SIZE)
if not data:
break
res += data
if res:
return bytes(res)
else:
# b'... | Read until EOF, using multiple read() call. | readall | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def readinto(self, b):
"""Read up to len(b) bytes into b.
Like read(), this may issue multiple reads to the underlying raw
stream, unless the latter is 'interactive'.
Returns the number of bytes read (0 for EOF).
Raises BlockingIOError if the underlying raw stream has no
... | Read up to len(b) bytes into b.
Like read(), this may issue multiple reads to the underlying raw
stream, unless the latter is 'interactive'.
Returns the number of bytes read (0 for EOF).
Raises BlockingIOError if the underlying raw stream has no
data at the moment.
| readinto | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def getvalue(self):
"""Return the bytes value (contents) of the buffer
"""
if self.closed:
raise ValueError("getvalue on closed file")
return bytes(self._buffer) | Return the bytes value (contents) of the buffer
| getvalue | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def __init__(self, raw, buffer_size=DEFAULT_BUFFER_SIZE):
"""Create a new buffered reader using the given readable raw IO object.
"""
if not raw.readable():
raise IOError('"raw" argument must be readable.')
_BufferedIOMixin.__init__(self, raw)
if buffer_size <= 0:
... | Create a new buffered reader using the given readable raw IO object.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def read(self, n=None):
"""Read n bytes.
Returns exactly n bytes of data unless the underlying raw IO
stream reaches EOF or if the call would block in non-blocking
mode. If n is negative, read until EOF or until read() would
block.
"""
if n is not None and n < -1... | Read n bytes.
Returns exactly n bytes of data unless the underlying raw IO
stream reaches EOF or if the call would block in non-blocking
mode. If n is negative, read until EOF or until read() would
block.
| read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def read1(self, n):
"""Reads up to n bytes, with at most one read() system call."""
# Returns up to n bytes. If at least one byte is buffered, we
# only return buffered bytes. Otherwise, we do one raw read.
if n < 0:
raise ValueError("number of bytes to read must be positiv... | Reads up to n bytes, with at most one read() system call. | read1 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def __init__(self, reader, writer,
buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None):
"""Constructor.
The arguments are two RawIO instances.
"""
if max_buffer_size is not None:
warnings.warn("max_buffer_size is deprecated", DeprecationWarning, 2)
... | Constructor.
The arguments are two RawIO instances.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def _read_chunk(self):
"""
Read and decode the next chunk of data from the BufferedReader.
"""
# The return value is True unless EOF was reached. The decoded
# string is placed in self._decoded_chars (replacing its previous
# value). The entire input chunk is sent to t... |
Read and decode the next chunk of data from the BufferedReader.
| _read_chunk | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_pyio.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_pyio.py | MIT |
def __init__(self):
"""Set all attributes.
Order of methods called matters for dependency reasons.
The locale language is set at the offset and then checked again before
exiting. This is to make sure that the attributes were not set with a
mix of information from more than one... | Set all attributes.
Order of methods called matters for dependency reasons.
The locale language is set at the offset and then checked again before
exiting. This is to make sure that the attributes were not set with a
mix of information from more than one locale. This would most likel... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_strptime.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_strptime.py | MIT |
def __init__(self, locale_time=None):
"""Create keys/values.
Order of execution is important for dependency reasons.
"""
if locale_time:
self.locale_time = locale_time
else:
self.locale_time = LocaleTime()
base = super(TimeRE, self)
base.... | Create keys/values.
Order of execution is important for dependency reasons.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_strptime.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_strptime.py | MIT |
def __seqToRE(self, to_convert, directive):
"""Convert a list to a regex string for matching a directive.
Want possible matching values to be from longest to shortest. This
prevents the possibility of a match occurring for a value that also
a substring of a larger value that should hav... | Convert a list to a regex string for matching a directive.
Want possible matching values to be from longest to shortest. This
prevents the possibility of a match occurring for a value that also
a substring of a larger value that should have matched (e.g., 'abc'
matching when 'abcdef' s... | __seqToRE | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_strptime.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_strptime.py | MIT |
def pattern(self, format):
"""Return regex pattern for the format string.
Need to make sure that any characters that might be interpreted as
regex syntax are escaped.
"""
processed_format = ''
# The sub() call escapes all characters that might be misconstrued
# ... | Return regex pattern for the format string.
Need to make sure that any characters that might be interpreted as
regex syntax are escaped.
| pattern | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_strptime.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_strptime.py | MIT |
def _calc_julian_from_U_or_W(year, week_of_year, day_of_week, week_starts_Mon):
"""Calculate the Julian day based on the year, week of the year, and day of
the week, with week_start_day representing whether the week of the year
assumes the week starts on Sunday or Monday (6 or 0)."""
first_weekday = dat... | Calculate the Julian day based on the year, week of the year, and day of
the week, with week_start_day representing whether the week of the year
assumes the week starts on Sunday or Monday (6 or 0). | _calc_julian_from_U_or_W | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_strptime.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_strptime.py | MIT |
def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
"""Return a time struct based on the input string and the format string."""
global _TimeRE_cache, _regex_cache
with _cache_lock:
locale_time = _TimeRE_cache.locale_time
if (_getlang() != locale_time.lang or
time.tzname !=... | Return a time struct based on the input string and the format string. | _strptime | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/_strptime.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/_strptime.py | MIT |
def contains_metastrings(s) :
"""Verify that the given string does not contain any
metadata strings that might interfere with dbtables database operation.
"""
if (s.find(_table_names_key) >= 0 or
s.find(_columns) >= 0 or
s.find(_data) >= 0 or
s.find(_rowid) >= 0):
# Then
... | Verify that the given string does not contain any
metadata strings that might interfere with dbtables database operation.
| contains_metastrings | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def _db_print(self) :
"""Print the database to stdout for debugging"""
print "******** Printing raw database for debugging ********"
cur = self.db.cursor()
try:
key, data = cur.first()
while 1:
print repr({key: data})
next = cur.nex... | Print the database to stdout for debugging | _db_print | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def CreateTable(self, table, columns):
"""CreateTable(table, columns) - Create a new table in the database.
raises TableDBError if it already exists or for other DB errors.
"""
assert isinstance(columns, list)
txn = None
try:
# checking sanity of the table a... | CreateTable(table, columns) - Create a new table in the database.
raises TableDBError if it already exists or for other DB errors.
| CreateTable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def ListTableColumns(self, table):
"""Return a list of columns in the given table.
[] if the table doesn't exist.
"""
assert isinstance(table, str)
if contains_metastrings(table):
raise ValueError, "bad table name: contains reserved metastrings"
columnlist_ke... | Return a list of columns in the given table.
[] if the table doesn't exist.
| ListTableColumns | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def ListTables(self):
"""Return a list of tables in this database."""
pickledtablelist = self.db.get_get(_table_names_key)
if pickledtablelist:
return pickle.loads(pickledtablelist)
else:
return [] | Return a list of tables in this database. | ListTables | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def CreateOrExtendTable(self, table, columns):
"""CreateOrExtendTable(table, columns)
Create a new table in the database.
If a table of this name already exists, extend it to have any
additional columns present in the given list as well as
all of its current columns.
""... | CreateOrExtendTable(table, columns)
Create a new table in the database.
If a table of this name already exists, extend it to have any
additional columns present in the given list as well as
all of its current columns.
| CreateOrExtendTable | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def Insert(self, table, rowdict) :
"""Insert(table, datadict) - Insert a new row into the table
using the keys+values from rowdict as the column values.
"""
txn = None
try:
if not getattr(self.db, "has_key")(_columns_key(table)):
raise TableDBError, "... | Insert(table, datadict) - Insert a new row into the table
using the keys+values from rowdict as the column values.
| Insert | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def Modify(self, table, conditions={}, mappings={}):
"""Modify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings'
* table - the table name
* conditions - a dictionary keyed on column names containing
a condition callab... | Modify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings'
* table - the table name
* conditions - a dictionary keyed on column names containing
a condition callable expecting the data string as an
argument and return... | Modify | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def Delete(self, table, conditions={}):
"""Delete(table, conditions) - Delete items matching the given
conditions from the table.
* conditions - a dictionary keyed on column names containing
condition functions expecting the data string as an
argument and returning a boolean... | Delete(table, conditions) - Delete items matching the given
conditions from the table.
* conditions - a dictionary keyed on column names containing
condition functions expecting the data string as an
argument and returning a boolean.
| Delete | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def Select(self, table, columns, conditions={}):
"""Select(table, columns, conditions) - retrieve specific row data
Returns a list of row column->value mapping dictionaries.
* columns - a list of which column data to return. If
columns is None, all columns will be returned.
*... | Select(table, columns, conditions) - retrieve specific row data
Returns a list of row column->value mapping dictionaries.
* columns - a list of which column data to return. If
columns is None, all columns will be returned.
* conditions - a dictionary keyed on column names
c... | Select | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def __Select(self, table, columns, conditions):
"""__Select() - Used to implement Select and Delete (above)
Returns a dictionary keyed on rowids containing dicts
holding the row data for columns listed in the columns param
that match the given conditions.
* conditions is a dictio... | __Select() - Used to implement Select and Delete (above)
Returns a dictionary keyed on rowids containing dicts
holding the row data for columns listed in the columns param
that match the given conditions.
* conditions is a dictionary keyed on column names
containing callable cond... | __Select | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def Drop(self, table):
"""Remove an entire table from the database"""
txn = None
try:
txn = self.env.txn_begin()
# delete the column list
self.db.delete(_columns_key(table), txn=txn)
cur = self.db.cursor(txn)
# delete all keys contai... | Remove an entire table from the database | Drop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbtables.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbtables.py | MIT |
def DeadlockWrap(function, *_args, **_kwargs):
"""DeadlockWrap(function, *_args, **_kwargs) - automatically retries
function in case of a database deadlock.
This is a function intended to be used to wrap database calls such
that they perform retrys with exponentially backing off sleeps in
between w... | DeadlockWrap(function, *_args, **_kwargs) - automatically retries
function in case of a database deadlock.
This is a function intended to be used to wrap database calls such
that they perform retrys with exponentially backing off sleeps in
between when a DBLockDeadlockError exception is raised.
A ... | DeadlockWrap | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bsddb/dbutils.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bsddb/dbutils.py | MIT |
def is_future(stmt):
"""Return true if statement is a well-formed future statement"""
if not isinstance(stmt, ast.From):
return 0
if stmt.modname == "__future__":
return 1
else:
return 0 | Return true if statement is a well-formed future statement | is_future | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/future.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/future.py | MIT |
def set_filename(filename, tree):
"""Set the filename attribute to filename on every node in tree"""
worklist = [tree]
while worklist:
node = worklist.pop(0)
node.filename = filename
worklist.extend(node.getChildNodes()) | Set the filename attribute to filename on every node in tree | set_filename | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/misc.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/misc.py | MIT |
def has_unconditional_transfer(self):
"""Returns True if there is an unconditional transfer to an other block
at the end of this block. This means there is no risk for the bytecode
executer to go past this block's bytecode."""
try:
op, arg = self.insts[-1]
except (Ind... | Returns True if there is an unconditional transfer to an other block
at the end of this block. This means there is no risk for the bytecode
executer to go past this block's bytecode. | has_unconditional_transfer | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def get_followers(self):
"""Get the whole list of followers, including the next block."""
followers = set(self.next)
# Blocks that must be emitted *after* this one, because of
# bytecode offsets (e.g. relative jumps) pointing to them.
for inst in self.insts:
if inst[0... | Get the whole list of followers, including the next block. | get_followers | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def getContainedGraphs(self):
"""Return all graphs contained within this block.
For example, a MAKE_FUNCTION block will contain a reference to
the graph for the function body.
"""
contained = []
for inst in self.insts:
if len(inst) == 1:
conti... | Return all graphs contained within this block.
For example, a MAKE_FUNCTION block will contain a reference to
the graph for the function body.
| getContainedGraphs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def computeStackDepth(self):
"""Compute the max stack depth.
Approach is to compute the stack effect of each basic block.
Then find the path through the code with the largest total
effect.
"""
depth = {}
exit = None
for b in self.getBlocks():
... | Compute the max stack depth.
Approach is to compute the stack effect of each basic block.
Then find the path through the code with the largest total
effect.
| computeStackDepth | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def flattenGraph(self):
"""Arrange the blocks in order and resolve jumps"""
assert self.stage == RAW
self.insts = insts = []
pc = 0
begin = {}
end = {}
for b in self.getBlocksInOrder():
begin[b] = pc
for inst in b.getInstructions():
... | Arrange the blocks in order and resolve jumps | flattenGraph | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def convertArgs(self):
"""Convert arguments from symbolic to concrete form"""
assert self.stage == FLAT
self.consts.insert(0, self.docstring)
self.sort_cellvars()
for i in range(len(self.insts)):
t = self.insts[i]
if len(t) == 2:
opname, op... | Convert arguments from symbolic to concrete form | convertArgs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def sort_cellvars(self):
"""Sort cellvars in the order of varnames and prune from freevars.
"""
cells = {}
for name in self.cellvars:
cells[name] = 1
self.cellvars = [name for name in self.varnames
if name in cells]
for name in self.ce... | Sort cellvars in the order of varnames and prune from freevars.
| sort_cellvars | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def _lookupName(self, name, list):
"""Return index of name in list, appending if necessary
This routine uses a list instead of a dictionary, because a
dictionary can't store two different keys if the keys have the
same value but different types, e.g. 2 and 2L. The compiler
must... | Return index of name in list, appending if necessary
This routine uses a list instead of a dictionary, because a
dictionary can't store two different keys if the keys have the
same value but different types, e.g. 2 and 2L. The compiler
must treat these two separately, so it does an exp... | _lookupName | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def getConsts(self):
"""Return a tuple for the const slot of the code object
Must convert references to code (MAKE_FUNCTION) to code
objects recursively.
"""
l = []
for elt in self.consts:
if isinstance(elt, PyFlowGraph):
elt = elt.getCode()
... | Return a tuple for the const slot of the code object
Must convert references to code (MAKE_FUNCTION) to code
objects recursively.
| getConsts | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def twobyte(val):
"""Convert an int argument into high and low bytes"""
assert isinstance(val, int)
return divmod(val, 256) | Convert an int argument into high and low bytes | twobyte | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pyassem.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pyassem.py | MIT |
def checkClass(self):
"""Verify that class is constructed correctly"""
try:
assert hasattr(self, 'graph')
assert getattr(self, 'NameFinder')
assert getattr(self, 'FunctionGen')
assert getattr(self, 'ClassGen')
except AssertionError, msg:
... | Verify that class is constructed correctly | checkClass | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pycodegen.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pycodegen.py | MIT |
def generateArgList(arglist):
"""Generate an arg list marking TupleArgs"""
args = []
extra = []
count = 0
for i in range(len(arglist)):
elt = arglist[i]
if isinstance(elt, str):
args.append(elt)
elif isinstance(elt, tuple):
args.append(TupleArg(i * 2, ... | Generate an arg list marking TupleArgs | generateArgList | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pycodegen.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pycodegen.py | MIT |
def findOp(node):
"""Find the op (DELETE, LOAD, STORE) in an AssTuple tree"""
v = OpFinder()
walk(node, v, verbose=0)
return v.op | Find the op (DELETE, LOAD, STORE) in an AssTuple tree | findOp | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/pycodegen.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/pycodegen.py | MIT |
def check_name(self, name):
"""Return scope of name.
The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
"""
if name in self.globals:
return SC_GLOBAL_EXPLICIT
if name in self.cells:
return SC_CELL
if name in self.defs:
return S... | Return scope of name.
The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
| check_name | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/symbols.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/symbols.py | MIT |
def force_global(self, name):
"""Force name to be global in scope.
Some child of the current node had a free reference to name.
When the child was processed, it was labelled a free
variable. Now that all its enclosing scope have been
processed, the name is known to be a global ... | Force name to be global in scope.
Some child of the current node had a free reference to name.
When the child was processed, it was labelled a free
variable. Now that all its enclosing scope have been
processed, the name is known to be a global or builtin. So
walk back down th... | force_global | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/symbols.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/symbols.py | MIT |
def add_frees(self, names):
"""Process list of free vars from nested scope.
Returns a list of names that are either 1) declared global in the
parent or 2) undefined in a top-level parent. In either case,
the nested scope should treat them as globals.
"""
child_globals =... | Process list of free vars from nested scope.
Returns a list of names that are either 1) declared global in the
parent or 2) undefined in a top-level parent. In either case,
the nested scope should treat them as globals.
| add_frees | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/symbols.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/symbols.py | MIT |
def visitAssign(self, node, scope):
"""Propagate assignment flag down to child nodes.
The Assign node doesn't itself contains the variables being
assigned to. Instead, the children in node.nodes are visited
with the assign flag set to true. When the names occur in
those nodes,... | Propagate assignment flag down to child nodes.
The Assign node doesn't itself contains the variables being
assigned to. Instead, the children in node.nodes are visited
with the assign flag set to true. When the names occur in
those nodes, they are marked as defs.
Some names t... | visitAssign | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/symbols.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/symbols.py | MIT |
def __init__(self, multi=None):
"""Create new visitor object.
If optional argument multi is not None, then print messages
for each error rather than raising a SyntaxError for the
first.
"""
self.multi = multi
self.errors = 0 | Create new visitor object.
If optional argument multi is not None, then print messages
for each error rather than raising a SyntaxError for the
first.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/syntax.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/syntax.py | MIT |
def transform(self, tree):
"""Transform an AST into a modified parse tree."""
if not (isinstance(tree, tuple) or isinstance(tree, list)):
tree = parser.st2tuple(tree, line_info=1)
return self.compile_node(tree) | Transform an AST into a modified parse tree. | transform | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/transformer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/transformer.py | MIT |
def parsefile(self, file):
"""Return a modified parse tree for the contents of the given file."""
if type(file) == type(''):
file = open(file)
return self.parsesuite(file.read()) | Return a modified parse tree for the contents of the given file. | parsefile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/transformer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/transformer.py | MIT |
def com_augassign(self, node):
"""Return node suitable for lvalue of augmented assignment
Names, slices, and attributes are the only allowable nodes.
"""
l = self.com_node(node)
if l.__class__ in (Name, Slice, Subscript, Getattr):
return l
raise SyntaxError, ... | Return node suitable for lvalue of augmented assignment
Names, slices, and attributes are the only allowable nodes.
| com_augassign | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/transformer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/transformer.py | MIT |
def com_binary(self, constructor, nodelist):
"Compile 'NODE (OP NODE)*' into (type, [ node1, ..., nodeN ])."
l = len(nodelist)
if l == 1:
n = nodelist[0]
return self.lookup_node(n)(n[1:])
items = []
for i in range(0, l, 2):
n = nodelist[i]
... | Compile 'NODE (OP NODE)*' into (type, [ node1, ..., nodeN ]). | com_binary | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/compiler/transformer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/compiler/transformer.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.