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 b32encode(s):
"""Encode a string using Base32.
s is the string to encode. The encoded string is returned.
"""
parts = []
quanta, leftover = divmod(len(s), 5)
# Pad the last quantum with zero bits if necessary
if leftover:
s += ('\0' * (5 - leftover))
quanta += 1
for... | Encode a string using Base32.
s is the string to encode. The encoded string is returned.
| b32encode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/base64.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/base64.py | MIT |
def b32decode(s, casefold=False, map01=None):
"""Decode a Base32 encoded string.
s is the string to decode. Optional casefold is a flag specifying whether
a lowercase alphabet is acceptable as input. For security purposes, the
default is False.
RFC 3548 allows for optional mapping of the digit 0... | Decode a Base32 encoded string.
s is the string to decode. Optional casefold is a flag specifying whether
a lowercase alphabet is acceptable as input. For security purposes, the
default is False.
RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O
(oh), and for optional ma... | b32decode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/base64.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/base64.py | MIT |
def b16decode(s, casefold=False):
"""Decode a Base16 encoded string.
s is the string to decode. Optional casefold is a flag specifying whether
a lowercase alphabet is acceptable as input. For security purposes, the
default is False.
The decoded string is returned. A TypeError is raised if s is
... | Decode a Base16 encoded string.
s is the string to decode. Optional casefold is a flag specifying whether
a lowercase alphabet is acceptable as input. For security purposes, the
default is False.
The decoded string is returned. A TypeError is raised if s is
incorrectly padded or if there are no... | b16decode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/base64.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/base64.py | MIT |
def encodestring(s):
"""Encode a string into multiple lines of base-64 data."""
pieces = []
for i in range(0, len(s), MAXBINSIZE):
chunk = s[i : i + MAXBINSIZE]
pieces.append(binascii.b2a_base64(chunk))
return "".join(pieces) | Encode a string into multiple lines of base-64 data. | encodestring | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/base64.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/base64.py | MIT |
def server_bind(self):
"""Override server_bind to store the server name."""
SocketServer.TCPServer.server_bind(self)
host, port = self.socket.getsockname()[:2]
self.server_name = socket.getfqdn(host)
self.server_port = port | Override server_bind to store the server name. | server_bind | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def parse_request(self):
"""Parse a request (internal).
The request should be stored in self.raw_requestline; the results
are in self.command, self.path, self.request_version and
self.headers.
Return True for success, False for failure; on failure, an
error is sent back... | Parse a request (internal).
The request should be stored in self.raw_requestline; the results
are in self.command, self.path, self.request_version and
self.headers.
Return True for success, False for failure; on failure, an
error is sent back.
| parse_request | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def handle_one_request(self):
"""Handle a single HTTP request.
You normally don't need to override this method; see the class
__doc__ string for information on how to handle specific HTTP
commands such as GET and POST.
"""
try:
self.raw_requestline = self.rf... | Handle a single HTTP request.
You normally don't need to override this method; see the class
__doc__ string for information on how to handle specific HTTP
commands such as GET and POST.
| handle_one_request | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def send_error(self, code, message=None):
"""Send and log an error reply.
Arguments are the error code, and a detailed message.
The detailed message defaults to the short entry matching the
response code.
This sends an error response (so it must be called before any
out... | Send and log an error reply.
Arguments are the error code, and a detailed message.
The detailed message defaults to the short entry matching the
response code.
This sends an error response (so it must be called before any
output has been generated), logs the error, and finally ... | send_error | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def send_response(self, code, message=None):
"""Send the response header and log the response code.
Also send two standard headers with the server software
version and the current date.
"""
self.log_request(code)
if message is None:
if code in self.responses... | Send the response header and log the response code.
Also send two standard headers with the server software
version and the current date.
| send_response | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def log_request(self, code='-', size='-'):
"""Log an accepted request.
This is called by send_response().
"""
self.log_message('"%s" %s %s',
self.requestline, str(code), str(size)) | Log an accepted request.
This is called by send_response().
| log_request | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def log_message(self, format, *args):
"""Log an arbitrary message.
This is used by all other logging functions. Override
it if you have specific logging wishes.
The first argument, FORMAT, is a format string for the
message to be logged. If the format string contains
... | Log an arbitrary message.
This is used by all other logging functions. Override
it if you have specific logging wishes.
The first argument, FORMAT, is a format string for the
message to be logged. If the format string contains
any % escapes requiring parameters, they should b... | log_message | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def date_time_string(self, timestamp=None):
"""Return the current date and time formatted for a message header."""
if timestamp is None:
timestamp = time.time()
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
... | Return the current date and time formatted for a message header. | date_time_string | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def log_date_time_string(self):
"""Return the current time formatted for logging."""
now = time.time()
year, month, day, hh, mm, ss, x, y, z = time.localtime(now)
s = "%02d/%3s/%04d %02d:%02d:%02d" % (
day, self.monthname[month], year, hh, mm, ss)
return s | Return the current time formatted for logging. | log_date_time_string | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def test(HandlerClass = BaseHTTPRequestHandler,
ServerClass = HTTPServer, protocol="HTTP/1.0"):
"""Test the HTTP request handler class.
This runs an HTTP server on port 8000 (or the first command line
argument).
"""
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port ... | Test the HTTP request handler class.
This runs an HTTP server on port 8000 (or the first command line
argument).
| test | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/BaseHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/BaseHTTPServer.py | MIT |
def __init__(self, get, name):
"""Constructor.
Arguments:
get - a function that gets the attribute value (by name)
name - a human-readable name for the original object
(suggestion: use repr(object))
"""
self._get_ = get
self._name_ = name | Constructor.
Arguments:
get - a function that gets the attribute value (by name)
name - a human-readable name for the original object
(suggestion: use repr(object))
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Bastion.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Bastion.py | MIT |
def __getattr__(self, name):
"""Get an as-yet undefined attribute value.
This calls the get() function that was passed to the
constructor. The result is stored as an instance variable so
that the next time the same attribute is requested,
__getattr__() won't be invoked.
... | Get an as-yet undefined attribute value.
This calls the get() function that was passed to the
constructor. The result is stored as an instance variable so
that the next time the same attribute is requested,
__getattr__() won't be invoked.
If the get() function raises an except... | __getattr__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Bastion.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Bastion.py | MIT |
def Bastion(object, filter = lambda name: name[:1] != '_',
name=None, bastionclass=BastionClass):
"""Create a bastion for an object, using an optional filter.
See the Bastion module's documentation for background.
Arguments:
object - the original object
filter - a predicate that decid... | Create a bastion for an object, using an optional filter.
See the Bastion module's documentation for background.
Arguments:
object - the original object
filter - a predicate that decides whether a function name is OK;
by default all names are OK that don't start with '_'
name - the n... | Bastion | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Bastion.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Bastion.py | MIT |
def get1(name, object=object, filter=filter):
"""Internal function for Bastion(). See source comments."""
if filter(name):
attribute = getattr(object, name)
if type(attribute) == MethodType:
return attribute
raise AttributeError, name | Internal function for Bastion(). See source comments. | get1 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/Bastion.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/Bastion.py | MIT |
def set_step(self):
"""Stop after one line of code."""
# Issue #13183: pdb skips frames after hitting a breakpoint and running
# step commands.
# Restore the trace function in the caller (that may not have been set
# for performance reasons) when returning from the current frame.... | Stop after one line of code. | set_step | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bdb.py | MIT |
def set_trace(self, frame=None):
"""Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame.
"""
if frame is None:
frame = sys._getframe().f_back
self.reset()
while frame:
frame.f_trace = self.trace_dispatch
... | Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame.
| set_trace | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bdb.py | MIT |
def checkfuncname(b, frame):
"""Check whether we should break here because of `b.funcname`."""
if not b.funcname:
# Breakpoint was set via line number.
if b.line != frame.f_lineno:
# Breakpoint was set at a line with a def statement and the function
# defined is called: d... | Check whether we should break here because of `b.funcname`. | checkfuncname | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bdb.py | MIT |
def effective(file, line, frame):
"""Determine which breakpoint for this file:line is to be acted upon.
Called only if we know there is a bpt at this
location. Returns breakpoint that was triggered and a flag
that indicates if it is ok to delete a temporary bp.
"""
possibles = Breakpoint.bpli... | Determine which breakpoint for this file:line is to be acted upon.
Called only if we know there is a bpt at this
location. Returns breakpoint that was triggered and a flag
that indicates if it is ok to delete a temporary bp.
| effective | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bdb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bdb.py | MIT |
def binhex(inp, out):
"""(infilename, outfilename) - Create binhex-encoded copy of a file"""
finfo = getfileinfo(inp)
ofp = BinHex(finfo, out)
ifp = open(inp, 'rb')
# XXXX Do textfile translation on non-mac systems
while 1:
d = ifp.read(128000)
if not d: break
ofp.write(... | (infilename, outfilename) - Create binhex-encoded copy of a file | binhex | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/binhex.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/binhex.py | MIT |
def read(self, totalwtd):
"""Read at least wtd bytes (or until EOF)"""
decdata = ''
wtd = totalwtd
#
# The loop here is convoluted, since we don't really now how
# much to decode: there may be newlines in the incoming data.
while wtd > 0:
if self.eof: ... | Read at least wtd bytes (or until EOF) | read | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/binhex.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/binhex.py | MIT |
def insort_right(a, x, lo=0, hi=None):
"""Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the right of the rightmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
"""
if lo < 0:
raise V... | Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the right of the rightmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
| insort_right | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bisect.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bisect.py | MIT |
def bisect_right(a, x, lo=0, hi=None):
"""Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e <= x, and all e in
a[i:] have e > x. So if x already appears in the list, a.insert(x) will
insert just after the rightmost x already ... | Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e <= x, and all e in
a[i:] have e > x. So if x already appears in the list, a.insert(x) will
insert just after the rightmost x already there.
Optional args lo (default 0) and h... | bisect_right | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bisect.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bisect.py | MIT |
def insort_left(a, x, lo=0, hi=None):
"""Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the left of the leftmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
"""
if lo < 0:
raise Valu... | Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the left of the leftmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
| insort_left | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bisect.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bisect.py | MIT |
def bisect_left(a, x, lo=0, hi=None):
"""Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e < x, and all e in
a[i:] have e >= x. So if x already appears in the list, a.insert(x) will
insert just before the leftmost x already t... | Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e < x, and all e in
a[i:] have e >= x. So if x already appears in the list, a.insert(x) will
insert just before the leftmost x already there.
Optional args lo (default 0) and h... | bisect_left | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/bisect.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/bisect.py | MIT |
def leapdays(y1, y2):
"""Return number of leap years in range [y1, y2).
Assume y1 <= y2."""
y1 -= 1
y2 -= 1
return (y2//4 - y1//4) - (y2//100 - y1//100) + (y2//400 - y1//400) | Return number of leap years in range [y1, y2).
Assume y1 <= y2. | leapdays | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def monthrange(year, month):
"""Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for
year, month."""
if not 1 <= month <= 12:
raise IllegalMonthError(month)
day1 = weekday(year, month, 1)
ndays = mdays[month] + (month == February and isleap(year))
return day1, ndays | Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for
year, month. | monthrange | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def itermonthdates(self, year, month):
"""
Return an iterator for one month. The iterator will yield datetime.date
values and will always iterate through complete weeks, so it will yield
dates outside the specified month.
"""
date = datetime.date(year, month, 1)
#... |
Return an iterator for one month. The iterator will yield datetime.date
values and will always iterate through complete weeks, so it will yield
dates outside the specified month.
| itermonthdates | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def itermonthdays2(self, year, month):
"""
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
"""
for date in self.itermonthdates(year, month):
if date.month != month:
yi... |
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
| itermonthdays2 | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def itermonthdays(self, year, month):
"""
Like itermonthdates(), but will yield day numbers. For days outside
the specified month the day number is 0.
"""
for date in self.itermonthdates(year, month):
if date.month != month:
yield 0
else:
... |
Like itermonthdates(), but will yield day numbers. For days outside
the specified month the day number is 0.
| itermonthdays | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def monthdatescalendar(self, year, month):
"""
Return a matrix (list of lists) representing a month's calendar.
Each row represents a week; week entries are datetime.date values.
"""
dates = list(self.itermonthdates(year, month))
return [ dates[i:i+7] for i in range(0, le... |
Return a matrix (list of lists) representing a month's calendar.
Each row represents a week; week entries are datetime.date values.
| monthdatescalendar | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def monthdays2calendar(self, year, month):
"""
Return a matrix representing a month's calendar.
Each row represents a week; week entries are
(day number, weekday number) tuples. Day numbers outside this month
are zero.
"""
days = list(self.itermonthdays2(year, mon... |
Return a matrix representing a month's calendar.
Each row represents a week; week entries are
(day number, weekday number) tuples. Day numbers outside this month
are zero.
| monthdays2calendar | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def monthdayscalendar(self, year, month):
"""
Return a matrix representing a month's calendar.
Each row represents a week; days outside this month are zero.
"""
days = list(self.itermonthdays(year, month))
return [ days[i:i+7] for i in range(0, len(days), 7) ] |
Return a matrix representing a month's calendar.
Each row represents a week; days outside this month are zero.
| monthdayscalendar | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def yeardatescalendar(self, year, width=3):
"""
Return the data for the specified year ready for formatting. The return
value is a list of month rows. Each month row contains up to width months.
Each month contains between 4 and 6 weeks and each week contains 1-7
days. Days are d... |
Return the data for the specified year ready for formatting. The return
value is a list of month rows. Each month row contains up to width months.
Each month contains between 4 and 6 weeks and each week contains 1-7
days. Days are datetime.date objects.
| yeardatescalendar | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def yeardays2calendar(self, year, width=3):
"""
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are
(day number, weekday number) tuples. Day numbers outside this month are
zero.
"""
months = [... |
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are
(day number, weekday number) tuples. Day numbers outside this month are
zero.
| yeardays2calendar | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def yeardayscalendar(self, year, width=3):
"""
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are day numbers.
Day numbers outside this month are zero.
"""
months = [
self.monthdayscalend... |
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are day numbers.
Day numbers outside this month are zero.
| yeardayscalendar | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatmonth(self, theyear, themonth, w=0, l=0):
"""
Return a month's calendar string (multi-line).
"""
w = max(2, w)
l = max(1, l)
s = self.formatmonthname(theyear, themonth, 7 * (w + 1) - 1)
s = s.rstrip()
s += '\n' * l
s += self.formatweekhea... |
Return a month's calendar string (multi-line).
| formatmonth | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatyear(self, theyear, w=2, l=1, c=6, m=3):
"""
Returns a year's calendar as a multi-line string.
"""
w = max(2, w)
l = max(1, l)
c = max(2, c)
colwidth = (w + 1) * 7 - 1
v = []
a = v.append
a(repr(theyear).center(colwidth*m+c*(m-1))... |
Returns a year's calendar as a multi-line string.
| formatyear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatweek(self, theweek):
"""
Return a complete week as a table row.
"""
s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
return '<tr>%s</tr>' % s |
Return a complete week as a table row.
| formatweek | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatweekheader(self):
"""
Return a header for a week as a table row.
"""
s = ''.join(self.formatweekday(i) for i in self.iterweekdays())
return '<tr>%s</tr>' % s |
Return a header for a week as a table row.
| formatweekheader | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatmonthname(self, theyear, themonth, withyear=True):
"""
Return a month name as a table row.
"""
if withyear:
s = '%s %s' % (month_name[themonth], theyear)
else:
s = '%s' % month_name[themonth]
return '<tr><th colspan="7" class="month">%s</... |
Return a month name as a table row.
| formatmonthname | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatyear(self, theyear, width=3):
"""
Return a formatted year as a table of tables.
"""
v = []
a = v.append
width = max(width, 1)
a('<table border="0" cellpadding="0" cellspacing="0" class="year">')
a('\n')
a('<tr><th colspan="%d" class="year... |
Return a formatted year as a table of tables.
| formatyear | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
"""
Return a formatted year as a complete HTML page.
"""
if encoding is None:
encoding = sys.getdefaultencoding()
v = []
a = v.append
a('<?xml version="1.0" encoding="%s"?>\... |
Return a formatted year as a complete HTML page.
| formatyearpage | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def formatstring(cols, colwidth=_colwidth, spacing=_spacing):
"""Returns a string formatted from n strings, centered within n columns."""
spacing *= ' '
return spacing.join(c.center(colwidth) for c in cols) | Returns a string formatted from n strings, centered within n columns. | formatstring | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def timegm(tuple):
"""Unrelated but handy function to calculate Unix timestamp from GMT."""
year, month, day, hour, minute, second = tuple[:6]
days = datetime.date(year, month, 1).toordinal() - _EPOCH_ORD + day - 1
hours = days*24 + hour
minutes = hours*60 + minute
seconds = minutes*60 + second
... | Unrelated but handy function to calculate Unix timestamp from GMT. | timegm | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/calendar.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/calendar.py | MIT |
def initlog(*allargs):
"""Write a log message, if there is a log file.
Even though this function is called initlog(), you should always
use log(); log is a variable that is set either to initlog
(initially), to dolog (once the log file has been opened), or to
nolog (when logging is disabled).
... | Write a log message, if there is a log file.
Even though this function is called initlog(), you should always
use log(); log is a variable that is set either to initlog
(initially), to dolog (once the log file has been opened), or to
nolog (when logging is disabled).
The first argument is a format... | initlog | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
"""Parse a query in the environment or from a file (default stdin)
Arguments, all optional:
fp : file pointer; default: sys.stdin
environ : environment dictionary; default: os.environ
... | Parse a query in the environment or from a file (default stdin)
Arguments, all optional:
fp : file pointer; default: sys.stdin
environ : environment dictionary; default: os.environ
keep_blank_values: flag indicating whether blank values in
percent-enc... | parse | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
"""Parse a query given as a string argument."""
warn("cgi.parse_qs is deprecated, use urlparse.parse_qs instead",
PendingDeprecationWarning, 2)
return urlparse.parse_qs(qs, keep_blank_values, strict_parsing) | Parse a query given as a string argument. | parse_qs | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
"""Parse a query given as a string argument."""
warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
PendingDeprecationWarning, 2)
return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing) | Parse a query given as a string argument. | parse_qsl | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def parse_header(line):
"""Parse a Content-type like header.
Return the main content-type and a dictionary of options.
"""
parts = _parseparam(';' + line)
key = parts.next()
pdict = {}
for p in parts:
i = p.find('=')
if i >= 0:
name = p[:i].strip().lower()
... | Parse a Content-type like header.
Return the main content-type and a dictionary of options.
| parse_header | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def __init__(self, name, value):
"""Constructor from field name and value."""
self.name = name
self.value = value
# self.file = StringIO(value) | Constructor from field name and value. | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def __init__(self, fp=None, headers=None, outerboundary="",
environ=os.environ, keep_blank_values=0, strict_parsing=0):
"""Constructor. Read multipart/* until last part.
Arguments, all optional:
fp : file pointer; default: sys.stdin
(not used when the... | Constructor. Read multipart/* until last part.
Arguments, all optional:
fp : file pointer; default: sys.stdin
(not used when the request method is GET)
headers : header dictionary-like object; default:
taken from environ as per CGI spec
o... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def getvalue(self, key, default=None):
"""Dictionary style get() method, including 'value' lookup."""
if key in self:
value = self[key]
if type(value) is type([]):
return map(attrgetter('value'), value)
else:
return value.value
... | Dictionary style get() method, including 'value' lookup. | getvalue | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def read_urlencoded(self):
"""Internal: read data in query string format."""
qs = self.fp.read(self.length)
if self.qs_on_post:
qs += '&' + self.qs_on_post
self.list = list = []
for key, value in urlparse.parse_qsl(qs, self.keep_blank_values,
... | Internal: read data in query string format. | read_urlencoded | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def read_multi(self, environ, keep_blank_values, strict_parsing):
"""Internal: read a part that is itself multipart."""
ib = self.innerboundary
if not valid_boundary(ib):
raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
self.list = []
if self.qs_on_p... | Internal: read a part that is itself multipart. | read_multi | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def read_lines(self):
"""Internal: read lines until EOF or outerboundary."""
self.file = self.__file = StringIO()
if self.outerboundary:
self.read_lines_to_outerboundary()
else:
self.read_lines_to_eof() | Internal: read lines until EOF or outerboundary. | read_lines | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def skip_lines(self):
"""Internal: skip lines until outer boundary if defined."""
if not self.outerboundary or self.done:
return
next = "--" + self.outerboundary
last = next + "--"
last_line_lfend = True
while 1:
line = self.fp.readline(1<<16)
... | Internal: skip lines until outer boundary if defined. | skip_lines | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def test(environ=os.environ):
"""Robust test CGI script, usable as main program.
Write minimal HTTP headers and dump all information provided to
the script in HTML form.
"""
print "Content-type: text/html"
print
sys.stderr = sys.stdout
try:
form = FieldStorage() # Replace wit... | Robust test CGI script, usable as main program.
Write minimal HTTP headers and dump all information provided to
the script in HTML form.
| test | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def print_environ(environ=os.environ):
"""Dump the shell environment as HTML."""
keys = environ.keys()
keys.sort()
print
print "<H3>Shell Environment:</H3>"
print "<DL>"
for key in keys:
print "<DT>", escape(key), "<DD>", escape(environ[key])
print "</DL>"
print | Dump the shell environment as HTML. | print_environ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def print_form(form):
"""Dump the contents of a form as HTML."""
keys = form.keys()
keys.sort()
print
print "<H3>Form Contents:</H3>"
if not keys:
print "<P>No form fields."
print "<DL>"
for key in keys:
print "<DT>" + escape(key) + ":",
value = form[key]
... | Dump the contents of a form as HTML. | print_form | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def print_directory():
"""Dump the current directory as HTML."""
print
print "<H3>Current Working Directory:</H3>"
try:
pwd = os.getcwd()
except os.error, msg:
print "os.error:", escape(str(msg))
else:
print escape(pwd)
print | Dump the current directory as HTML. | print_directory | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def print_environ_usage():
"""Dump a list of environment variables used by CGI as HTML."""
print """
<H3>These environment variables could have been set:</H3>
<UL>
<LI>AUTH_TYPE
<LI>CONTENT_LENGTH
<LI>CONTENT_TYPE
<LI>DATE_GMT
<LI>DATE_LOCAL
<LI>DOCUMENT_NAME
<LI>DOCUMENT_ROOT
<LI>DOCUMENT_URI
<LI>GATEWAY_INTER... | Dump a list of environment variables used by CGI as HTML. | print_environ_usage | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def escape(s, quote=None):
'''Replace special characters "&", "<" and ">" to HTML-safe sequences.
If the optional flag quote is true, the quotation mark character (")
is also translated.'''
s = s.replace("&", "&") # Must be done first!
s = s.replace("<", "<")
s = s.replace(">", ">")
... | Replace special characters "&", "<" and ">" to HTML-safe sequences.
If the optional flag quote is true, the quotation mark character (")
is also translated. | escape | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgi.py | MIT |
def do_POST(self):
"""Serve a POST request.
This is only implemented for CGI scripts.
"""
if self.is_cgi():
self.run_cgi()
else:
self.send_error(501, "Can only POST to CGI scripts") | Serve a POST request.
This is only implemented for CGI scripts.
| do_POST | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/CGIHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/CGIHTTPServer.py | MIT |
def send_head(self):
"""Version of send_head that support CGI scripts"""
if self.is_cgi():
return self.run_cgi()
else:
return SimpleHTTPServer.SimpleHTTPRequestHandler.send_head(self) | Version of send_head that support CGI scripts | send_head | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/CGIHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/CGIHTTPServer.py | MIT |
def is_cgi(self):
"""Test whether self.path corresponds to a CGI script.
Returns True and updates the cgi_info attribute to the tuple
(dir, rest) if self.path requires running a CGI script.
Returns False otherwise.
If any exception is raised, the caller should assume that
... | Test whether self.path corresponds to a CGI script.
Returns True and updates the cgi_info attribute to the tuple
(dir, rest) if self.path requires running a CGI script.
Returns False otherwise.
If any exception is raised, the caller should assume that
self.path was rejected as ... | is_cgi | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/CGIHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/CGIHTTPServer.py | MIT |
def is_python(self, path):
"""Test whether argument path is a Python script."""
head, tail = os.path.splitext(path)
return tail.lower() in (".py", ".pyw") | Test whether argument path is a Python script. | is_python | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/CGIHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/CGIHTTPServer.py | MIT |
def nobody_uid():
"""Internal routine to get nobody's uid"""
global nobody
if nobody:
return nobody
try:
import pwd
except ImportError:
return -1
try:
nobody = pwd.getpwnam('nobody')[2]
except KeyError:
nobody = 1 + max(map(lambda x: x[2], pwd.getpwall... | Internal routine to get nobody's uid | nobody_uid | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/CGIHTTPServer.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/CGIHTTPServer.py | MIT |
def reset():
"""Return a string that resets the CGI and browser to a known state."""
return '''<!--: spam
Content-Type: text/html
<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> -->
<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> --> -->
</font> </font> </font> </script> </object> </blockquot... | Return a string that resets the CGI and browser to a known state. | reset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgitb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgitb.py | MIT |
def lookup(name, frame, locals):
"""Find the value for a given name in the given environment."""
if name in locals:
return 'local', locals[name]
if name in frame.f_globals:
return 'global', frame.f_globals[name]
if '__builtins__' in frame.f_globals:
builtins = frame.f_globals['__... | Find the value for a given name in the given environment. | lookup | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgitb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgitb.py | MIT |
def scanvars(reader, frame, locals):
"""Scan one logical line of Python and look up values of variables used."""
vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
for ttype, token, start, end, line in tokenize.generate_tokens(reader):
if ttype == tokenize.NEWLINE: break
... | Scan one logical line of Python and look up values of variables used. | scanvars | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgitb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgitb.py | MIT |
def html(einfo, context=5):
"""Return a nice HTML document describing a given traceback."""
etype, evalue, etb = einfo
if type(etype) is types.ClassType:
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
head = '<body... | Return a nice HTML document describing a given traceback. | html | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgitb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgitb.py | MIT |
def text(einfo, context=5):
"""Return a plain text document describing a given traceback."""
etype, evalue, etb = einfo
if type(etype) is types.ClassType:
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
head = "%s\n... | Return a plain text document describing a given traceback. | text | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cgitb.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cgitb.py | MIT |
def seek(self, pos, whence=0):
"""Seek to specified position into the chunk.
Default position is 0 (start of chunk).
If the file is not seekable, this will result in an error.
"""
if self.closed:
raise ValueError, "I/O operation on closed file"
if not self.se... | Seek to specified position into the chunk.
Default position is 0 (start of chunk).
If the file is not seekable, this will result in an error.
| seek | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/chunk.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/chunk.py | MIT |
def skip(self):
"""Skip the rest of the chunk.
If you are not interested in the contents of the chunk,
this method should be called so that the file points to
the start of the next chunk.
"""
if self.closed:
raise ValueError, "I/O operation on closed file"
... | Skip the rest of the chunk.
If you are not interested in the contents of the chunk,
this method should be called so that the file points to
the start of the next chunk.
| skip | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/chunk.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/chunk.py | MIT |
def __init__(self, completekey='tab', stdin=None, stdout=None):
"""Instantiate a line-oriented interpreter framework.
The optional argument 'completekey' is the readline name of a
completion key; it defaults to the Tab key. If completekey is
not None and the readline module is available... | Instantiate a line-oriented interpreter framework.
The optional argument 'completekey' is the readline name of a
completion key; it defaults to the Tab key. If completekey is
not None and the readline module is available, command completion
is done automatically. The optional arguments ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def cmdloop(self, intro=None):
"""Repeatedly issue a prompt, accept input, parse an initial prefix
off the received input, and dispatch to action methods, passing them
the remainder of the line as argument.
"""
self.preloop()
if self.use_rawinput and self.completekey:
... | Repeatedly issue a prompt, accept input, parse an initial prefix
off the received input, and dispatch to action methods, passing them
the remainder of the line as argument.
| cmdloop | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def parseline(self, line):
"""Parse the line into a command name and a string containing
the arguments. Returns a tuple containing (command, args, line).
'command' and 'args' may be None if the line couldn't be parsed.
"""
line = line.strip()
if not line:
ret... | Parse the line into a command name and a string containing
the arguments. Returns a tuple containing (command, args, line).
'command' and 'args' may be None if the line couldn't be parsed.
| parseline | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def onecmd(self, line):
"""Interpret the argument as though it had been typed in response
to the prompt.
This may be overridden, but should not normally need to be;
see the precmd() and postcmd() methods for useful execution hooks.
The return value is a flag indicating whether i... | Interpret the argument as though it had been typed in response
to the prompt.
This may be overridden, but should not normally need to be;
see the precmd() and postcmd() methods for useful execution hooks.
The return value is a flag indicating whether interpretation of
commands b... | onecmd | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def complete(self, text, state):
"""Return the next possible completion for 'text'.
If a command has not been entered, then complete against command list.
Otherwise try to call complete_<command> to get list of completions.
"""
if state == 0:
import readline
... | Return the next possible completion for 'text'.
If a command has not been entered, then complete against command list.
Otherwise try to call complete_<command> to get list of completions.
| complete | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def do_help(self, arg):
'List available commands with "help" or detailed help with "help cmd".'
if arg:
# XXX check arg syntax
try:
func = getattr(self, 'help_' + arg)
except AttributeError:
try:
doc=getattr(self, 'd... | List available commands with "help" or detailed help with "help cmd". | do_help | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def columnize(self, list, displaywidth=80):
"""Display a list of strings as a compact set of columns.
Each column is only as wide as necessary.
Columns are separated by two spaces (one was not legible enough).
"""
if not list:
self.stdout.write("<empty>\n")
... | Display a list of strings as a compact set of columns.
Each column is only as wide as necessary.
Columns are separated by two spaces (one was not legible enough).
| columnize | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/cmd.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/cmd.py | MIT |
def __init__(self, locals=None):
"""Constructor.
The optional 'locals' argument specifies the dictionary in
which code will be executed; it defaults to a newly created
dictionary with key "__name__" set to "__console__" and key
"__doc__" set to None.
"""
if loca... | Constructor.
The optional 'locals' argument specifies the dictionary in
which code will be executed; it defaults to a newly created
dictionary with key "__name__" set to "__console__" and key
"__doc__" set to None.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def runsource(self, source, filename="<input>", symbol="single"):
"""Compile and run some source in the interpreter.
Arguments are as for compile_command().
One several things can happen:
1) The input is incorrect; compile_command() raised an
exception (SyntaxError or Overflow... | Compile and run some source in the interpreter.
Arguments are as for compile_command().
One several things can happen:
1) The input is incorrect; compile_command() raised an
exception (SyntaxError or OverflowError). A syntax traceback
will be printed by calling the showsyntax... | runsource | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def runcode(self, code):
"""Execute a code object.
When an exception occurs, self.showtraceback() is called to
display a traceback. All exceptions are caught except
SystemExit, which is reraised.
A note about KeyboardInterrupt: this exception may occur
elsewhere in thi... | Execute a code object.
When an exception occurs, self.showtraceback() is called to
display a traceback. All exceptions are caught except
SystemExit, which is reraised.
A note about KeyboardInterrupt: this exception may occur
elsewhere in this code, and may not always be caught... | runcode | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def showsyntaxerror(self, filename=None):
"""Display the syntax error that just occurred.
This doesn't display a stack trace because there isn't one.
If a filename is given, it is stuffed in the exception instead
of what was there before (because Python's parser always uses
"<s... | Display the syntax error that just occurred.
This doesn't display a stack trace because there isn't one.
If a filename is given, it is stuffed in the exception instead
of what was there before (because Python's parser always uses
"<string>" when reading from a string).
The out... | showsyntaxerror | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def showtraceback(self):
"""Display the exception that just occurred.
We remove the first stack item because it is our own code.
The output is written by self.write(), below.
"""
try:
type, value, tb = sys.exc_info()
sys.last_type = type
sys... | Display the exception that just occurred.
We remove the first stack item because it is our own code.
The output is written by self.write(), below.
| showtraceback | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def __init__(self, locals=None, filename="<console>"):
"""Constructor.
The optional locals argument will be passed to the
InteractiveInterpreter base class.
The optional filename argument should specify the (file)name
of the input stream; it will show up in tracebacks.
... | Constructor.
The optional locals argument will be passed to the
InteractiveInterpreter base class.
The optional filename argument should specify the (file)name
of the input stream; it will show up in tracebacks.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def interact(self, banner=None):
"""Closely emulate the interactive Python console.
The optional banner argument specify the banner to print
before the first interaction; by default it prints a banner
similar to the one printed by the real Python interpreter,
followed by the cur... | Closely emulate the interactive Python console.
The optional banner argument specify the banner to print
before the first interaction; by default it prints a banner
similar to the one printed by the real Python interpreter,
followed by the current class name in parentheses (so as not
... | interact | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def push(self, line):
"""Push a line to the interpreter.
The line should not have a trailing newline; it may have
internal newlines. The line is appended to a buffer and the
interpreter's runsource() method is called with the
concatenated contents of the buffer as source. If t... | Push a line to the interpreter.
The line should not have a trailing newline; it may have
internal newlines. The line is appended to a buffer and the
interpreter's runsource() method is called with the
concatenated contents of the buffer as source. If this
indicates that the co... | push | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def interact(banner=None, readfunc=None, local=None):
"""Closely emulate the interactive Python interpreter.
This is a backwards compatible interface to the InteractiveConsole
class. When readfunc is not specified, it attempts to import the
readline module to enable GNU readline if it is available.
... | Closely emulate the interactive Python interpreter.
This is a backwards compatible interface to the InteractiveConsole
class. When readfunc is not specified, it attempts to import the
readline module to enable GNU readline if it is available.
Arguments (all optional, all default to None):
banner... | interact | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/code.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/code.py | MIT |
def __init__(self, errors='strict'):
"""
Creates an IncrementalEncoder instance.
The IncrementalEncoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
"""
self.errors = er... |
Creates an IncrementalEncoder instance.
The IncrementalEncoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def reset(self):
"""
Resets the encoder to the initial state.
""" |
Resets the encoder to the initial state.
| reset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def setstate(self, state):
"""
Set the current state of the encoder. state must have been
returned by getstate().
""" |
Set the current state of the encoder. state must have been
returned by getstate().
| setstate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def reset(self):
"""
Resets the decoder to the initial state.
""" |
Resets the decoder to the initial state.
| reset | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def setstate(self, state):
"""
Set the current state of the decoder.
state must have been returned by getstate(). The effect of
setstate((b"", 0)) must be equivalent to reset().
""" |
Set the current state of the decoder.
state must have been returned by getstate(). The effect of
setstate((b"", 0)) must be equivalent to reset().
| setstate | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
def __init__(self, stream, errors='strict'):
""" Creates a StreamWriter instance.
stream must be a file-like object open for writing
(binary) data.
The StreamWriter may use different error handling
schemes by providing the errors keyword argument. These
... | Creates a StreamWriter instance.
stream must be a file-like object open for writing
(binary) data.
The StreamWriter may use different error handling
schemes by providing the errors keyword argument. These
parameters are predefined:
'strict' - ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pywin/Lib/codecs.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pywin/Lib/codecs.py | MIT |
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.