id
int64
1
6.07M
name
stringlengths
1
295
code
stringlengths
12
426k
language
stringclasses
1 value
source_file
stringlengths
5
202
start_line
int64
1
158k
end_line
int64
1
158k
repo
dict
14,001
formatweekheader
def formatweekheader(self, width): """ Return a header for a week. """ return ' '.join(self.formatweekday(i, width) for i in self.iterweekdays())
python
Lib/calendar.py
363
367
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,002
formatmonthname
def formatmonthname(self, theyear, themonth, width, withyear=True): """ Return a formatted month name. """ s = month_name[themonth] if withyear: s = "%s %r" % (s, theyear) return s.center(width)
python
Lib/calendar.py
369
376
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,003
prmonth
def prmonth(self, theyear, themonth, w=0, l=0): """ Print a month's calendar. """ print(self.formatmonth(theyear, themonth, w, l), end='')
python
Lib/calendar.py
378
382
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,004
formatmonth
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...
python
Lib/calendar.py
384
398
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,005
formatyear
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))...
python
Lib/calendar.py
400
435
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,006
pryear
def pryear(self, theyear, w=0, l=0, c=6, m=3): """Print a year's calendar.""" print(self.formatyear(theyear, w, l, c, m), end='')
python
Lib/calendar.py
437
439
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,007
formatday
def formatday(self, day, weekday): """ Return a day as a table cell. """ if day == 0: # day outside month return '<td class="%s">&nbsp;</td>' % self.cssclass_noday else: return '<td class="%s">%d</td>' % (self.cssclasses[weekday], day)
python
Lib/calendar.py
468
476
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,008
formatweek
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
python
Lib/calendar.py
478
483
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,009
formatweekday
def formatweekday(self, day): """ Return a weekday name as a table header. """ return '<th class="%s">%s</th>' % ( self.cssclasses_weekday_head[day], day_abbr[day])
python
Lib/calendar.py
485
490
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,010
formatweekheader
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
python
Lib/calendar.py
492
497
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,011
formatmonthname
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="%s">%s</th>...
python
Lib/calendar.py
499
508
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,012
formatmonth
def formatmonth(self, theyear, themonth, withyear=True): """ Return a formatted month as a table. """ v = [] a = v.append a('<table border="0" cellpadding="0" cellspacing="0" class="%s">' % ( self.cssclass_month)) a('\n') a(self.formatmonthname...
python
Lib/calendar.py
510
528
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,013
formatyear
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="%s">' % self.cssclass_year) a('\n') a('<tr...
python
Lib/calendar.py
530
552
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,014
formatyearpage
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"?>\...
python
Lib/calendar.py
554
575
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,015
__init__
def __init__(self, locale): self.locale = locale self.oldlocale = None
python
Lib/calendar.py
579
581
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,016
__enter__
def __enter__(self): self.oldlocale = _locale.setlocale(_locale.LC_TIME, None) _locale.setlocale(_locale.LC_TIME, self.locale)
python
Lib/calendar.py
583
585
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,017
__exit__
def __exit__(self, *args): _locale.setlocale(_locale.LC_TIME, self.oldlocale)
python
Lib/calendar.py
587
588
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,018
_get_default_locale
def _get_default_locale(): locale = _locale.setlocale(_locale.LC_TIME, None) if locale == "C": with different_locale(""): # The LC_TIME locale does not seem to be configured: # get the user preferred locale. locale = _locale.setlocale(_locale.LC_TIME, None) return...
python
Lib/calendar.py
591
598
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,019
__init__
def __init__(self, firstweekday=0, locale=None): TextCalendar.__init__(self, firstweekday) if locale is None: locale = _get_default_locale() self.locale = locale
python
Lib/calendar.py
607
611
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,020
formatweekday
def formatweekday(self, day, width): with different_locale(self.locale): return super().formatweekday(day, width)
python
Lib/calendar.py
613
615
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,021
formatmonthname
def formatmonthname(self, theyear, themonth, width, withyear=True): with different_locale(self.locale): return super().formatmonthname(theyear, themonth, width, withyear)
python
Lib/calendar.py
617
619
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,022
__init__
def __init__(self, firstweekday=0, locale=None): HTMLCalendar.__init__(self, firstweekday) if locale is None: locale = _get_default_locale() self.locale = locale
python
Lib/calendar.py
627
631
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,023
formatweekday
def formatweekday(self, day): with different_locale(self.locale): return super().formatweekday(day)
python
Lib/calendar.py
633
635
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,024
formatmonthname
def formatmonthname(self, theyear, themonth, withyear=True): with different_locale(self.locale): return super().formatmonthname(theyear, themonth, withyear)
python
Lib/calendar.py
637
639
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,025
setfirstweekday
def setfirstweekday(firstweekday): if not MONDAY <= firstweekday <= SUNDAY: raise IllegalWeekdayError(firstweekday) c.firstweekday = firstweekday
python
Lib/calendar.py
646
649
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,026
format
def format(cols, colwidth=_colwidth, spacing=_spacing): """Prints multi-column formatting for year calendars""" print(formatstring(cols, colwidth, spacing))
python
Lib/calendar.py
666
668
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,027
formatstring
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)
python
Lib/calendar.py
671
674
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,028
timegm
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 ...
python
Lib/calendar.py
681
688
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,029
main
def main(args=None): import argparse parser = argparse.ArgumentParser() textgroup = parser.add_argument_group('text only arguments') htmlgroup = parser.add_argument_group('html only arguments') textgroup.add_argument( "-w", "--width", type=int, default=2, help="width of date ...
python
Lib/calendar.py
691
799
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,030
get_annotations
def get_annotations(obj, *, globals=None, locals=None, eval_str=False): """Compute the annotations dict for an object. obj may be a callable, class, or module. Passing in an object of any other type raises TypeError. Returns a dict. get_annotations() returns a new dict every time it's called; cal...
python
Lib/inspect.py
176
288
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,031
ismodule
def ismodule(object): """Return true if the object is a module.""" return isinstance(object, types.ModuleType)
python
Lib/inspect.py
292
294
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,032
isclass
def isclass(object): """Return true if the object is a class.""" return isinstance(object, type)
python
Lib/inspect.py
296
298
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,033
ismethod
def ismethod(object): """Return true if the object is an instance method.""" return isinstance(object, types.MethodType)
python
Lib/inspect.py
300
302
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,034
ismethoddescriptor
def ismethoddescriptor(object): """Return true if the object is a method descriptor. But not if ismethod() or isclass() or isfunction() are true. This is new in Python 2.2, and, for example, is true of int.__add__. An object passing this test has a __get__ attribute but not a __set__ attribute, bu...
python
Lib/inspect.py
304
322
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,035
isdatadescriptor
def isdatadescriptor(object): """Return true if the object is a data descriptor. Data descriptors have a __set__ or a __delete__ attribute. Examples are properties (defined in Python) and getsets and members (defined in C). Typically, data descriptors will also have __name__ and __doc__ attributes ...
python
Lib/inspect.py
324
336
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,036
ismemberdescriptor
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
python
Lib/inspect.py
340
345
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,037
ismemberdescriptor
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return False
python
Lib/inspect.py
348
353
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,038
isgetsetdescriptor
def isgetsetdescriptor(object): """Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.GetSetDescriptorType)
python
Lib/inspect.py
357
362
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,039
isgetsetdescriptor
def isgetsetdescriptor(object): """Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.""" return False
python
Lib/inspect.py
365
370
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,040
isfunction
def isfunction(object): """Return true if the object is a user-defined function. Function objects provide these attributes: __doc__ documentation string __name__ name with which this function was defined __code__ code object containing compiled function bytecode ...
python
Lib/inspect.py
372
383
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,041
_has_code_flag
def _has_code_flag(f, flag): """Return true if ``f`` is a function (or a method or functools.partial wrapper wrapping a function or a functools.partialmethod wrapping a function) whose code object has the given ``flag`` set in its flags.""" f = functools._unwrap_partialmethod(f) while ismethod(f...
python
Lib/inspect.py
385
396
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,042
isgeneratorfunction
def isgeneratorfunction(obj): """Return true if the object is a user-defined generator function. Generator function objects provide the same attributes as functions. See help(isfunction) for a list of attributes.""" return _has_code_flag(obj, CO_GENERATOR)
python
Lib/inspect.py
398
403
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,043
_has_coroutine_mark
def _has_coroutine_mark(f): while ismethod(f): f = f.__func__ f = functools._unwrap_partial(f) return getattr(f, "_is_coroutine_marker", None) is _is_coroutine_marker
python
Lib/inspect.py
408
412
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,044
markcoroutinefunction
def markcoroutinefunction(func): """ Decorator to ensure callable is recognised as a coroutine function. """ if hasattr(func, '__func__'): func = func.__func__ func._is_coroutine_marker = _is_coroutine_marker return func
python
Lib/inspect.py
414
421
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,045
iscoroutinefunction
def iscoroutinefunction(obj): """Return true if the object is a coroutine function. Coroutine functions are normally defined with "async def" syntax, but may be marked via markcoroutinefunction. """ return _has_code_flag(obj, CO_COROUTINE) or _has_coroutine_mark(obj)
python
Lib/inspect.py
423
429
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,046
isasyncgenfunction
def isasyncgenfunction(obj): """Return true if the object is an asynchronous generator function. Asynchronous generator functions are defined with "async def" syntax and have "yield" expressions in their body. """ return _has_code_flag(obj, CO_ASYNC_GENERATOR)
python
Lib/inspect.py
431
437
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,047
isasyncgen
def isasyncgen(object): """Return true if the object is an asynchronous generator.""" return isinstance(object, types.AsyncGeneratorType)
python
Lib/inspect.py
439
441
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,048
isgenerator
def isgenerator(object): """Return true if the object is a generator. Generator objects provide these attributes: __iter__ defined to support iteration over container close raises a new GeneratorExit exception inside the generator to terminate the iterat...
python
Lib/inspect.py
443
458
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,049
iscoroutine
def iscoroutine(object): """Return true if the object is a coroutine.""" return isinstance(object, types.CoroutineType)
python
Lib/inspect.py
460
462
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,050
isawaitable
def isawaitable(object): """Return true if object can be passed to an ``await`` expression.""" return (isinstance(object, types.CoroutineType) or isinstance(object, types.GeneratorType) and bool(object.gi_code.co_flags & CO_ITERABLE_COROUTINE) or isinstance(object, collec...
python
Lib/inspect.py
464
469
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,051
istraceback
def istraceback(object): """Return true if the object is a traceback. Traceback objects provide these attributes: tb_frame frame object at this level tb_lasti index of last attempted instruction in bytecode tb_lineno current line number in Python source code ...
python
Lib/inspect.py
471
479
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,052
isframe
def isframe(object): """Return true if the object is a frame object. Frame objects provide these attributes: f_back next outer frame object (this frame's caller) f_builtins built-in namespace seen by this frame f_code code object being executed in this frame ...
python
Lib/inspect.py
481
493
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,053
iscode
def iscode(object): """Return true if the object is a code object. Code objects provide these attributes: co_argcount number of arguments (not including *, ** args or keyword only arguments) co_code string of raw compiled bytecode co_cellv...
python
Lib/inspect.py
495
518
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,054
isbuiltin
def isbuiltin(object): """Return true if the object is a built-in function or method. Built-in functions and methods provide these attributes: __doc__ documentation string __name__ original name of this function or method __self__ instance to which a method is boun...
python
Lib/inspect.py
520
527
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,055
ismethodwrapper
def ismethodwrapper(object): """Return true if the object is a method wrapper.""" return isinstance(object, types.MethodWrapperType)
python
Lib/inspect.py
529
531
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,056
isroutine
def isroutine(object): """Return true if the object is any kind of function or method.""" return (isbuiltin(object) or isfunction(object) or ismethod(object) or ismethoddescriptor(object) or ismethodwrapper(object))
python
Lib/inspect.py
533
539
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,057
isabstract
def isabstract(object): """Return true if the object is an abstract base class (ABC).""" if not isinstance(object, type): return False if object.__flags__ & TPFLAGS_IS_ABSTRACT: return True if not issubclass(type(object), abc.ABCMeta): return False if hasattr(object, '__abstr...
python
Lib/inspect.py
541
563
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,058
_getmembers
def _getmembers(object, predicate, getter): results = [] processed = set() names = dir(object) if isclass(object): mro = getmro(object) # add any DynamicClassAttributes to the list of names if object is a class; # this may result in duplicate entries if, for example, a virtual ...
python
Lib/inspect.py
565
605
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,059
getmembers
def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.""" return _getmembers(object, predicate, getattr)
python
Lib/inspect.py
607
610
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,060
getmembers_static
def getmembers_static(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Optionally, only return members that satisfy a given predicate. Note: this function...
python
Lib/inspect.py
612
624
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,061
classify_class_attrs
def classify_class_attrs(cls): """Return list of attribute-descriptor tuples. For each name in dir(cls), the return list contains a 4-tuple with these elements: 0. The name (a string). 1. The kind of attribute this is, one of these strings: 'class method' created via cla...
python
Lib/inspect.py
628
740
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,062
getmro
def getmro(cls): "Return tuple of base classes (including cls) in method resolution order." return cls.__mro__
python
Lib/inspect.py
744
746
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,063
unwrap
def unwrap(func, *, stop=None): """Get the object wrapped by *func*. Follows the chain of :attr:`__wrapped__` attributes returning the last object in the chain. *stop* is an optional callback accepting an object in the wrapper chain as its sole argument that allows the unwrapping to be terminated earl...
python
Lib/inspect.py
750
779
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,064
indentsize
def indentsize(line): """Return the indent size, in spaces, at the start of a line of text.""" expline = line.expandtabs() return len(expline) - len(expline.lstrip())
python
Lib/inspect.py
782
785
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,065
_findclass
def _findclass(func): cls = sys.modules.get(func.__module__) if cls is None: return None for name in func.__qualname__.split('.')[:-1]: cls = getattr(cls, name) if not isclass(cls): return None return cls
python
Lib/inspect.py
787
795
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,066
_finddoc
def _finddoc(obj): if isclass(obj): for base in obj.__mro__: if base is not object: try: doc = base.__doc__ except AttributeError: continue if doc is not None: return doc return No...
python
Lib/inspect.py
797
856
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,067
getdoc
def getdoc(object): """Get the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" try: doc = object.__doc__ ...
python
Lib/inspect.py
858
875
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,068
cleandoc
def cleandoc(doc): """Clean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed.""" lines = doc.expandtabs().split('\n') # Find minimum indentation of any non-blank lines after first line. margin = sys.maxsize for line in lin...
python
Lib/inspect.py
877
902
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,069
getfile
def getfile(object): """Work out which source or compiled file an object was defined in.""" if ismodule(object): if getattr(object, '__file__', None): return object.__file__ raise TypeError('{!r} is a built-in module'.format(object)) if isclass(object): if hasattr(object,...
python
Lib/inspect.py
905
931
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,070
getmodulename
def getmodulename(path): """Return the module name for a given file, or None.""" fname = os.path.basename(path) # Check for paths that look like an actual module file suffixes = [(-len(suffix), suffix) for suffix in importlib.machinery.all_suffixes()] suffixes.sort() # try longes...
python
Lib/inspect.py
933
943
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,071
getsourcefile
def getsourcefile(object): """Return the filename that can be used to locate an object's source. Return None if no way can be identified to get the source. """ filename = getfile(object) all_bytecode_suffixes = importlib.machinery.DEBUG_BYTECODE_SUFFIXES[:] all_bytecode_suffixes += importlib.mac...
python
Lib/inspect.py
945
972
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,072
getabsfile
def getabsfile(object, _filename=None): """Return an absolute path to the source or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.""" if _filename is None: _filename = getsourcefile(object) or getfile(...
python
Lib/inspect.py
974
981
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,073
getmodule
def getmodule(object, _filename=None): """Return the module an object was defined in, or None if not found.""" if ismodule(object): return object if hasattr(object, '__module__'): return sys.modules.get(object.__module__) # Try the filename to modulename cache if _filename is not No...
python
Lib/inspect.py
986
1,031
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,074
findsource
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. ...
python
Lib/inspect.py
1,038
1,091
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,075
getcomments
def getcomments(object): """Get lines of comments immediately preceding an object's source code. Returns None when source can't be found. """ try: lines, lnum = findsource(object) except (OSError, TypeError): return None if ismodule(object): # Look for a comment block a...
python
Lib/inspect.py
1,093
1,136
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,076
__init__
def __init__(self): self.indent = 0 self.islambda = False self.started = False self.passline = False self.indecorator = False self.last = 1 self.body_col0 = None
python
Lib/inspect.py
1,142
1,149
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,077
tokeneater
def tokeneater(self, type, token, srowcol, erowcol, line): if not self.started and not self.indecorator: # skip any decorators if token == "@": self.indecorator = True # look for the first "def", "class" or "lambda" elif token in ("def", "class", "...
python
Lib/inspect.py
1,151
1,192
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,078
getblock
def getblock(lines): """Extract the block of code at the top of the given list of lines.""" blockfinder = BlockFinder() try: tokens = tokenize.generate_tokens(iter(lines).__next__) for _token in tokens: blockfinder.tokeneater(*_token) except (EndOfBlock, IndentationError): ...
python
Lib/inspect.py
1,194
1,211
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,079
getsourcelines
def getsourcelines(object): """Return a list of source lines and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of the lines corresponding to the object and the line number indicates whe...
python
Lib/inspect.py
1,213
1,232
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,080
getsource
def getsource(object): """Return the text of the source code for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a single string. An OSError is raised if the source code cannot be retrieved.""" lines, lnum = getsou...
python
Lib/inspect.py
1,234
1,241
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,081
walktree
def walktree(classes, children, parent): """Recursive helper function for getclasstree().""" results = [] classes.sort(key=attrgetter('__module__', '__name__')) for c in classes: results.append((c, c.__bases__)) if c in children: results.append(walktree(children[c], children,...
python
Lib/inspect.py
1,244
1,252
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,082
getclasstree
def getclasstree(classes, unique=False): """Arrange the given list of classes into a hierarchy of nested lists. Where a nested list appears, it contains classes derived from the class whose entry immediately precedes the list. Each entry is a 2-tuple containing a class and a tuple of its base classes....
python
Lib/inspect.py
1,254
1,278
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,083
getargs
def getargs(co): """Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is the list of argument names. Keyword-only arguments are appended. 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" if not...
python
Lib/inspect.py
1,283
1,307
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,084
getfullargspec
def getfullargspec(func): """Get the names and default values of a callable object's parameters. A tuple of seven things is returned: (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). 'args' is a list of the parameter names. 'varargs' and 'varkw' are the names of the * and ...
python
Lib/inspect.py
1,313
1,403
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,085
getargvalues
def getargvalues(frame): """Get information about arguments passed into a particular frame. A tuple of four things is returned: (args, varargs, varkw, locals). 'args' is a list of the argument names. 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dicti...
python
Lib/inspect.py
1,408
1,416
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,086
formatannotation
def formatannotation(annotation, base_module=None): if getattr(annotation, '__module__', None) == 'typing': def repl(match): text = match.group() return text.removeprefix('typing.') return re.sub(r'[\w\.]+', repl, repr(annotation)) if isinstance(annotation, types.GenericA...
python
Lib/inspect.py
1,418
1,430
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,087
repl
def repl(match): text = match.group() return text.removeprefix('typing.')
python
Lib/inspect.py
1,420
1,422
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,088
formatannotationrelativeto
def formatannotationrelativeto(object): module = getattr(object, '__module__', None) def _formatannotation(annotation): return formatannotation(annotation, module) return _formatannotation
python
Lib/inspect.py
1,432
1,436
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,089
_formatannotation
def _formatannotation(annotation): return formatannotation(annotation, module)
python
Lib/inspect.py
1,434
1,435
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,090
formatargvalues
def formatargvalues(args, varargs, varkw, locals, formatarg=str, formatvarargs=lambda name: '*' + name, formatvarkw=lambda name: '**' + name, formatvalue=lambda value: '=' + repr(value)): """Format an argument spec from the 4 values ret...
python
Lib/inspect.py
1,439
1,460
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,091
convert
def convert(name, locals=locals, formatarg=formatarg, formatvalue=formatvalue): return formatarg(name) + formatvalue(locals[name])
python
Lib/inspect.py
1,450
1,452
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,092
_missing_arguments
def _missing_arguments(f_name, argnames, pos, values): names = [repr(name) for name in argnames if name not in values] missing = len(names) if missing == 1: s = names[0] elif missing == 2: s = "{} and {}".format(*names) else: tail = ", {} and {}".format(*names[-2:]) d...
python
Lib/inspect.py
1,462
1,476
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,093
_too_many
def _too_many(f_name, args, kwonly, varargs, defcount, given, values): atleast = len(args) - defcount kwonly_given = len([arg for arg in kwonly if arg in values]) if varargs: plural = atleast != 1 sig = "at least %d" % (atleast,) elif defcount: plural = True sig = "from %...
python
Lib/inspect.py
1,478
1,497
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,094
getcallargs
def getcallargs(func, /, *positional, **named): """Get the mapping of arguments to values. A dict is returned, with keys the function argument names (including the names of the * and ** arguments, if any), and values the respective bound values from 'positional' and 'named'.""" spec = getfullargspe...
python
Lib/inspect.py
1,499
1,557
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,095
getclosurevars
def getclosurevars(func): """ Get the mapping of free variables to their current values. Returns a named tuple of dicts mapping the current nonlocal, global and builtin references as seen by the body of the function. A final set of unbound names that could not be resolved is also provided. """ ...
python
Lib/inspect.py
1,561
1,610
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,096
__new__
def __new__(cls, filename, lineno, function, code_context, index, *, positions=None): instance = super().__new__(cls, filename, lineno, function, code_context, index) instance.positions = positions return instance
python
Lib/inspect.py
1,617
1,620
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,097
__repr__
def __repr__(self): return ('Traceback(filename={!r}, lineno={!r}, function={!r}, ' 'code_context={!r}, index={!r}, positions={!r})'.format( self.filename, self.lineno, self.function, self.code_context, self.index, self.positions))
python
Lib/inspect.py
1,622
1,626
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,098
_get_code_position_from_tb
def _get_code_position_from_tb(tb): code, instruction_index = tb.tb_frame.f_code, tb.tb_lasti return _get_code_position(code, instruction_index)
python
Lib/inspect.py
1,628
1,630
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,099
_get_code_position
def _get_code_position(code, instruction_index): if instruction_index < 0: return (None, None, None, None) positions_gen = code.co_positions() # The nth entry in code.co_positions() corresponds to instruction (2*n)th since Python 3.10+ return next(itertools.islice(positions_gen, instruction_inde...
python
Lib/inspect.py
1,632
1,637
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
14,100
getframeinfo
def getframeinfo(frame, context=1): """Get information about a frame or traceback object. A tuple of five things is returned: the filename, the line number of the current line, the function name, a list of lines of context from the source code, and the index of the current line within that list. Th...
python
Lib/inspect.py
1,639
1,680
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }