_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q252900 | date.isocalendar | validation | def isocalendar(self):
"""Return a 3-tuple containing ISO year, week number, and weekday.
The first ISO week of the year is the (Mon-Sun) week
containing the year's first Thursday; everything else derives
from that.
The first week is 1; Monday is 1 ... Sunday is 7.
ISO... | python | {
"resource": ""
} |
q252901 | time.tzname | validation | def tzname(self):
"""Return the timezone name.
Note that the name is 100% informational -- there's no requirement that
it mean anything in particular. For example, "GMT", "UTC", "-500",
"-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
"""
| python | {
"resource": ""
} |
q252902 | time.replace | validation | def replace(self, hour=None, minute=None, second=None, microsecond=None,
tzinfo=True):
"""Return a new time with new values for the specified fields."""
if hour is None:
hour = self.hour
if minute is None: | python | {
"resource": ""
} |
q252903 | datetime.combine | validation | def combine(cls, date, time):
"Construct a datetime from a given date and a given time."
if not isinstance(date, _date_class):
raise TypeError("date argument must be a date instance")
if not isinstance(time, _time_class):
raise TypeError("time argument must be a time inst... | python | {
"resource": ""
} |
q252904 | datetime.time | validation | def time(self):
"Return the time part, with tzinfo None."
| python | {
"resource": ""
} |
q252905 | datetime.timetz | validation | def timetz(self):
"Return the time part, with same tzinfo."
| python | {
"resource": ""
} |
q252906 | datetime.replace | validation | def replace(self, year=None, month=None, day=None, hour=None,
minute=None, second=None, microsecond=None, tzinfo=True):
"""Return a new datetime with new values for the specified fields."""
if year is None:
year = self.year
if month is None:
month = self.m... | python | {
"resource": ""
} |
q252907 | concat | validation | def concat(a, b):
"Same as a + b, for a and b sequences."
if not hasattr(a, '__getitem__'):
| python | {
"resource": ""
} |
q252908 | countOf | validation | def countOf(a, b):
"Return the number of times b occurs in a."
count = 0
for i in a:
| python | {
"resource": ""
} |
q252909 | indexOf | validation | def indexOf(a, b):
"Return the first index of b in a."
for i, j in enumerate(a):
| python | {
"resource": ""
} |
q252910 | iconcat | validation | def iconcat(a, b):
"Same as a += b, for a and b sequences."
if not hasattr(a, '__getitem__'):
| python | {
"resource": ""
} |
q252911 | encode_basestring | validation | def encode_basestring(s):
"""Return a JSON representation of a Python string
"""
def replace(match):
| python | {
"resource": ""
} |
q252912 | sub | validation | def sub(pattern, repl, string, count=0, flags=0):
"""Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. | python | {
"resource": ""
} |
q252913 | split | validation | def split(pattern, string, maxsplit=0, flags=0):
"""Split the source string by the occurrences of the pattern,
returning a | python | {
"resource": ""
} |
q252914 | findall | validation | def findall(pattern, string, flags=0):
"""Return a list of all non-overlapping matches in the string.
If one or more groups are present in the pattern, return a
list of groups; this will be a list of tuples if the pattern
has more than one group.
Empty matches are included in the result."""
re... | python | {
"resource": ""
} |
q252915 | escape | validation | def escape(pattern):
"Escape all non-alphanumeric characters in pattern."
s = list(pattern)
alphanum = _alphanum
for i, c in enumerate(pattern):
if c not in alphanum:
if c == "\000":
| python | {
"resource": ""
} |
q252916 | Block.free_temp | validation | def free_temp(self, v):
"""Release the GeneratedTempVar v so it can be reused."""
| python | {
"resource": ""
} |
q252917 | decode | validation | def decode(in_file, out_file=None, mode=None, quiet=0):
"""Decode uuencoded file"""
#
# Open the input file, if needed.
#
opened_files = []
if in_file == '-':
in_file = sys.stdin
elif isinstance(in_file, basestring):
in_file = open(in_file)
opened_files.append(in_file... | python | {
"resource": ""
} |
q252918 | get_close_matches | validation | def get_close_matches(word, possibilities, n=3, cutoff=0.6):
"""Use SequenceMatcher to return list of the best "good enough" matches.
word is a sequence for which close matches are desired (typically a
string).
possibilities is a list of sequences against which to match word
(typically a list of s... | python | {
"resource": ""
} |
q252919 | _count_leading | validation | def _count_leading(line, ch):
"""
Return number of `ch` characters at the start of `line`.
| python | {
"resource": ""
} |
q252920 | unified_diff | validation | def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
tofiledate='', n=3, lineterm='\n'):
r"""
Compare two sequences of lines; generate the delta as a unified diff.
Unified diffs are a compact way of showing line changes and a few
lines of context. The number of context line... | python | {
"resource": ""
} |
q252921 | context_diff | validation | def context_diff(a, b, fromfile='', tofile='',
fromfiledate='', tofiledate='', n=3, lineterm='\n'):
r"""
Compare two sequences of lines; generate the delta as a context diff.
Context diffs are a compact way of showing line changes and a few
lines of context. The number of context line... | python | {
"resource": ""
} |
q252922 | restore | validation | def restore(delta, which):
r"""
Generate one of the two sequences that generated a delta.
Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract
lines originating from file 1 or 2 (parameter `which`), stripping off line
prefixes.
Examples:
>>> diff = ndiff('one\ntwo\nthree\n... | python | {
"resource": ""
} |
q252923 | Match._make | validation | def _make(cls, iterable, new=tuple.__new__, len=len):
'Make a new Match object from a sequence or iterable'
result = new(cls, iterable)
if len(result) != 3:
| python | {
"resource": ""
} |
q252924 | SequenceMatcher.set_seq1 | validation | def set_seq1(self, a):
"""Set the first sequence to be compared.
The second sequence to be compared is not changed.
>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
0.75
>>> s.set_seq1("bcde")
>>> s.ratio()
1.0
>>>
SequenceMat... | python | {
"resource": ""
} |
q252925 | SequenceMatcher.set_seq2 | validation | def set_seq2(self, b):
"""Set the second sequence to be compared.
The first sequence to be compared is not changed.
>>> s = SequenceMatcher(None, "abcd", "bcde")
>>> s.ratio()
0.75
>>> s.set_seq2("abcd")
>>> s.ratio()
1.0
>>>
SequenceMat... | python | {
"resource": ""
} |
q252926 | SequenceMatcher.get_matching_blocks | validation | def get_matching_blocks(self):
"""Return list of triples describing matching subsequences.
Each triple is of the form (i, j, n), and means that
a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
i and in j. New in Python 2.5, it's also guaranteed that if
(i, j, ... | python | {
"resource": ""
} |
q252927 | SequenceMatcher.get_opcodes | validation | def get_opcodes(self):
"""Return list of 5-tuples describing how to turn a into b.
Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
tuple preceding it, and likewise for j1 == the previous j2.
Th... | python | {
"resource": ""
} |
q252928 | SequenceMatcher.get_grouped_opcodes | validation | def get_grouped_opcodes(self, n=3):
""" Isolate change clusters by eliminating ranges with no changes.
Return a generator of groups with up to n lines of context.
Each group is in the same format as returned by get_opcodes().
>>> from pprint import pprint
>>> a = map(str, range... | python | {
"resource": ""
} |
q252929 | Differ.compare | validation | def compare(self, a, b):
r"""
Compare two sequences of lines; generate the resulting delta.
Each sequence must contain individual single-line strings ending with
newlines. Such sequences can be obtained from the `readlines()` method
of file-like objects. The delta generated als... | python | {
"resource": ""
} |
q252930 | Differ._dump | validation | def _dump(self, tag, x, lo, hi):
"""Generate comparison results for | python | {
"resource": ""
} |
q252931 | Differ._qformat | validation | def _qformat(self, aline, bline, atags, btags):
r"""
Format "?" output and deal with leading tabs.
Example:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
... ' ^ ^ ^ ', ' ^ ^ ^ ')
>>> for lin... | python | {
"resource": ""
} |
q252932 | HtmlDiff.make_file | validation | def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False,
numlines=5):
"""Returns HTML file of side by side comparison with change highlights
Arguments:
fromlines -- list of "from" lines
tolines -- list of "to" lines
fromdesc -- "from" file colu... | python | {
"resource": ""
} |
q252933 | HtmlDiff._split_line | validation | def _split_line(self,data_list,line_num,text):
"""Builds list of text lines by splitting text lines at wrap point
This function will determine if the input text line needs to be
wrapped (split) into separate lines. If so, the first wrap point
will be determined and the first line appen... | python | {
"resource": ""
} |
q252934 | HtmlDiff._collect_lines | validation | def _collect_lines(self,diffs):
"""Collects mdiff output into separate lists
Before storing the mdiff from/to data into a list, it is converted
into a single line of text with HTML markup.
"""
fromlist,tolist,flaglist = [],[],[]
# pull from/to data and flags from mdiff ... | python | {
"resource": ""
} |
q252935 | HtmlDiff._make_prefix | validation | def _make_prefix(self):
"""Create unique anchor prefixes"""
# Generate a unique anchor prefix so multiple tables
# can exist on the same HTML page without conflicts.
| python | {
"resource": ""
} |
q252936 | HtmlDiff._convert_flags | validation | def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
"""Makes list of "next" links"""
# all anchor names will be generated using the unique "to" prefix
toprefix = self._prefix[1]
# process change flags, generating middle column of next anchors/links
next_id = [''... | python | {
"resource": ""
} |
q252937 | HtmlDiff.make_table | validation | def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
numlines=5):
"""Returns HTML table of side by side comparison with change highlights
Arguments:
fromlines -- list of "from" lines
tolines -- list of "to" lines
fromdesc -- "from" file c... | python | {
"resource": ""
} |
q252938 | _MakeParallelBenchmark | validation | def _MakeParallelBenchmark(p, work_func, *args):
"""Create and return a benchmark that runs work_func p times in parallel."""
def Benchmark(b): # pylint: disable=missing-docstring
e = threading.Event()
def Target():
e.wait()
for _ in xrange(b.N / p):
work_func(*args)
| python | {
"resource": ""
} |
q252939 | listdir | validation | def listdir(path):
"""List directory contents, using cache."""
try:
cached_mtime, list = cache[path]
del cache[path]
except KeyError:
cached_mtime, list = -1, []
| python | {
"resource": ""
} |
q252940 | pformat | validation | def pformat(o, indent=1, width=80, depth=None):
"""Format a Python o into | python | {
"resource": ""
} |
q252941 | PrettyPrinter.format | validation | def format(self, o, context, maxlevels, level):
"""Format o for a specific context, returning a string
and flags indicating whether the representation is 'readable'
and whether the o | python | {
"resource": ""
} |
q252942 | action | validation | def action(inner_rule, loc=None):
"""
A decorator returning a function that first runs ``inner_rule`` and then, if its
return value is not None, maps that value using ``mapper``.
If the value being mapped is a tuple, it is expanded into multiple arguments.
Similar to attaching semantic actions to ... | python | {
"resource": ""
} |
q252943 | Tok | validation | def Tok(kind, loc=None):
"""A rule that accepts a token of kind ``kind`` and returns it, or | python | {
"resource": ""
} |
q252944 | Loc | validation | def Loc(kind, loc=None):
"""A rule that accepts a token of kind ``kind`` and returns its location, or returns None."""
@llrule(loc, lambda parser: [kind])
def rule(parser):
result | python | {
"resource": ""
} |
q252945 | Rule | validation | def Rule(name, loc=None):
"""A proxy for a rule called ``name`` which may not be yet defined."""
@llrule(loc, lambda parser: getattr(parser, name).expected(parser)) | python | {
"resource": ""
} |
q252946 | Expect | validation | def Expect(inner_rule, loc=None):
"""A rule that executes ``inner_rule`` and emits a diagnostic error if it returns None."""
@llrule(loc, inner_rule.expected)
def rule(parser):
result = inner_rule(parser)
if result is unmatched:
expected = reduce(list.__add__, [rule.expected(pars... | python | {
"resource": ""
} |
q252947 | Seq | validation | def Seq(first_rule, *rest_of_rules, **kwargs):
"""
A rule that accepts a sequence of tokens satisfying ``rules`` and returns a tuple
containing their return values, or None if the first rule was not satisfied.
"""
@llrule(kwargs.get("loc", None), first_rule.expected)
| python | {
"resource": ""
} |
q252948 | SeqN | validation | def SeqN(n, *inner_rules, **kwargs):
"""
A rule that accepts a sequence of tokens satisfying ``rules`` and returns
the value returned by rule number ``n``, or None if the first rule was not satisfied.
""" | python | {
"resource": ""
} |
q252949 | Newline | validation | def Newline(loc=None):
"""A rule that accepts token of kind ``newline`` and returns an empty list."""
@llrule(loc, lambda parser: ["newline"])
def rule(parser):
result | python | {
"resource": ""
} |
q252950 | urljoin | validation | def urljoin(base, url, allow_fragments=True):
"""Join a base URL and a possibly relative URL to form an absolute
interpretation of the latter."""
if not base:
return url
if not url:
return base
bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
urlparse(base, '', all... | python | {
"resource": ""
} |
q252951 | urldefrag | validation | def urldefrag(url):
"""Removes any existing fragment from URL.
Returns a tuple of the defragmented URL and the fragment. If
the URL contained no fragments, the second element is the
empty string.
"""
if '#' in url:
s, n, p, | python | {
"resource": ""
} |
q252952 | _SplitResult._replace | validation | def _replace(_self, **kwds):
'Return a new SplitResult object replacing specified fields with new values'
result = _self._make(map(kwds.pop, ('scheme', | python | {
"resource": ""
} |
q252953 | getlines | validation | def getlines(filename, module_globals=None):
"""Get the lines for a file from the cache.
Update the cache if it doesn't contain an entry for this file already."""
if filename in cache:
return cache[filename][2]
try:
| python | {
"resource": ""
} |
q252954 | updatecache | validation | def updatecache(filename, module_globals=None):
"""Update a cache entry and return its list of lines.
If something's wrong, print a message, discard the cache entry,
and return an empty list."""
if filename in cache:
del cache[filename]
if not filename or (filename.startswith('<') and filen... | python | {
"resource": ""
} |
q252955 | isfile | validation | def isfile(path):
"""Test whether a path is a regular file"""
try:
st = os.stat(path)
except os.error:
| python | {
"resource": ""
} |
q252956 | isdir | validation | def isdir(s):
"""Return true if the pathname refers to an existing directory."""
try:
st = os.stat(s)
| python | {
"resource": ""
} |
q252957 | commonprefix | validation | def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m: return ''
s1 = min(m)
| python | {
"resource": ""
} |
q252958 | _splitext | validation | def _splitext(p, sep, altsep, extsep):
"""Split the extension from a pathname.
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty."""
sepIndex = p.rfind(sep)
if altsep:
altsepIndex = p.rfind(altsep)
sepIndex = max(s... | python | {
"resource": ""
} |
q252959 | wrap | validation | def wrap(text, width=70, **kwargs):
"""Wrap a single paragraph of text, returning a list of wrapped lines.
Reformat the single paragraph in 'text' so it fits in lines of no
more than 'width' columns, and return a list of wrapped | python | {
"resource": ""
} |
q252960 | fill | validation | def fill(text, width=70, **kwargs):
"""Fill a single paragraph of text, returning a new string.
Reformat the single paragraph in 'text' to fit in lines of no more
than 'width' columns, and return a new | python | {
"resource": ""
} |
q252961 | dedent | validation | def dedent(text):
"""Remove any common leading whitespace from every line in `text`.
This can be used to make triple-quoted strings line up with the left
edge of the display, while still presenting them in the source code
in indented form.
Note that tabs and spaces are both treated as whitespace, ... | python | {
"resource": ""
} |
q252962 | _long2bytesBigEndian | validation | def _long2bytesBigEndian(n, blocksize=0):
"""Convert a long integer to a byte string.
If optional blocksize is given and greater than zero, pad the front
of the byte string with binary zeros so that the length is a multiple
of blocksize.
"""
# After much testing, this algorithm was deemed to b... | python | {
"resource": ""
} |
q252963 | _bytelist2longBigEndian | validation | def _bytelist2longBigEndian(list):
"Transform a list of characters into a list of longs."
imax = len(list) // 4
hl = [0] * imax
j = 0
i = 0
while i < imax:
b0 = ord(list[j]) << 24
b1 = ord(list[j+1]) << | python | {
"resource": ""
} |
q252964 | sha.init | validation | def init(self):
"Initialize the message-digest and set all fields to zero."
self.length = 0
self.input = []
# Initial 160 bit message digest (5 times 32 bit).
self.H0 = 0x67452301
| python | {
"resource": ""
} |
q252965 | scheduler.enterabs | validation | def enterabs(self, time, priority, action, argument):
"""Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
"""
| python | {
"resource": ""
} |
q252966 | copy | validation | def copy(x):
"""Shallow copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
"""
cls = type(x)
copier = _copy_dispatch.get(cls)
if copier:
return copier(x)
copier = getattr(cls, "__copy__", None)
if copier:
return copier(x)
r... | python | {
"resource": ""
} |
q252967 | deepcopy | validation | def deepcopy(x, memo=None, _nil=[]):
"""Deep copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
"""
if memo is None:
memo = {}
d = id(x)
y = memo.get(d, _nil)
if y is not _nil:
return y
cls = type(x)
copier = _deepcopy_disp... | python | {
"resource": ""
} |
q252968 | _keep_alive | validation | 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... | python | {
"resource": ""
} |
q252969 | warnpy3k | validation | def warnpy3k(message, category=None, stacklevel=1):
"""Issue a deprecation warning for Python 3.x related changes.
Warnings are omitted unless Python is started with the -3 option.
"""
| python | {
"resource": ""
} |
q252970 | _show_warning | validation | def _show_warning(message, category, filename, lineno, file=None, line=None):
"""Hook to write a warning to a file; replace if you like."""
if file is None:
file = sys.stderr
if file is None:
# sys.stderr is None - warnings get lost
| python | {
"resource": ""
} |
q252971 | formatwarning | validation | def formatwarning(message, category, filename, lineno, line=None):
"""Function to format a warning the standard way."""
try:
unicodetype = unicode
except NameError:
unicodetype = ()
try:
message = str(message)
except UnicodeEncodeError:
pass
s = "%s: %s: %s\n" % ... | python | {
"resource": ""
} |
q252972 | warn | validation | def warn(message, category=None, stacklevel=1):
"""Issue a warning, or maybe ignore it or raise an exception."""
# Check if message is already a Warning object
if isinstance(message, Warning):
category = message.__class__
# Check category argument
if category is None:
category = User... | python | {
"resource": ""
} |
q252973 | Set._hash | validation | def _hash(self):
"""Compute the hash value of a set.
Note that we don't define __hash__: not all sets are hashable.
But if you define a hashable set type, its __hash__ should
call this function.
This must be compatible __eq__.
All sets ought to compare equal if they co... | python | {
"resource": ""
} |
q252974 | MutableSet.remove | validation | def remove(self, value):
"""Remove an element. If not a member, raise a KeyError."""
if value not in self:
| python | {
"resource": ""
} |
q252975 | MutableSet.pop | validation | def pop(self):
"""Return the popped value. Raise KeyError if empty."""
it = iter(self)
| python | {
"resource": ""
} |
q252976 | go_str | validation | def go_str(value):
"""Returns value as a valid Go string literal."""
io = StringIO.StringIO()
io.write('"')
for c in value:
if c in _ESCAPES:
io.write(_ESCAPES[c])
| python | {
"resource": ""
} |
q252977 | _RLock.acquire | validation | def acquire(self, blocking=1):
"""Acquire a lock, blocking or non-blocking.
When invoked without arguments: if this thread already owns the lock,
increment the recursion level by one, and return immediately. Otherwise,
if another thread owns the lock, block until the lock is unlocked. O... | python | {
"resource": ""
} |
q252978 | _RLock.release | validation | def release(self):
"""Release a lock, decrementing the recursion level.
If after the decrement it is zero, reset the lock to unlocked (not owned
by any thread), and if any other threads are blocked waiting for the
lock to become unlocked, allow exactly one of them to proceed. If after
... | python | {
"resource": ""
} |
q252979 | _Condition.wait | validation | def wait(self, timeout=None):
"""Wait until notified or until a timeout occurs.
If the calling thread has not acquired the lock when this method is
called, a RuntimeError is raised.
This method releases the underlying lock, and then blocks until it is
awakened by a notify() or ... | python | {
"resource": ""
} |
q252980 | _Condition.notify | validation | def notify(self, n=1):
"""Wake up one or more threads waiting on this condition, if any.
If the calling thread has not acquired the lock when this method is
called, a RuntimeError is raised.
This method wakes up at most n of the threads waiting for the condition
variable; it is... | python | {
"resource": ""
} |
q252981 | _Semaphore.acquire | validation | def acquire(self, blocking=1):
"""Acquire a semaphore, decrementing the internal counter by one.
When invoked without arguments: if the internal counter is larger than
zero on entry, decrement it by one and return immediately. If it is zero
on entry, block, waiting until some other thre... | python | {
"resource": ""
} |
q252982 | _Event.set | validation | def set(self):
"""Set the internal flag to true.
All threads waiting for the flag to become true are awakened. Threads
| python | {
"resource": ""
} |
q252983 | _Event.wait | validation | def wait(self, timeout=None):
"""Block until the internal flag is true.
If the internal flag is true on entry, return immediately. Otherwise,
block until another thread calls set() to set the flag to true, or until
the optional timeout occurs.
When the timeout argument is prese... | python | {
"resource": ""
} |
q252984 | Thread.start | validation | def start(self):
"""Start the thread's activity.
It must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the
same thread object.
... | python | {
"resource": ""
} |
q252985 | Thread.run | validation | def run(self):
"""Method representing the thread's activity.
You may override this method in a subclass. The standard run() method
invokes the callable object passed to the object's constructor as the
target argument, if any, with sequential and keyword arguments taken
from the ... | python | {
"resource": ""
} |
q252986 | Thread.join | validation | def join(self, timeout=None):
"""Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is
called terminates -- either normally or through an unhandled exception
or until the optional timeout occurs.
When the timeout argument is pr... | python | {
"resource": ""
} |
q252987 | ABCMeta._dump_registry | validation | def _dump_registry(cls, file=None):
"""Debug helper to print the ABC registry."""
print >> file, "Class: %s.%s" % (cls.__module__, cls.__name__)
print >> file, "Inv.counter: %s" % ABCMeta._abc_invalidation_counter
for name in sorted(cls.__dict__.keys()): | python | {
"resource": ""
} |
q252988 | b2a_qp | validation | def b2a_qp(data, quotetabs=False, istext=True, header=False):
"""quotetabs=True means that tab and space characters are always
quoted.
istext=False means that \r and \n are treated as regular characters
header=True encodes space characters with '_' and requires
real '_' characters to be ... | python | {
"resource": ""
} |
q252989 | rlecode_hqx | validation | def rlecode_hqx(s):
"""
Run length encoding for binhex4.
The CPython implementation does not do run length encoding
of \x90 characters. This implementation does.
"""
if not s:
return ''
result = []
prev = s[0]
count = 1
# Add a dummy character to get the loop to go one ex... | python | {
"resource": ""
} |
q252990 | HelpFormatter._format_text | validation | def _format_text(self, text):
"""
Format a paragraph of free-form text for inclusion in the
help output at the current indentation level.
"""
text_width = max(self.width - self.current_indent, 11)
indent = " "*self.current_indent
return textwrap.fill(text,
... | python | {
"resource": ""
} |
q252991 | HelpFormatter.format_option_strings | validation | def format_option_strings(self, option):
"""Return a comma-separated list of option strings & metavariables."""
if option.takes_value():
metavar = option.metavar or option.dest.upper()
short_opts = [self._short_opt_fmt % (sopt, metavar)
for sopt in optio... | python | {
"resource": ""
} |
q252992 | Values._update_careful | validation | def _update_careful(self, dict):
"""
Update the option values from an arbitrary dictionary, but only
use keys from dict that already have a corresponding attribute
in self. Any keys in dict without a corresponding attribute
are silently ignored.
""" | python | {
"resource": ""
} |
q252993 | insort_right | validation | 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:
| python | {
"resource": ""
} |
q252994 | mutex.lock | validation | def lock(self, function, argument):
"""Lock a mutex, call the function with supplied argument
when it is acquired. If the mutex is already locked, place
function and argument in the | python | {
"resource": ""
} |
q252995 | mutex.unlock | validation | def unlock(self):
"""Unlock a mutex. If the queue is not empty, call the next
function with its argument."""
if self.queue:
| python | {
"resource": ""
} |
q252996 | MD5Type.copy | validation | def copy(self):
"""Return a clone object.
Return a copy ('clone') of the md5 object. This can be used
to efficiently compute the digests of strings that share
a common initial substring.
"""
if 0: # set this to 1 to make the flow space crash
return copy.deepcopy(self)
clone = self.__... | python | {
"resource": ""
} |
q252997 | SRE_Pattern.search | validation | def search(self, string, pos=0, endpos=sys.maxint):
"""Scan through string looking for a location where this regular
expression produces a match, and return a corresponding MatchObject
instance. Return None if no position in the string matches the
pattern."""
| python | {
"resource": ""
} |
q252998 | SRE_Pattern.sub | validation | def sub(self, repl, string, count=0):
"""Return the string obtained by replacing the leftmost non-overlapping | python | {
"resource": ""
} |
q252999 | SRE_Pattern.split | validation | def split(self, string, maxsplit=0):
"""Split string by the occurrences of pattern."""
splitlist = []
state = _State(string, 0, sys.maxint, self.flags)
n = 0
last = state.start
while not maxsplit or n < maxsplit:
state.reset()
state.string_position... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.