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 _process_args(self, largs, rargs, values):
"""_process_args(largs : [string],
rargs : [string],
values : Values)
Process command-line arguments and populate 'values', consuming
options and arguments from 'rargs'. If 'allow_interspersed_args... | _process_args(largs : [string],
rargs : [string],
values : Values)
Process command-line arguments and populate 'values', consuming
options and arguments from 'rargs'. If 'allow_interspersed_args' is
false, stop at the first non-option argument.... | _process_args | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/optparse.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py | MIT |
def error(self, msg):
"""error(msg : string)
Print a usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
self.print_usage(sys.stderr)
self.exit(2, "%s: ... | error(msg : string)
Print a usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
| error | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/optparse.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py | MIT |
def print_usage(self, file=None):
"""print_usage(file : file = stdout)
Print the usage message for the current program (self.usage) to
'file' (default stdout). Any occurrence of the string "%prog" in
self.usage is replaced with the name of the current program
(basename of sys.a... | print_usage(file : file = stdout)
Print the usage message for the current program (self.usage) to
'file' (default stdout). Any occurrence of the string "%prog" in
self.usage is replaced with the name of the current program
(basename of sys.argv[0]). Does nothing if self.usage is empty... | print_usage | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/optparse.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py | MIT |
def print_version(self, file=None):
"""print_version(file : file = stdout)
Print the version message for this program (self.version) to
'file' (default stdout). As with print_usage(), any occurrence
of "%prog" in self.version is replaced by the current program's
name. Does not... | print_version(file : file = stdout)
Print the version message for this program (self.version) to
'file' (default stdout). As with print_usage(), any occurrence
of "%prog" in self.version is replaced by the current program's
name. Does nothing if self.version is empty or undefined.
... | print_version | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/optparse.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py | MIT |
def print_help(self, file=None):
"""print_help(file : file = stdout)
Print an extended help message, listing all options and any
help text provided with them, to 'file' (default stdout).
"""
if file is None:
file = sys.stdout
encoding = self._get_encoding(fil... | print_help(file : file = stdout)
Print an extended help message, listing all options and any
help text provided with them, to 'file' (default stdout).
| print_help | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/optparse.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py | MIT |
def _match_abbrev(s, wordmap):
"""_match_abbrev(s : string, wordmap : {string : Option}) -> string
Return the string key in 'wordmap' for which 's' is an unambiguous
abbreviation. If 's' is found to be ambiguous or doesn't match any of
'words', raise BadOptionError.
"""
# Is there an exact mat... | _match_abbrev(s : string, wordmap : {string : Option}) -> string
Return the string key in 'wordmap' for which 's' is an unambiguous
abbreviation. If 's' is found to be ambiguous or doesn't match any of
'words', raise BadOptionError.
| _match_abbrev | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/optparse.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/optparse.py | MIT |
def makedirs(name, mode=0777):
"""makedirs(path [, mode=0777])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
just the rightmost) will be created if it does not exist. This is
recursive.
"""
head, tail = pat... | makedirs(path [, mode=0777])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
just the rightmost) will be created if it does not exist. This is
recursive.
| makedirs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def removedirs(name):
"""removedirs(path)
Super-rmdir; remove a leaf directory and all empty intermediate
ones. Works like rmdir except that, if the leaf directory is
successfully removed, directories corresponding to rightmost path
segments will be pruned away until either the whole path is
c... | removedirs(path)
Super-rmdir; remove a leaf directory and all empty intermediate
ones. Works like rmdir except that, if the leaf directory is
successfully removed, directories corresponding to rightmost path
segments will be pruned away until either the whole path is
consumed or an error occurs. ... | removedirs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def renames(old, new):
"""renames(old, new)
Super-rename; create directories as necessary and delete any left
empty. Works like rename, except creation of any intermediate
directories needed to make the new pathname good is attempted
first. After the rename, directories corresponding to rightmost... | renames(old, new)
Super-rename; create directories as necessary and delete any left
empty. Works like rename, except creation of any intermediate
directories needed to make the new pathname good is attempted
first. After the rename, directories corresponding to rightmost
path segments of the old ... | renames | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def walk(top, topdown=True, onerror=None, followlinks=False):
"""Directory tree generator.
For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. ... | Directory tree generator.
For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. dirnames is a list of
the names of the subdirectories in dirpath ... | walk | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def execle(file, *args):
"""execle(file, *args, env)
Execute the executable file with argument list args and
environment env, replacing the current process. """
env = args[-1]
execve(file, args[:-1], env) | execle(file, *args, env)
Execute the executable file with argument list args and
environment env, replacing the current process. | execle | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def execlpe(file, *args):
"""execlpe(file, *args, env)
Execute the executable file (which is searched for along $PATH)
with argument list args and environment env, replacing the current
process. """
env = args[-1]
execvpe(file, args[:-1], env) | execlpe(file, *args, env)
Execute the executable file (which is searched for along $PATH)
with argument list args and environment env, replacing the current
process. | execlpe | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def spawnle(mode, file, *args):
"""spawnle(mode, file, *args, env) -> integer
Execute file with arguments from args in a subprocess with the
supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, whe... | spawnle(mode, file, *args, env) -> integer
Execute file with arguments from args in a subprocess with the
supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. | spawnle | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def spawnlpe(mode, file, *args):
"""spawnlpe(mode, file, *args, env) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits ... | spawnlpe(mode, file, *args, env) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG i... | spawnlpe | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def popen2(cmd, mode="t", bufsize=-1):
"""Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()). If 'cmd'
is a string it will be... | Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()). If 'cmd'
is a string it will be passed to the shell (as with os.system()). If
... | popen2 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def popen3(cmd, mode="t", bufsize=-1):
"""Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()). If 'cmd'
is a string it will be... | Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()). If 'cmd'
is a string it will be passed to the shell (as with os.system()). If
... | popen3 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def popen4(cmd, mode="t", bufsize=-1):
"""Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()). If 'cmd'
is a string it will be... | Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
may be a sequence, in which case arguments will be passed directly to
the program without shell intervention (as with os.spawnv()). If 'cmd'
is a string it will be passed to the shell (as with os.system()). If
... | popen4 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os.py | MIT |
def join(a, *p):
"""Join two or more pathname components, inserting sep as needed"""
path = a
for b in p:
if isabs(b):
path = b
elif path == '' or path[-1:] in '/\\:':
path = path + b
else:
path = path + '/' + b
return path | Join two or more pathname components, inserting sep as needed | join | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os2emxpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os2emxpath.py | MIT |
def splitunc(p):
"""Split a pathname into UNC mount point and relative path specifiers.
Return a 2-tuple (unc, rest); either part may be empty.
If unc is not empty, it has the form '//host/mount' (or similar
using backslashes). unc+rest is always the input path.
Paths containing drive letters neve... | Split a pathname into UNC mount point and relative path specifiers.
Return a 2-tuple (unc, rest); either part may be empty.
If unc is not empty, it has the form '//host/mount' (or similar
using backslashes). unc+rest is always the input path.
Paths containing drive letters never have a UNC part.
| splitunc | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os2emxpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os2emxpath.py | MIT |
def ismount(path):
"""Test whether a path is a mount point (defined as root of drive)"""
unc, rest = splitunc(path)
if unc:
return rest in ("", "/", "\\")
p = splitdrive(path)[1]
return len(p) == 1 and p[0] in '/\\' | Test whether a path is a mount point (defined as root of drive) | ismount | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os2emxpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os2emxpath.py | MIT |
def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
path = path.replace('\\', '/')
prefix, path = splitdrive(path)
while path[:1] == '/':
prefix = prefix + '/'
path = path[1:]
comps = path.split('/')
i = 0
while i < len(comps):
if comps[i] == '.... | Normalize path, eliminating double slashes, etc. | normpath | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os2emxpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os2emxpath.py | MIT |
def abspath(path):
"""Return the absolute version of a path"""
if not isabs(path):
if isinstance(path, _unicode):
cwd = os.getcwdu()
else:
cwd = os.getcwd()
path = join(cwd, path)
return normpath(path) | Return the absolute version of a path | abspath | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/os2emxpath.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/os2emxpath.py | MIT |
def user_call(self, frame, argument_list):
"""This method is called when there is the remote possibility
that we ever need to stop in this function."""
if self._wait_for_mainpyfile:
return
if self.stop_here(frame):
print >>self.stdout, '--Call--'
self.... | This method is called when there is the remote possibility
that we ever need to stop in this function. | user_call | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def user_line(self, frame):
"""This function is called when we stop or break at this line."""
if self._wait_for_mainpyfile:
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
or frame.f_lineno<= 0):
return
self._wait_for_mainpyfile = 0
... | This function is called when we stop or break at this line. | user_line | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def bp_commands(self,frame):
"""Call every command that was set for the current active breakpoint
(if there is one).
Returns True if the normal interaction function must be called,
False otherwise."""
# self.currentbp is set in bdb in Bdb.break_here if a breakpoint was hit
... | Call every command that was set for the current active breakpoint
(if there is one).
Returns True if the normal interaction function must be called,
False otherwise. | bp_commands | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def user_return(self, frame, return_value):
"""This function is called when a return trap is set here."""
if self._wait_for_mainpyfile:
return
frame.f_locals['__return__'] = return_value
print >>self.stdout, '--Return--'
self.interaction(frame, None) | This function is called when a return trap is set here. | user_return | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def user_exception(self, frame, exc_info):
"""This function is called if an exception occurs,
but only if we are to stop at or just below this level."""
if self._wait_for_mainpyfile:
return
exc_type, exc_value, exc_traceback = exc_info
frame.f_locals['__exception__'] ... | This function is called if an exception occurs,
but only if we are to stop at or just below this level. | user_exception | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def displayhook(self, obj):
"""Custom displayhook for the exec in default(), which prevents
assignment of the _ variable in the builtins.
"""
# reproduce the behavior of the standard displayhook, not printing None
if obj is not None:
print repr(obj) | Custom displayhook for the exec in default(), which prevents
assignment of the _ variable in the builtins.
| displayhook | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def onecmd(self, line):
"""Interpret the argument as though it had been typed in response
to the prompt.
Checks whether this line is typed at the normal prompt or in
a breakpoint command list definition.
"""
if not self.commands_defining:
return cmd.Cmd.onecm... | Interpret the argument as though it had been typed in response
to the prompt.
Checks whether this line is typed at the normal prompt or in
a breakpoint command list definition.
| onecmd | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def handle_command_def(self,line):
"""Handles one command line during command list definition."""
cmd, arg, line = self.parseline(line)
if not cmd:
return
if cmd == 'silent':
self.commands_silent[self.commands_bnum] = True
return # continue to handle o... | Handles one command line during command list definition. | handle_command_def | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def do_commands(self, arg):
"""Defines a list of commands associated to a breakpoint.
Those commands will be executed whenever the breakpoint causes
the program to stop execution."""
if not arg:
bnum = len(bdb.Breakpoint.bpbynumber)-1
else:
try:
... | Defines a list of commands associated to a breakpoint.
Those commands will be executed whenever the breakpoint causes
the program to stop execution. | do_commands | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def checkline(self, filename, lineno):
"""Check whether specified line seems to be executable.
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
line or EOF). Warning: testing is not comprehensive.
"""
# this method should be callable before starting debugging... | Check whether specified line seems to be executable.
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
line or EOF). Warning: testing is not comprehensive.
| checkline | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def do_ignore(self,arg):
"""arg is bp number followed by ignore count."""
args = arg.split()
try:
bpnum = int(args[0].strip())
except ValueError:
# something went wrong
print >>self.stdout, \
'Breakpoint index %r is not a number' % args... | arg is bp number followed by ignore count. | do_ignore | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def do_clear(self, arg):
"""Three possibilities, tried in this order:
clear -> clear all breaks, ask for confirmation
clear file:lineno -> clear all breaks at file:lineno
clear bpno bpno ... -> clear breakpoints by number"""
if not arg:
try:
reply = ra... | Three possibilities, tried in this order:
clear -> clear all breaks, ask for confirmation
clear file:lineno -> clear all breaks at file:lineno
clear bpno bpno ... -> clear breakpoints by number | do_clear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def do_run(self, arg):
"""Restart program by raising an exception to be caught in the main
debugger loop. If arguments were given, set them in sys.argv."""
if arg:
import shlex
argv0 = sys.argv[0:1]
sys.argv = shlex.split(arg)
sys.argv[:0] = argv0... | Restart program by raising an exception to be caught in the main
debugger loop. If arguments were given, set them in sys.argv. | do_run | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def lookupmodule(self, filename):
"""Helper function for break/clear parsing -- may be overridden.
lookupmodule() translates (possibly incomplete) file or module name
into an absolute file name.
"""
if os.path.isabs(filename) and os.path.exists(filename):
return fil... | Helper function for break/clear parsing -- may be overridden.
lookupmodule() translates (possibly incomplete) file or module name
into an absolute file name.
| lookupmodule | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pdb.py | MIT |
def __init__(self, file, protocol=None):
"""This takes a file-like object for writing a pickle data stream.
The optional protocol argument tells the pickler to use the
given protocol; supported protocols are 0, 1, 2. The default
protocol is 0, to be backwards compatible. (Protocol 0 i... | This takes a file-like object for writing a pickle data stream.
The optional protocol argument tells the pickler to use the
given protocol; supported protocols are 0, 1, 2. The default
protocol is 0, to be backwards compatible. (Protocol 0 is the
only protocol that can be written to a... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def dump(self, obj):
"""Write a pickled representation of obj to the open file."""
if self.proto >= 2:
self.write(PROTO + chr(self.proto))
self.save(obj)
self.write(STOP) | Write a pickled representation of obj to the open file. | dump | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def memoize(self, obj):
"""Store an object in the memo."""
# The Pickler memo is a dictionary mapping object ids to 2-tuples
# that contain the Unpickler memo key and the object being memoized.
# The memo key is written to the pickle and will become
# the key in the Unpickler's ... | Store an object in the memo. | memoize | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def _keep_alive(x, memo):
"""Keeps a reference to the object x in the memo.
Because we remember objects by their id, we have
to assure that possibly temporary objects are kept
alive by referencing them.
We store a reference at the id of the memo, which should
normally not be used unless someone... | Keeps a reference to the object x in the memo.
Because we remember objects by their id, we have
to assure that possibly temporary objects are kept
alive by referencing them.
We store a reference at the id of the memo, which should
normally not be used unless someone tries to deepcopy
the memo i... | _keep_alive | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def whichmodule(func, funcname):
"""Figure out the module in which a function occurs.
Search sys.modules for the module.
Cache in classmap.
Return a module name.
If the function cannot be found, return "__main__".
"""
# Python functions should always get an __module__ from their globals.
... | Figure out the module in which a function occurs.
Search sys.modules for the module.
Cache in classmap.
Return a module name.
If the function cannot be found, return "__main__".
| whichmodule | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def __init__(self, file):
"""This takes a file-like object for reading a pickle data stream.
The protocol version of the pickle is detected automatically, so no
proto argument is needed.
The file-like object must have two methods, a read() method that
takes an integer argument,... | This takes a file-like object for reading a pickle data stream.
The protocol version of the pickle is detected automatically, so no
proto argument is needed.
The file-like object must have two methods, a read() method that
takes an integer argument, and a readline() method that require... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def load(self):
"""Read a pickled object representation from the open file.
Return the reconstituted object hierarchy specified in the file.
"""
self.mark = object() # any new unique object
self.stack = []
self.append = self.stack.append
read = self.read
... | Read a pickled object representation from the open file.
Return the reconstituted object hierarchy specified in the file.
| load | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def encode_long(x):
r"""Encode a long to a two's complement little-endian binary string.
Note that 0L is a special case, returning an empty string, to save a
byte in the LONG1 pickling context.
>>> encode_long(0L)
''
>>> encode_long(255L)
'\xff\x00'
>>> encode_long(32767L)
'\xff\x7f... | Encode a long to a two's complement little-endian binary string.
Note that 0L is a special case, returning an empty string, to save a
byte in the LONG1 pickling context.
>>> encode_long(0L)
''
>>> encode_long(255L)
'\xff\x00'
>>> encode_long(32767L)
'\xff\x7f'
>>> encode_long(-256L)... | encode_long | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def decode_long(data):
r"""Decode a long from a two's complement little-endian binary string.
>>> decode_long('')
0L
>>> decode_long("\xff\x00")
255L
>>> decode_long("\xff\x7f")
32767L
>>> decode_long("\x00\xff")
-256L
>>> decode_long("\x00\x80")
-32768L
>>> decode_long(... | Decode a long from a two's complement little-endian binary string.
>>> decode_long('')
0L
>>> decode_long("\xff\x00")
255L
>>> decode_long("\xff\x7f")
32767L
>>> decode_long("\x00\xff")
-256L
>>> decode_long("\x00\x80")
-32768L
>>> decode_long("\x80")
-128L
>>> decod... | decode_long | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickle.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickle.py | MIT |
def read_uint2(f):
r"""
>>> import StringIO
>>> read_uint2(StringIO.StringIO('\xff\x00'))
255
>>> read_uint2(StringIO.StringIO('\xff\xff'))
65535
"""
data = f.read(2)
if len(data) == 2:
return _unpack("<H", data)[0]
raise ValueError("not enough data in stream to read uin... |
>>> import StringIO
>>> read_uint2(StringIO.StringIO('\xff\x00'))
255
>>> read_uint2(StringIO.StringIO('\xff\xff'))
65535
| read_uint2 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_int4(f):
r"""
>>> import StringIO
>>> read_int4(StringIO.StringIO('\xff\x00\x00\x00'))
255
>>> read_int4(StringIO.StringIO('\x00\x00\x00\x80')) == -(2**31)
True
"""
data = f.read(4)
if len(data) == 4:
return _unpack("<i", data)[0]
raise ValueError("not enough da... |
>>> import StringIO
>>> read_int4(StringIO.StringIO('\xff\x00\x00\x00'))
255
>>> read_int4(StringIO.StringIO('\x00\x00\x00\x80')) == -(2**31)
True
| read_int4 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_stringnl(f, decode=True, stripquotes=True):
r"""
>>> import StringIO
>>> read_stringnl(StringIO.StringIO("'abcd'\nefg\n"))
'abcd'
>>> read_stringnl(StringIO.StringIO("\n"))
Traceback (most recent call last):
...
ValueError: no string quotes around ''
>>> read_stringnl(Stri... |
>>> import StringIO
>>> read_stringnl(StringIO.StringIO("'abcd'\nefg\n"))
'abcd'
>>> read_stringnl(StringIO.StringIO("\n"))
Traceback (most recent call last):
...
ValueError: no string quotes around ''
>>> read_stringnl(StringIO.StringIO("\n"), stripquotes=False)
''
>>> read_... | read_stringnl | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_string4(f):
r"""
>>> import StringIO
>>> read_string4(StringIO.StringIO("\x00\x00\x00\x00abc"))
''
>>> read_string4(StringIO.StringIO("\x03\x00\x00\x00abcdef"))
'abc'
>>> read_string4(StringIO.StringIO("\x00\x00\x00\x03abcdef"))
Traceback (most recent call last):
...
Val... |
>>> import StringIO
>>> read_string4(StringIO.StringIO("\x00\x00\x00\x00abc"))
''
>>> read_string4(StringIO.StringIO("\x03\x00\x00\x00abcdef"))
'abc'
>>> read_string4(StringIO.StringIO("\x00\x00\x00\x03abcdef"))
Traceback (most recent call last):
...
ValueError: expected 50331648 by... | read_string4 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_string1(f):
r"""
>>> import StringIO
>>> read_string1(StringIO.StringIO("\x00"))
''
>>> read_string1(StringIO.StringIO("\x03abcdef"))
'abc'
"""
n = read_uint1(f)
assert n >= 0
data = f.read(n)
if len(data) == n:
return data
raise ValueError("expected %d ... |
>>> import StringIO
>>> read_string1(StringIO.StringIO("\x00"))
''
>>> read_string1(StringIO.StringIO("\x03abcdef"))
'abc'
| read_string1 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_unicodestringnl(f):
r"""
>>> import StringIO
>>> read_unicodestringnl(StringIO.StringIO("abc\uabcd\njunk"))
u'abc\uabcd'
"""
data = f.readline()
if not data.endswith('\n'):
raise ValueError("no newline found when trying to read "
"unicodestringnl")
... |
>>> import StringIO
>>> read_unicodestringnl(StringIO.StringIO("abc\uabcd\njunk"))
u'abc\uabcd'
| read_unicodestringnl | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_unicodestring4(f):
r"""
>>> import StringIO
>>> s = u'abcd\uabcd'
>>> enc = s.encode('utf-8')
>>> enc
'abcd\xea\xaf\x8d'
>>> n = chr(len(enc)) + chr(0) * 3 # little-endian 4-byte length
>>> t = read_unicodestring4(StringIO.StringIO(n + enc + 'junk'))
>>> s == t
True
... |
>>> import StringIO
>>> s = u'abcd\uabcd'
>>> enc = s.encode('utf-8')
>>> enc
'abcd\xea\xaf\x8d'
>>> n = chr(len(enc)) + chr(0) * 3 # little-endian 4-byte length
>>> t = read_unicodestring4(StringIO.StringIO(n + enc + 'junk'))
>>> s == t
True
>>> read_unicodestring4(StringIO.S... | read_unicodestring4 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_decimalnl_short(f):
r"""
>>> import StringIO
>>> read_decimalnl_short(StringIO.StringIO("1234\n56"))
1234
>>> read_decimalnl_short(StringIO.StringIO("1234L\n56"))
Traceback (most recent call last):
...
ValueError: trailing 'L' not allowed in '1234L'
"""
s = read_string... |
>>> import StringIO
>>> read_decimalnl_short(StringIO.StringIO("1234\n56"))
1234
>>> read_decimalnl_short(StringIO.StringIO("1234L\n56"))
Traceback (most recent call last):
...
ValueError: trailing 'L' not allowed in '1234L'
| read_decimalnl_short | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_decimalnl_long(f):
r"""
>>> import StringIO
>>> read_decimalnl_long(StringIO.StringIO("1234\n56"))
Traceback (most recent call last):
...
ValueError: trailing 'L' required in '1234'
Someday the trailing 'L' will probably go away from this output.
>>> read_decimalnl_long(Strin... |
>>> import StringIO
>>> read_decimalnl_long(StringIO.StringIO("1234\n56"))
Traceback (most recent call last):
...
ValueError: trailing 'L' required in '1234'
Someday the trailing 'L' will probably go away from this output.
>>> read_decimalnl_long(StringIO.StringIO("1234L\n56"))
1234L... | read_decimalnl_long | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_float8(f):
r"""
>>> import StringIO, struct
>>> raw = struct.pack(">d", -1.25)
>>> raw
'\xbf\xf4\x00\x00\x00\x00\x00\x00'
>>> read_float8(StringIO.StringIO(raw + "\n"))
-1.25
"""
data = f.read(8)
if len(data) == 8:
return _unpack(">d", data)[0]
raise ValueEr... |
>>> import StringIO, struct
>>> raw = struct.pack(">d", -1.25)
>>> raw
'\xbf\xf4\x00\x00\x00\x00\x00\x00'
>>> read_float8(StringIO.StringIO(raw + "\n"))
-1.25
| read_float8 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_long1(f):
r"""
>>> import StringIO
>>> read_long1(StringIO.StringIO("\x00"))
0L
>>> read_long1(StringIO.StringIO("\x02\xff\x00"))
255L
>>> read_long1(StringIO.StringIO("\x02\xff\x7f"))
32767L
>>> read_long1(StringIO.StringIO("\x02\x00\xff"))
-256L
>>> read_long1(Stri... |
>>> import StringIO
>>> read_long1(StringIO.StringIO("\x00"))
0L
>>> read_long1(StringIO.StringIO("\x02\xff\x00"))
255L
>>> read_long1(StringIO.StringIO("\x02\xff\x7f"))
32767L
>>> read_long1(StringIO.StringIO("\x02\x00\xff"))
-256L
>>> read_long1(StringIO.StringIO("\x02\x00\x80... | read_long1 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def read_long4(f):
r"""
>>> import StringIO
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x00"))
255L
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x7f"))
32767L
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\xff"))
-256L
>>> read_long4(StringIO.StringIO("\x... |
>>> import StringIO
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x00"))
255L
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x7f"))
32767L
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\xff"))
-256L
>>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\x80"))
... | read_long4 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def genops(pickle):
"""Generate all the opcodes in a pickle.
'pickle' is a file-like object, or string, containing the pickle.
Each opcode in the pickle is generated, from the current pickle position,
stopping after a STOP opcode is delivered. A triple is generated for
each opcode:
opcod... | Generate all the opcodes in a pickle.
'pickle' is a file-like object, or string, containing the pickle.
Each opcode in the pickle is generated, from the current pickle position,
stopping after a STOP opcode is delivered. A triple is generated for
each opcode:
opcode, arg, pos
opcode is ... | genops | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def optimize(p):
'Optimize a pickle string by removing unused PUT opcodes'
gets = set() # set of args used by a GET opcode
puts = [] # (arg, startpos, stoppos) for the PUT opcodes
prevpos = None # set to pos if previous opcode was a PUT
for opcode, arg, pos in genop... | Optimize a pickle string by removing unused PUT opcodes | optimize | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def dis(pickle, out=None, memo=None, indentlevel=4):
"""Produce a symbolic disassembly of a pickle.
'pickle' is a file-like object, or string, containing a (at least one)
pickle. The pickle is disassembled from the current position, through
the first STOP opcode encountered.
Optional arg 'out' is... | Produce a symbolic disassembly of a pickle.
'pickle' is a file-like object, or string, containing a (at least one)
pickle. The pickle is disassembled from the current position, through
the first STOP opcode encountered.
Optional arg 'out' is a file-like object to which the disassembly is
printed.... | dis | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pickletools.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pickletools.py | MIT |
def clone(self):
"""t.clone() returns a new pipeline template with identical
initial state as the current one."""
t = Template()
t.steps = self.steps[:]
t.debugging = self.debugging
return t | t.clone() returns a new pipeline template with identical
initial state as the current one. | clone | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pipes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pipes.py | MIT |
def append(self, cmd, kind):
"""t.append(cmd, kind) adds a new step at the end."""
if type(cmd) is not type(''):
raise TypeError, \
'Template.append: cmd must be a string'
if kind not in stepkinds:
raise ValueError, \
'Template.append: ... | t.append(cmd, kind) adds a new step at the end. | append | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pipes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pipes.py | MIT |
def prepend(self, cmd, kind):
"""t.prepend(cmd, kind) adds a new step at the front."""
if type(cmd) is not type(''):
raise TypeError, \
'Template.prepend: cmd must be a string'
if kind not in stepkinds:
raise ValueError, \
'Template.pre... | t.prepend(cmd, kind) adds a new step at the front. | prepend | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pipes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pipes.py | MIT |
def open(self, file, rw):
"""t.open(file, rw) returns a pipe or file object open for
reading or writing; the file is the other end of the pipeline."""
if rw == 'r':
return self.open_r(file)
if rw == 'w':
return self.open_w(file)
raise ValueError, \
... | t.open(file, rw) returns a pipe or file object open for
reading or writing; the file is the other end of the pipeline. | open | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pipes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pipes.py | MIT |
def open_r(self, file):
"""t.open_r(file) and t.open_w(file) implement
t.open(file, 'r') and t.open(file, 'w') respectively."""
if not self.steps:
return open(file, 'r')
if self.steps[-1][1] == SINK:
raise ValueError, \
'Template.open_r: pipeline... | t.open_r(file) and t.open_w(file) implement
t.open(file, 'r') and t.open(file, 'w') respectively. | open_r | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pipes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pipes.py | MIT |
def quote(file):
"""Return a shell-escaped version of the file string."""
for c in file:
if c not in _safechars:
break
else:
if not file:
return "''"
return file
# use single quotes, and put single quotes into double quotes
# the string $'b is then quo... | Return a shell-escaped version of the file string. | quote | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pipes.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pipes.py | MIT |
def simplegeneric(func):
"""Make a trivial single-dispatch generic function"""
registry = {}
def wrapper(*args, **kw):
ob = args[0]
try:
cls = ob.__class__
except AttributeError:
cls = type(ob)
try:
mro = cls.__mro__
except Attribut... | Make a trivial single-dispatch generic function | simplegeneric | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def walk_packages(path=None, prefix='', onerror=None):
"""Yields (module_loader, name, ispkg) for all modules recursively
on path, or, if path is None, all accessible modules.
'path' should be either None or a list of paths to look for
modules in.
'prefix' is a string to output on the front of eve... | Yields (module_loader, name, ispkg) for all modules recursively
on path, or, if path is None, all accessible modules.
'path' should be either None or a list of paths to look for
modules in.
'prefix' is a string to output on the front of every module name
on output.
Note that this function mus... | walk_packages | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def iter_modules(path=None, prefix=''):
"""Yields (module_loader, name, ispkg) for all submodules on path,
or, if path is None, all top-level modules on sys.path.
'path' should be either None or a list of paths to look for
modules in.
'prefix' is a string to output on the front of every module nam... | Yields (module_loader, name, ispkg) for all submodules on path,
or, if path is None, all top-level modules on sys.path.
'path' should be either None or a list of paths to look for
modules in.
'prefix' is a string to output on the front of every module name
on output.
| iter_modules | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def get_importer(path_item):
"""Retrieve a PEP 302 importer for the given path item
The returned importer is cached in sys.path_importer_cache
if it was newly created by a path hook.
If there is no importer, a wrapper around the basic import
machinery is returned. This wrapper is never inserted in... | Retrieve a PEP 302 importer for the given path item
The returned importer is cached in sys.path_importer_cache
if it was newly created by a path hook.
If there is no importer, a wrapper around the basic import
machinery is returned. This wrapper is never inserted into
the importer cache (None is i... | get_importer | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def iter_importers(fullname=""):
"""Yield PEP 302 importers for the given module name
If fullname contains a '.', the importers will be for the package
containing fullname, otherwise they will be importers for sys.meta_path,
sys.path, and Python's "classic" import machinery, in that order. If
the ... | Yield PEP 302 importers for the given module name
If fullname contains a '.', the importers will be for the package
containing fullname, otherwise they will be importers for sys.meta_path,
sys.path, and Python's "classic" import machinery, in that order. If
the named module is in a package, that packa... | iter_importers | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def extend_path(path, name):
"""Extend a package's path.
Intended use is to place the following code in a package's __init__.py:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
This will add to the package's __path__ all subdirectories of
directories on sys.... | Extend a package's path.
Intended use is to place the following code in a package's __init__.py:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
This will add to the package's __path__ all subdirectories of
directories on sys.path named after the package. This ... | extend_path | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def get_data(package, resource):
"""Get a resource from a package.
This is a wrapper round the PEP 302 loader get_data API. The package
argument should be the name of a package, in standard module format
(foo.bar). The resource argument should be in the form of a relative
filename, using '/' as the... | Get a resource from a package.
This is a wrapper round the PEP 302 loader get_data API. The package
argument should be the name of a package, in standard module format
(foo.bar). The resource argument should be in the form of a relative
filename, using '/' as the path separator. The parent directory na... | get_data | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/pkgutil.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/pkgutil.py | MIT |
def libc_ver(executable=sys.executable,lib='',version='',
chunksize=2048):
""" Tries to determine the libc version that the file executable
(which defaults to the Python interpreter) is linked against.
Returns a tuple of strings (lib,version) which default to the
given parame... | Tries to determine the libc version that the file executable
(which defaults to the Python interpreter) is linked against.
Returns a tuple of strings (lib,version) which default to the
given parameters in case the lookup fails.
Note that the function has intimate knowledge of how diff... | libc_ver | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _dist_try_harder(distname,version,id):
""" Tries some special tricks to get the distribution
information in case the default method fails.
Currently supports older SuSE Linux, Caldera OpenLinux and
Slackware Linux distributions.
"""
if os.path.exists('/var/adm/inst-log/info'):... | Tries some special tricks to get the distribution
information in case the default method fails.
Currently supports older SuSE Linux, Caldera OpenLinux and
Slackware Linux distributions.
| _dist_try_harder | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def linux_distribution(distname='', version='', id='',
supported_dists=_supported_dists,
full_distribution_name=1):
""" Tries to determine the name of the Linux OS distribution name.
The function first looks for a distribution release file in
/etc and... | Tries to determine the name of the Linux OS distribution name.
The function first looks for a distribution release file in
/etc and then reverts to _dist_try_harder() in case no
suitable files are found.
supported_dists may be given to define the set of Linux
distributions to ... | linux_distribution | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def dist(distname='',version='',id='',
supported_dists=_supported_dists):
""" Tries to determine the name of the Linux OS distribution name.
The function first looks for a distribution release file in
/etc and then reverts to _dist_try_harder() in case no
suitable files are found... | Tries to determine the name of the Linux OS distribution name.
The function first looks for a distribution release file in
/etc and then reverts to _dist_try_harder() in case no
suitable files are found.
Returns a tuple (distname,version,id) which default to the
args given as ... | dist | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _norm_version(version, build=''):
""" Normalize the version and build strings and return a single
version string using the format major.minor.build (or patchlevel).
"""
l = string.split(version,'.')
if build:
l.append(build)
try:
ints = map(int,l)
except ValueError:
... | Normalize the version and build strings and return a single
version string using the format major.minor.build (or patchlevel).
| _norm_version | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _syscmd_ver(system='', release='', version='',
supported_platforms=('win32','win16','dos','os2')):
""" Tries to figure out the OS version used and returns
a tuple (system,release,version).
It uses the "ver" shell command for this which is known
to exists on Windows, DOS... | Tries to figure out the OS version used and returns
a tuple (system,release,version).
It uses the "ver" shell command for this which is known
to exists on Windows, DOS and OS/2. XXX Others too ?
In case this fails, the given parameters are used as
defaults.
| _syscmd_ver | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _mac_ver_gestalt():
"""
Thanks to Mark R. Levinson for mailing documentation links and
code examples for this function. Documentation for the
gestalt() API is available online at:
http://www.rgaros.nl/gestalt/
"""
# Check whether the version info module is available
... |
Thanks to Mark R. Levinson for mailing documentation links and
code examples for this function. Documentation for the
gestalt() API is available online at:
http://www.rgaros.nl/gestalt/
| _mac_ver_gestalt | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def mac_ver(release='',versioninfo=('','',''),machine=''):
""" Get MacOS version information and return it as tuple (release,
versioninfo, machine) with versioninfo being a tuple (version,
dev_stage, non_release_version).
Entries which cannot be determined are set to the parameter values
... | Get MacOS version information and return it as tuple (release,
versioninfo, machine) with versioninfo being a tuple (version,
dev_stage, non_release_version).
Entries which cannot be determined are set to the parameter values
which default to ''. All tuple entries are strings.
| mac_ver | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')):
""" Version interface for Jython.
Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being
a tuple (vm_name,vm_release,vm_vendor) and osinfo being a
tuple (os_name,os_version,os_arch).
Values which can... | Version interface for Jython.
Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being
a tuple (vm_name,vm_release,vm_vendor) and osinfo being a
tuple (os_name,os_version,os_arch).
Values which cannot be determined are set to the defaults
given as parameters (which all... | java_ver | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def system_alias(system,release,version):
""" Returns (system,release,version) aliased to common
marketing names used for some systems.
It also does some reordering of the information in some cases
where it would otherwise cause confusion.
"""
if system == 'Rhapsody':
# Ap... | Returns (system,release,version) aliased to common
marketing names used for some systems.
It also does some reordering of the information in some cases
where it would otherwise cause confusion.
| system_alias | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _platform(*args):
""" Helper to format the platform string in a filename
compatible format e.g. "system-version-machine".
"""
# Format the platform string
platform = string.join(
map(string.strip,
filter(len, args)),
'-')
# Cleanup some possible filename obs... | Helper to format the platform string in a filename
compatible format e.g. "system-version-machine".
| _platform | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _node(default=''):
""" Helper to determine the node name of this machine.
"""
try:
import socket
except ImportError:
# No sockets...
return default
try:
return socket.gethostname()
except socket.error:
# Still not working...
return default | Helper to determine the node name of this machine.
| _node | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _follow_symlinks(filepath):
""" In case filepath is a symlink, follow it until a
real file is reached.
"""
filepath = _abspath(filepath)
while os.path.islink(filepath):
filepath = os.path.normpath(
os.path.join(os.path.dirname(filepath),os.readlink(filepath)))
return... | In case filepath is a symlink, follow it until a
real file is reached.
| _follow_symlinks | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _syscmd_uname(option,default=''):
""" Interface to the system's uname command.
"""
if sys.platform in ('dos','win32','win16','os2'):
# XXX Others too ?
return default
try:
f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
except (AttributeError,os.error):
retur... | Interface to the system's uname command.
| _syscmd_uname | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def architecture(executable=sys.executable,bits='',linkage=''):
""" Queries the given executable (defaults to the Python interpreter
binary) for various architecture information.
Returns a tuple (bits,linkage) which contains information about
the bit architecture and the linkage format use... | Queries the given executable (defaults to the Python interpreter
binary) for various architecture information.
Returns a tuple (bits,linkage) which contains information about
the bit architecture and the linkage format used for the
executable. Both values are returned as strings.
... | architecture | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def uname():
""" Fairly portable uname interface. Returns a tuple
of strings (system,node,release,version,machine,processor)
identifying the underlying platform.
Note that unlike the os.uname function this also returns
possible processor information as an additional tuple entry.
... | Fairly portable uname interface. Returns a tuple
of strings (system,node,release,version,machine,processor)
identifying the underlying platform.
Note that unlike the os.uname function this also returns
possible processor information as an additional tuple entry.
Entries which ... | uname | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def _sys_version(sys_version=None):
""" Returns a parsed version of Python's sys.version as tuple
(name, version, branch, revision, buildno, builddate, compiler)
referring to the Python implementation name, version, branch,
revision, build number, build date/time as string and the compiler
... | Returns a parsed version of Python's sys.version as tuple
(name, version, branch, revision, buildno, builddate, compiler)
referring to the Python implementation name, version, branch,
revision, build number, build date/time as string and the compiler
identification string.
Note... | _sys_version | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def platform(aliased=0, terse=0):
""" Returns a single string identifying the underlying platform
with as much useful information as possible (but no more :).
The output is intended to be human readable rather than
machine parseable. It may look different on different
platforms and... | Returns a single string identifying the underlying platform
with as much useful information as possible (but no more :).
The output is intended to be human readable rather than
machine parseable. It may look different on different
platforms and this is intended.
If "aliased" i... | platform | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/platform.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/platform.py | MIT |
def readPlist(pathOrFile):
"""Read a .plist file. 'pathOrFile' may either be a file name or a
(readable) file object. Return the unpacked root object (which
usually is a dictionary).
"""
didOpen = 0
if isinstance(pathOrFile, (str, unicode)):
pathOrFile = open(pathOrFile)
didOpen ... | Read a .plist file. 'pathOrFile' may either be a file name or a
(readable) file object. Return the unpacked root object (which
usually is a dictionary).
| readPlist | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/plistlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/plistlib.py | MIT |
def writePlist(rootObject, pathOrFile):
"""Write 'rootObject' to a .plist file. 'pathOrFile' may either be a
file name or a (writable) file object.
"""
didOpen = 0
if isinstance(pathOrFile, (str, unicode)):
pathOrFile = open(pathOrFile, "w")
didOpen = 1
writer = PlistWriter(pathO... | Write 'rootObject' to a .plist file. 'pathOrFile' may either be a
file name or a (writable) file object.
| writePlist | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/plistlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/plistlib.py | MIT |
def writePlistToString(rootObject):
"""Return 'rootObject' as a plist-formatted string.
"""
f = StringIO()
writePlist(rootObject, f)
return f.getvalue() | Return 'rootObject' as a plist-formatted string.
| writePlistToString | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/plistlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/plistlib.py | MIT |
def readPlistFromResource(path, restype='plst', resid=0):
"""Read plst resource from the resource fork of path.
"""
warnings.warnpy3k("In 3.x, readPlistFromResource is removed.",
stacklevel=2)
from Carbon.File import FSRef, FSGetResourceForkName
from Carbon.Files import fsRdPer... | Read plst resource from the resource fork of path.
| readPlistFromResource | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/plistlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/plistlib.py | MIT |
def writePlistToResource(rootObject, path, restype='plst', resid=0):
"""Write 'rootObject' as a plst resource to the resource fork of path.
"""
warnings.warnpy3k("In 3.x, writePlistToResource is removed.", stacklevel=2)
from Carbon.File import FSRef, FSGetResourceForkName
from Carbon.Files import fs... | Write 'rootObject' as a plst resource to the resource fork of path.
| writePlistToResource | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/plistlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/plistlib.py | MIT |
def fromFile(cls, pathOrFile):
"""Deprecated. Use the readPlist() function instead."""
rootObject = readPlist(pathOrFile)
plist = cls()
plist.update(rootObject)
return plist | Deprecated. Use the readPlist() function instead. | fromFile | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/plistlib.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/plistlib.py | MIT |
def __init__(self, cmd, capturestderr=False, bufsize=-1):
"""The parameter 'cmd' is the shell command to execute in a
sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments
will be passed directly to the program without shell intervention (as
with os.spawnv()). If 'cmd'... | The parameter 'cmd' is the shell command to execute in a
sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments
will be passed directly to the program without shell intervention (as
with os.spawnv()). If 'cmd' is a string it will be passed to the shell
(as with os.syste... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/popen2.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/popen2.py | MIT |
def poll(self, _deadstate=None):
"""Return the exit status of the child process if it has finished,
or -1 if it hasn't finished yet."""
if self.sts < 0:
try:
pid, sts = os.waitpid(self.pid, os.WNOHANG)
# pid will be 0 if self.pid hasn't terminated
... | Return the exit status of the child process if it has finished,
or -1 if it hasn't finished yet. | poll | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/popen2.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/popen2.py | MIT |
def wait(self):
"""Wait for and return the exit status of the child process."""
if self.sts < 0:
pid, sts = os.waitpid(self.pid, 0)
# This used to be a test, but it is believed to be
# always true, so I changed it to an assertion - mvl
assert pid == self.p... | Wait for and return the exit status of the child process. | wait | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/popen2.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/popen2.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.