Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
spaceless
(parser, token)
Removes whitespace between HTML tags, including tab and newline characters. Example usage:: {% spaceless %} <p> <a href="foo/">Foo</a> </p> {% endspaceless %} This example would return this HTML:: <p><a href="foo/">Foo</a></p> Only sp...
Removes whitespace between HTML tags, including tab and newline characters.
def spaceless(parser, token): """ Removes whitespace between HTML tags, including tab and newline characters. Example usage:: {% spaceless %} <p> <a href="foo/">Foo</a> </p> {% endspaceless %} This example would return this HTML:: <p><a...
[ "def", "spaceless", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endspaceless'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "SpacelessNode", "(", "nodelist", ")" ]
[ 1265, 0 ]
[ 1292, 34 ]
python
en
['en', 'error', 'th']
False
templatetag
(parser, token)
Outputs one of the bits used to compose template tags. Since the template system has no concept of "escaping", to display one of the bits used in template tags, you must use the ``{% templatetag %}`` tag. The argument tells which template bit to output: ================== ======= Ar...
Outputs one of the bits used to compose template tags.
def templatetag(parser, token): """ Outputs one of the bits used to compose template tags. Since the template system has no concept of "escaping", to display one of the bits used in template tags, you must use the ``{% templatetag %}`` tag. The argument tells which template bit to output: ...
[ "def", "templatetag", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ...
[ 1296, 0 ]
[ 1327, 31 ]
python
en
['en', 'error', 'th']
False
url
(parser, token)
r""" Return an absolute URL matching the given view with its parameters. This is a way to define links that aren't tied to a particular URL configuration:: {% url "url_name" arg1 arg2 %} or {% url "url_name" name1=value1 name2=value2 %} The first argument is a django.conf.ur...
r""" Return an absolute URL matching the given view with its parameters.
def url(parser, token): r""" Return an absolute URL matching the given view with its parameters. This is a way to define links that aren't tied to a particular URL configuration:: {% url "url_name" arg1 arg2 %} or {% url "url_name" name1=value1 name2=value2 %} The first ...
[ "def", "url", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes at least one argument, the name of a url().\"", "%", "b...
[ 1331, 0 ]
[ 1395, 49 ]
python
cy
['en', 'cy', 'hi']
False
verbatim
(parser, token)
Stops the template engine from rendering the contents of this block tag. Usage:: {% verbatim %} {% don't process this %} {% endverbatim %} You can also designate a specific closing tag block (allowing the unrendered use of ``{% endverbatim %}``):: {% verbatim myb...
Stops the template engine from rendering the contents of this block tag.
def verbatim(parser, token): """ Stops the template engine from rendering the contents of this block tag. Usage:: {% verbatim %} {% don't process this %} {% endverbatim %} You can also designate a specific closing tag block (allowing the unrendered use of ``{% endverba...
[ "def", "verbatim", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endverbatim'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "VerbatimNode", "(", "nodelist", ".", "render", "(", "Co...
[ 1399, 0 ]
[ 1418, 51 ]
python
en
['en', 'error', 'th']
False
widthratio
(parser, token)
For creating bar charts and such, this tag calculates the ratio of a given value to a maximum value, and then applies that ratio to a constant. For example:: <img src="bar.png" alt="Bar" height="10" width="{% widthratio this_value max_value max_width %}" /> If ``this_value`` is ...
For creating bar charts and such, this tag calculates the ratio of a given value to a maximum value, and then applies that ratio to a constant.
def widthratio(parser, token): """ For creating bar charts and such, this tag calculates the ratio of a given value to a maximum value, and then applies that ratio to a constant. For example:: <img src="bar.png" alt="Bar" height="10" width="{% widthratio this_value max_value max_w...
[ "def", "widthratio", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "==", "4", ":", "tag", ",", "this_value_expr", ",", "max_value_expr", ",", "max_width", "=", "bits", "asva...
[ 1422, 0 ]
[ 1456, 38 ]
python
en
['en', 'error', 'th']
False
do_with
(parser, token)
Adds one or more values to the context (inside of this block) for caching and easy access. For example:: {% with total=person.some_sql_method %} {{ total }} object{{ total|pluralize }} {% endwith %} Multiple values can be added to the context:: {% with foo=1 bar=...
Adds one or more values to the context (inside of this block) for caching and easy access.
def do_with(parser, token): """ Adds one or more values to the context (inside of this block) for caching and easy access. For example:: {% with total=person.some_sql_method %} {{ total }} object{{ total|pluralize }} {% endwith %} Multiple values can be added to the co...
[ "def", "do_with", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "remaining_bits", "=", "bits", "[", "1", ":", "]", "extra_context", "=", "token_kwargs", "(", "remaining_bits", ",", "parser", ",", "support_leg...
[ 1460, 0 ]
[ 1491, 70 ]
python
en
['en', 'error', 'th']
False
CycleNode.reset
(self, context)
Reset the cycle iteration back to the beginning.
Reset the cycle iteration back to the beginning.
def reset(self, context): """ Reset the cycle iteration back to the beginning. """ context.render_context[self] = itertools_cycle(self.cyclevars)
[ "def", "reset", "(", "self", ",", "context", ")", ":", "context", ".", "render_context", "[", "self", "]", "=", "itertools_cycle", "(", "self", ".", "cyclevars", ")" ]
[ 90, 4 ]
[ 94, 70 ]
python
en
['en', 'error', 'th']
False
Rect.round
(self)
Returns a new rect with all attributes rounded to integers
Returns a new rect with all attributes rounded to integers
def round(self): """ Returns a new rect with all attributes rounded to integers """ clone = self.clone() # Round down left and top clone.left = int(math.floor(clone.left)) clone.top = int(math.floor(clone.top)) # Round up right and bottom clone.r...
[ "def", "round", "(", "self", ")", ":", "clone", "=", "self", ".", "clone", "(", ")", "# Round down left and top", "clone", ".", "left", "=", "int", "(", "math", ".", "floor", "(", "clone", ".", "left", ")", ")", "clone", ".", "top", "=", "int", "("...
[ 88, 4 ]
[ 102, 20 ]
python
en
['en', 'error', 'th']
False
Rect.move_to_clamp
(self, other)
Moves this rect so it is completely covered by the rect in "other" and returns a new Rect instance.
Moves this rect so it is completely covered by the rect in "other" and returns a new Rect instance.
def move_to_clamp(self, other): """ Moves this rect so it is completely covered by the rect in "other" and returns a new Rect instance. """ other = Rect(*other) clone = self.clone() if clone.left < other.left: clone.right -= clone.left - other.left ...
[ "def", "move_to_clamp", "(", "self", ",", "other", ")", ":", "other", "=", "Rect", "(", "*", "other", ")", "clone", "=", "self", ".", "clone", "(", ")", "if", "clone", ".", "left", "<", "other", ".", "left", ":", "clone", ".", "right", "-=", "clo...
[ 104, 4 ]
[ 128, 20 ]
python
en
['en', 'error', 'th']
False
Rect.move_to_cover
(self, other)
Moves this rect so it completely covers the rect specified in the "other" parameter and returns a new Rect instance.
Moves this rect so it completely covers the rect specified in the "other" parameter and returns a new Rect instance.
def move_to_cover(self, other): """ Moves this rect so it completely covers the rect specified in the "other" parameter and returns a new Rect instance. """ other = Rect(*other) clone = self.clone() if clone.left > other.left: clone.right -= clone.lef...
[ "def", "move_to_cover", "(", "self", ",", "other", ")", ":", "other", "=", "Rect", "(", "*", "other", ")", "clone", "=", "self", ".", "clone", "(", ")", "if", "clone", ".", "left", ">", "other", ".", "left", ":", "clone", ".", "right", "-=", "clo...
[ 130, 4 ]
[ 154, 20 ]
python
en
['en', 'error', 'th']
False
Application.create_spinner
(self, rv, index)
create a dict of data for a spinner
create a dict of data for a spinner
def create_spinner(self, rv, index): """ create a dict of data for a spinner """ return { 'index': index, 'widget': 'RVSpinner', 'value': '', 'values': [ letter * 5 for letter in ascii_lowercase[:5] ...
[ "def", "create_spinner", "(", "self", ",", "rv", ",", "index", ")", ":", "return", "{", "'index'", ":", "index", ",", "'widget'", ":", "'RVSpinner'", ",", "'value'", ":", "''", ",", "'values'", ":", "[", "letter", "*", "5", "for", "letter", "in", "as...
[ 107, 4 ]
[ 120, 9 ]
python
en
['en', 'error', 'th']
False
Application.create_checkbox
(self, rv, index)
create a dict of data for a checkbox
create a dict of data for a checkbox
def create_checkbox(self, rv, index): """ create a dict of data for a checkbox """ return { 'index': index, 'widget': 'RVCheckBox', 'value': choice((True, False)), 'title': ''.join(choices(ascii_lowercase, k=10)), 'ready': True,...
[ "def", "create_checkbox", "(", "self", ",", "rv", ",", "index", ")", ":", "return", "{", "'index'", ":", "index", ",", "'widget'", ":", "'RVCheckBox'", ",", "'value'", ":", "choice", "(", "(", "True", ",", "False", ")", ")", ",", "'title'", ":", "''"...
[ 122, 4 ]
[ 132, 9 ]
python
en
['en', 'error', 'th']
False
Application.create_textinput
(self, rv, index)
create a dict of data for a textinput
create a dict of data for a textinput
def create_textinput(self, rv, index): """ create a dict of data for a textinput """ return { 'index': index, 'widget': 'RVTextInput', 'value': ''.join(choices(ascii_lowercase, k=10)), 'title': ''.join(choices(ascii_lowercase, k=10)), ...
[ "def", "create_textinput", "(", "self", ",", "rv", ",", "index", ")", ":", "return", "{", "'index'", ":", "index", ",", "'widget'", ":", "'RVTextInput'", ",", "'value'", ":", "''", ".", "join", "(", "choices", "(", "ascii_lowercase", ",", "k", "=", "10...
[ 134, 4 ]
[ 144, 9 ]
python
en
['en', 'error', 'th']
False
format
(value, format_string)
Convenience function
Convenience function
def format(value, format_string): "Convenience function" df = DateFormat(value) return df.format(format_string)
[ "def", "format", "(", "value", ",", "format_string", ")", ":", "df", "=", "DateFormat", "(", "value", ")", "return", "df", ".", "format", "(", "format_string", ")" ]
[ 367, 0 ]
[ 370, 35 ]
python
en
['en', 'en', 'en']
False
time_format
(value, format_string)
Convenience function
Convenience function
def time_format(value, format_string): "Convenience function" tf = TimeFormat(value) return tf.format(format_string)
[ "def", "time_format", "(", "value", ",", "format_string", ")", ":", "tf", "=", "TimeFormat", "(", "value", ")", "return", "tf", ".", "format", "(", "format_string", ")" ]
[ 373, 0 ]
[ 376, 35 ]
python
en
['en', 'en', 'en']
False
TimeFormat.a
(self)
a.m.' or 'p.m.
a.m.' or 'p.m.
def a(self): "'a.m.' or 'p.m.'" if self.data.hour > 11: return _('p.m.') return _('a.m.')
[ "def", "a", "(", "self", ")", ":", "if", "self", ".", "data", ".", "hour", ">", "11", ":", "return", "_", "(", "'p.m.'", ")", "return", "_", "(", "'a.m.'", ")" ]
[ 62, 4 ]
[ 66, 24 ]
python
en
['en', 'en', 'en']
True
TimeFormat.B
(self)
Swatch Internet time
Swatch Internet time
def B(self): "Swatch Internet time" raise NotImplementedError('may be implemented in a future release')
[ "def", "B", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'may be implemented in a future release'", ")" ]
[ 74, 4 ]
[ 76, 75 ]
python
en
['en', 'en', 'en']
True
TimeFormat.e
(self)
Timezone name. If timezone information is not available, this method returns an empty string.
Timezone name.
def e(self): """ Timezone name. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tz...
[ "def", "e", "(", "self", ")", ":", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "try", ":", "if", "hasattr", "(", "self", ".", "data", ",", "'tzinfo'", ")", "and", "self", ".", "data", ".", "tzinfo", ":", "# Have to use tzinfo.tzname an...
[ 78, 4 ]
[ 95, 17 ]
python
en
['en', 'error', 'th']
False
TimeFormat.f
(self)
Time, in 12-hour hours and minutes, with minutes left off if they're zero. Examples: '1', '1:30', '2:05', '2' Proprietary extension.
Time, in 12-hour hours and minutes, with minutes left off if they're zero. Examples: '1', '1:30', '2:05', '2' Proprietary extension.
def f(self): """ Time, in 12-hour hours and minutes, with minutes left off if they're zero. Examples: '1', '1:30', '2:05', '2' Proprietary extension. """ if self.data.minute == 0: return self.g() return '%s:%s' % (self.g(), self.i())
[ "def", "f", "(", "self", ")", ":", "if", "self", ".", "data", ".", "minute", "==", "0", ":", "return", "self", ".", "g", "(", ")", "return", "'%s:%s'", "%", "(", "self", ".", "g", "(", ")", ",", "self", ".", "i", "(", ")", ")" ]
[ 97, 4 ]
[ 106, 45 ]
python
en
['en', 'error', 'th']
False
TimeFormat.g
(self)
Hour, 12-hour format without leading zeros; i.e. '1' to '12
Hour, 12-hour format without leading zeros; i.e. '1' to '12
def g(self): "Hour, 12-hour format without leading zeros; i.e. '1' to '12'" if self.data.hour == 0: return 12 if self.data.hour > 12: return self.data.hour - 12 return self.data.hour
[ "def", "g", "(", "self", ")", ":", "if", "self", ".", "data", ".", "hour", "==", "0", ":", "return", "12", "if", "self", ".", "data", ".", "hour", ">", "12", ":", "return", "self", ".", "data", ".", "hour", "-", "12", "return", "self", ".", "...
[ 108, 4 ]
[ 114, 29 ]
python
en
['en', 'en', 'en']
True
TimeFormat.G
(self)
Hour, 24-hour format without leading zeros; i.e. '0' to '23
Hour, 24-hour format without leading zeros; i.e. '0' to '23
def G(self): "Hour, 24-hour format without leading zeros; i.e. '0' to '23'" return self.data.hour
[ "def", "G", "(", "self", ")", ":", "return", "self", ".", "data", ".", "hour" ]
[ 116, 4 ]
[ 118, 29 ]
python
en
['en', 'en', 'en']
True
TimeFormat.h
(self)
Hour, 12-hour format; i.e. '01' to '12
Hour, 12-hour format; i.e. '01' to '12
def h(self): "Hour, 12-hour format; i.e. '01' to '12'" return '%02d' % self.g()
[ "def", "h", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "g", "(", ")" ]
[ 120, 4 ]
[ 122, 32 ]
python
en
['en', 'pt', 'it']
False
TimeFormat.H
(self)
Hour, 24-hour format; i.e. '00' to '23
Hour, 24-hour format; i.e. '00' to '23
def H(self): "Hour, 24-hour format; i.e. '00' to '23'" return '%02d' % self.G()
[ "def", "H", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "G", "(", ")" ]
[ 124, 4 ]
[ 126, 32 ]
python
en
['en', 'pt', 'it']
False
TimeFormat.i
(self)
Minutes; i.e. '00' to '59
Minutes; i.e. '00' to '59
def i(self): "Minutes; i.e. '00' to '59'" return '%02d' % self.data.minute
[ "def", "i", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "minute" ]
[ 128, 4 ]
[ 130, 40 ]
python
en
['en', 'mi', 'it']
False
TimeFormat.O
(self)
Difference to Greenwich time in hours; e.g. '+0200', '-0430'. If timezone information is not available, this method returns an empty string.
Difference to Greenwich time in hours; e.g. '+0200', '-0430'.
def O(self): # NOQA: E743 """ Difference to Greenwich time in hours; e.g. '+0200', '-0430'. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" seconds = self.Z() if seconds == "...
[ "def", "O", "(", "self", ")", ":", "# NOQA: E743", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "seconds", "=", "self", ".", "Z", "(", ")", "if", "seconds", "==", "\"\"", ":", "return", "\"\"", "sign", "=", "'-'", "if", "seconds", "...
[ 132, 4 ]
[ 147, 75 ]
python
en
['en', 'error', 'th']
False
TimeFormat.P
(self)
Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension.
Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension.
def P(self): """ Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension. """ if self.dat...
[ "def", "P", "(", "self", ")", ":", "if", "self", ".", "data", ".", "minute", "==", "0", "and", "self", ".", "data", ".", "hour", "==", "0", ":", "return", "_", "(", "'midnight'", ")", "if", "self", ".", "data", ".", "minute", "==", "0", "and", ...
[ 149, 4 ]
[ 160, 45 ]
python
en
['en', 'error', 'th']
False
TimeFormat.s
(self)
Seconds; i.e. '00' to '59
Seconds; i.e. '00' to '59
def s(self): "Seconds; i.e. '00' to '59'" return '%02d' % self.data.second
[ "def", "s", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "second" ]
[ 162, 4 ]
[ 164, 40 ]
python
en
['en', 'pt', 'it']
False
TimeFormat.T
(self)
Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, this method returns an empty string.
Time zone of this machine; e.g. 'EST' or 'MDT'.
def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" name = None try: name = self.timezone.tzname(self....
[ "def", "T", "(", "self", ")", ":", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "name", "=", "None", "try", ":", "name", "=", "self", ".", "timezone", ".", "tzname", "(", "self", ".", "data", ")", "except", "Exception", ":", "# pytz...
[ 166, 4 ]
[ 186, 34 ]
python
en
['en', 'error', 'th']
False
TimeFormat.u
(self)
Microseconds; i.e. '000000' to '999999
Microseconds; i.e. '000000' to '999999
def u(self): "Microseconds; i.e. '000000' to '999999'" return '%06d' % self.data.microsecond
[ "def", "u", "(", "self", ")", ":", "return", "'%06d'", "%", "self", ".", "data", ".", "microsecond" ]
[ 188, 4 ]
[ 190, 45 ]
python
en
['en', 'mk', 'en']
True
TimeFormat.Z
(self)
Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. If timezone information is not available, this method returns an empty string.
Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.
def Z(self): """ Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. If timezone information is not available, this method returns an empty string. """ ...
[ "def", "Z", "(", "self", ")", ":", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "try", ":", "offset", "=", "self", ".", "timezone", ".", "utcoffset", "(", "self", ".", "data", ")", "except", "Exception", ":", "# pytz raises AmbiguousTimeE...
[ 192, 4 ]
[ 216, 51 ]
python
en
['en', 'error', 'th']
False
DateFormat.b
(self)
Month, textual, 3 letters, lowercase; e.g. 'jan
Month, textual, 3 letters, lowercase; e.g. 'jan
def b(self): "Month, textual, 3 letters, lowercase; e.g. 'jan'" return MONTHS_3[self.data.month]
[ "def", "b", "(", "self", ")", ":", "return", "MONTHS_3", "[", "self", ".", "data", ".", "month", "]" ]
[ 222, 4 ]
[ 224, 40 ]
python
en
['en', 'en', 'en']
True
DateFormat.c
(self)
ISO 8601 Format Example : '2008-01-02T10:30:00.000123'
ISO 8601 Format Example : '2008-01-02T10:30:00.000123'
def c(self): """ ISO 8601 Format Example : '2008-01-02T10:30:00.000123' """ return self.data.isoformat()
[ "def", "c", "(", "self", ")", ":", "return", "self", ".", "data", ".", "isoformat", "(", ")" ]
[ 226, 4 ]
[ 231, 36 ]
python
en
['en', 'error', 'th']
False
DateFormat.d
(self)
Day of the month, 2 digits with leading zeros; i.e. '01' to '31
Day of the month, 2 digits with leading zeros; i.e. '01' to '31
def d(self): "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'" return '%02d' % self.data.day
[ "def", "d", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "day" ]
[ 233, 4 ]
[ 235, 37 ]
python
en
['en', 'en', 'en']
True
DateFormat.D
(self)
Day of the week, textual, 3 letters; e.g. 'Fri
Day of the week, textual, 3 letters; e.g. 'Fri
def D(self): "Day of the week, textual, 3 letters; e.g. 'Fri'" return WEEKDAYS_ABBR[self.data.weekday()]
[ "def", "D", "(", "self", ")", ":", "return", "WEEKDAYS_ABBR", "[", "self", ".", "data", ".", "weekday", "(", ")", "]" ]
[ 237, 4 ]
[ 239, 49 ]
python
en
['en', 'en', 'en']
True
DateFormat.E
(self)
Alternative month names as required by some locales. Proprietary extension.
Alternative month names as required by some locales. Proprietary extension.
def E(self): "Alternative month names as required by some locales. Proprietary extension." return MONTHS_ALT[self.data.month]
[ "def", "E", "(", "self", ")", ":", "return", "MONTHS_ALT", "[", "self", ".", "data", ".", "month", "]" ]
[ 241, 4 ]
[ 243, 42 ]
python
en
['en', 'en', 'en']
True
DateFormat.F
(self)
Month, textual, long; e.g. 'January
Month, textual, long; e.g. 'January
def F(self): "Month, textual, long; e.g. 'January'" return MONTHS[self.data.month]
[ "def", "F", "(", "self", ")", ":", "return", "MONTHS", "[", "self", ".", "data", ".", "month", "]" ]
[ 245, 4 ]
[ 247, 38 ]
python
en
['en', 'en', 'pt']
True
DateFormat.I
(self)
1' if Daylight Savings Time, '0' otherwise.
1' if Daylight Savings Time, '0' otherwise.
def I(self): # NOQA: E743 "'1' if Daylight Savings Time, '0' otherwise." try: if self.timezone and self.timezone.dst(self.data): return '1' else: return '0' except Exception: # pytz raises AmbiguousTimeError during the autumn D...
[ "def", "I", "(", "self", ")", ":", "# NOQA: E743", "try", ":", "if", "self", ".", "timezone", "and", "self", ".", "timezone", ".", "dst", "(", "self", ".", "data", ")", ":", "return", "'1'", "else", ":", "return", "'0'", "except", "Exception", ":", ...
[ 249, 4 ]
[ 260, 21 ]
python
en
['en', 'en', 'en']
True
DateFormat.j
(self)
Day of the month without leading zeros; i.e. '1' to '31
Day of the month without leading zeros; i.e. '1' to '31
def j(self): "Day of the month without leading zeros; i.e. '1' to '31'" return self.data.day
[ "def", "j", "(", "self", ")", ":", "return", "self", ".", "data", ".", "day" ]
[ 262, 4 ]
[ 264, 28 ]
python
en
['en', 'en', 'en']
True
DateFormat.l
(self)
Day of the week, textual, long; e.g. 'Friday
Day of the week, textual, long; e.g. 'Friday
def l(self): # NOQA: E743 "Day of the week, textual, long; e.g. 'Friday'" return WEEKDAYS[self.data.weekday()]
[ "def", "l", "(", "self", ")", ":", "# NOQA: E743", "return", "WEEKDAYS", "[", "self", ".", "data", ".", "weekday", "(", ")", "]" ]
[ 266, 4 ]
[ 268, 44 ]
python
en
['en', 'en', 'en']
True
DateFormat.L
(self)
Boolean for whether it is a leap year; i.e. True or False
Boolean for whether it is a leap year; i.e. True or False
def L(self): "Boolean for whether it is a leap year; i.e. True or False" return calendar.isleap(self.data.year)
[ "def", "L", "(", "self", ")", ":", "return", "calendar", ".", "isleap", "(", "self", ".", "data", ".", "year", ")" ]
[ 270, 4 ]
[ 272, 46 ]
python
en
['en', 'en', 'en']
True
DateFormat.m
(self)
Month; i.e. '01' to '12
Month; i.e. '01' to '12
def m(self): "Month; i.e. '01' to '12'" return '%02d' % self.data.month
[ "def", "m", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "month" ]
[ 274, 4 ]
[ 276, 39 ]
python
en
['en', 'pt', 'it']
False
DateFormat.M
(self)
Month, textual, 3 letters; e.g. 'Jan
Month, textual, 3 letters; e.g. 'Jan
def M(self): "Month, textual, 3 letters; e.g. 'Jan'" return MONTHS_3[self.data.month].title()
[ "def", "M", "(", "self", ")", ":", "return", "MONTHS_3", "[", "self", ".", "data", ".", "month", "]", ".", "title", "(", ")" ]
[ 278, 4 ]
[ 280, 48 ]
python
en
['en', 'fr', 'pt']
False
DateFormat.n
(self)
Month without leading zeros; i.e. '1' to '12
Month without leading zeros; i.e. '1' to '12
def n(self): "Month without leading zeros; i.e. '1' to '12'" return self.data.month
[ "def", "n", "(", "self", ")", ":", "return", "self", ".", "data", ".", "month" ]
[ 282, 4 ]
[ 284, 30 ]
python
en
['en', 'en', 'en']
True
DateFormat.N
(self)
Month abbreviation in Associated Press style. Proprietary extension.
Month abbreviation in Associated Press style. Proprietary extension.
def N(self): "Month abbreviation in Associated Press style. Proprietary extension." return MONTHS_AP[self.data.month]
[ "def", "N", "(", "self", ")", ":", "return", "MONTHS_AP", "[", "self", ".", "data", ".", "month", "]" ]
[ 286, 4 ]
[ 288, 41 ]
python
en
['en', 'en', 'en']
True
DateFormat.o
(self)
ISO 8601 year number matching the ISO week number (W)
ISO 8601 year number matching the ISO week number (W)
def o(self): "ISO 8601 year number matching the ISO week number (W)" return self.data.isocalendar()[0]
[ "def", "o", "(", "self", ")", ":", "return", "self", ".", "data", ".", "isocalendar", "(", ")", "[", "0", "]" ]
[ 290, 4 ]
[ 292, 41 ]
python
en
['en', 'en', 'en']
True
DateFormat.r
(self)
RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200
RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200
def r(self): "RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'" return self.format('D, j M Y H:i:s O')
[ "def", "r", "(", "self", ")", ":", "return", "self", ".", "format", "(", "'D, j M Y H:i:s O'", ")" ]
[ 294, 4 ]
[ 296, 46 ]
python
co
['fr', 'co', 'it']
False
DateFormat.S
(self)
English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th
English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th
def S(self): "English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'" if self.data.day in (11, 12, 13): # Special case return 'th' last = self.data.day % 10 if last == 1: return 'st' if last == 2: return '...
[ "def", "S", "(", "self", ")", ":", "if", "self", ".", "data", ".", "day", "in", "(", "11", ",", "12", ",", "13", ")", ":", "# Special case", "return", "'th'", "last", "=", "self", ".", "data", ".", "day", "%", "10", "if", "last", "==", "1", "...
[ 298, 4 ]
[ 309, 19 ]
python
en
['en', 'en', 'en']
True
DateFormat.t
(self)
Number of days in the given month; i.e. '28' to '31
Number of days in the given month; i.e. '28' to '31
def t(self): "Number of days in the given month; i.e. '28' to '31'" return '%02d' % calendar.monthrange(self.data.year, self.data.month)[1]
[ "def", "t", "(", "self", ")", ":", "return", "'%02d'", "%", "calendar", ".", "monthrange", "(", "self", ".", "data", ".", "year", ",", "self", ".", "data", ".", "month", ")", "[", "1", "]" ]
[ 311, 4 ]
[ 313, 79 ]
python
en
['en', 'en', 'en']
True
DateFormat.U
(self)
Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)
Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)
def U(self): "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" if isinstance(self.data, datetime.datetime) and is_aware(self.data): return int(calendar.timegm(self.data.utctimetuple())) else: return int(time.mktime(self.data.timetuple()))
[ "def", "U", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "data", ",", "datetime", ".", "datetime", ")", "and", "is_aware", "(", "self", ".", "data", ")", ":", "return", "int", "(", "calendar", ".", "timegm", "(", "self", ".", "data"...
[ 315, 4 ]
[ 320, 58 ]
python
en
['en', 'cs', 'en']
True
DateFormat.w
(self)
Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)
Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)
def w(self): "Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)" return (self.data.weekday() + 1) % 7
[ "def", "w", "(", "self", ")", ":", "return", "(", "self", ".", "data", ".", "weekday", "(", ")", "+", "1", ")", "%", "7" ]
[ 322, 4 ]
[ 324, 44 ]
python
en
['en', 'en', 'en']
True
DateFormat.W
(self)
ISO-8601 week number of year, weeks starting on Monday
ISO-8601 week number of year, weeks starting on Monday
def W(self): "ISO-8601 week number of year, weeks starting on Monday" # Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt jan1_weekday = self.data.replace(month=1, day=1).weekday() + 1 weekday = self.data.weekday() + 1 day_of_year = self.z() if day_of_year ...
[ "def", "W", "(", "self", ")", ":", "# Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt", "jan1_weekday", "=", "self", ".", "data", ".", "replace", "(", "month", "=", "1", ",", "day", "=", "1", ")", ".", "weekday", "(", ")", "+", "1", "weekday...
[ 326, 4 ]
[ 349, 26 ]
python
en
['en', 'en', 'en']
True
DateFormat.y
(self)
Year, 2 digits; e.g. '99
Year, 2 digits; e.g. '99
def y(self): "Year, 2 digits; e.g. '99'" return six.text_type(self.data.year)[2:]
[ "def", "y", "(", "self", ")", ":", "return", "six", ".", "text_type", "(", "self", ".", "data", ".", "year", ")", "[", "2", ":", "]" ]
[ 351, 4 ]
[ 353, 48 ]
python
da
['da', 'ny', 'en']
False
DateFormat.Y
(self)
Year, 4 digits; e.g. '1999
Year, 4 digits; e.g. '1999
def Y(self): "Year, 4 digits; e.g. '1999'" return self.data.year
[ "def", "Y", "(", "self", ")", ":", "return", "self", ".", "data", ".", "year" ]
[ 355, 4 ]
[ 357, 29 ]
python
da
['da', 'ny', 'en']
False
DateFormat.z
(self)
Day of the year; i.e. '0' to '365
Day of the year; i.e. '0' to '365
def z(self): "Day of the year; i.e. '0' to '365'" doy = self.year_days[self.data.month] + self.data.day if self.L() and self.data.month > 2: doy += 1 return doy
[ "def", "z", "(", "self", ")", ":", "doy", "=", "self", ".", "year_days", "[", "self", ".", "data", ".", "month", "]", "+", "self", ".", "data", ".", "day", "if", "self", ".", "L", "(", ")", "and", "self", ".", "data", ".", "month", ">", "2", ...
[ 359, 4 ]
[ 364, 18 ]
python
en
['en', 'en', 'en']
True
GeoIP.__init__
(self, path=None, cache=0, country=None, city=None)
Initializes the GeoIP object, no parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP data sets. * path: Base directory to where GeoIP data is located or the full path to where the city or country data ...
Initializes the GeoIP object, no parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP data sets.
def __init__(self, path=None, cache=0, country=None, city=None): """ Initializes the GeoIP object, no parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP data sets. * path: Base directory to where GeoIP dat...
[ "def", "__init__", "(", "self", ",", "path", "=", "None", ",", "cache", "=", "0", ",", "country", "=", "None", ",", "city", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"django.contrib.gis.geoip is deprecated in favor of \"", "\"django.contrib.gis.geoi...
[ 61, 4 ]
[ 136, 81 ]
python
en
['en', 'error', 'th']
False
GeoIP._check_query
(self, query, country=False, city=False, city_or_country=False)
Helper routine for checking the query and database availability.
Helper routine for checking the query and database availability.
def _check_query(self, query, country=False, city=False, city_or_country=False): "Helper routine for checking the query and database availability." # Making sure a string was passed in for the query. if not isinstance(query, six.string_types): raise TypeError('GeoIP query must be a s...
[ "def", "_check_query", "(", "self", ",", "query", ",", "country", "=", "False", ",", "city", "=", "False", ",", "city_or_country", "=", "False", ")", ":", "# Making sure a string was passed in for the query.", "if", "not", "isinstance", "(", "query", ",", "six",...
[ 158, 4 ]
[ 173, 33 ]
python
en
['en', 'en', 'en']
True
GeoIP.city
(self, query)
Returns a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None).
Returns a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None).
def city(self, query): """ Returns a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None). """ enc_query = self._check_query(query, city=True) if ipv4_re.match(qu...
[ "def", "city", "(", "self", ",", "query", ")", ":", "enc_query", "=", "self", ".", "_check_query", "(", "query", ",", "city", "=", "True", ")", "if", "ipv4_re", ".", "match", "(", "query", ")", ":", "# If an IP address was passed in", "return", "GeoIP_reco...
[ 175, 4 ]
[ 187, 72 ]
python
en
['en', 'error', 'th']
False
GeoIP.country_code
(self, query)
Returns the country code for the given IP Address or FQDN.
Returns the country code for the given IP Address or FQDN.
def country_code(self, query): "Returns the country code for the given IP Address or FQDN." enc_query = self._check_query(query, city_or_country=True) if self._country: if ipv4_re.match(query): return GeoIP_country_code_by_addr(self._country, enc_query) el...
[ "def", "country_code", "(", "self", ",", "query", ")", ":", "enc_query", "=", "self", ".", "_check_query", "(", "query", ",", "city_or_country", "=", "True", ")", "if", "self", ".", "_country", ":", "if", "ipv4_re", ".", "match", "(", "query", ")", ":"...
[ 189, 4 ]
[ 198, 51 ]
python
en
['en', 'en', 'en']
True
GeoIP.country_name
(self, query)
Returns the country name for the given IP Address or FQDN.
Returns the country name for the given IP Address or FQDN.
def country_name(self, query): "Returns the country name for the given IP Address or FQDN." enc_query = self._check_query(query, city_or_country=True) if self._country: if ipv4_re.match(query): return GeoIP_country_name_by_addr(self._country, enc_query) el...
[ "def", "country_name", "(", "self", ",", "query", ")", ":", "enc_query", "=", "self", ".", "_check_query", "(", "query", ",", "city_or_country", "=", "True", ")", "if", "self", ".", "_country", ":", "if", "ipv4_re", ".", "match", "(", "query", ")", ":"...
[ 200, 4 ]
[ 209, 51 ]
python
en
['en', 'en', 'en']
True
GeoIP.country
(self, query)
Returns a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters.
Returns a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters.
def country(self, query): """ Returns a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters. """ # Returning the country code and name ...
[ "def", "country", "(", "self", ",", "query", ")", ":", "# Returning the country code and name", "return", "{", "'country_code'", ":", "self", ".", "country_code", "(", "query", ")", ",", "'country_name'", ":", "self", ".", "country_name", "(", "query", ")", ",...
[ 211, 4 ]
[ 220, 17 ]
python
en
['en', 'error', 'th']
False
GeoIP.lon_lat
(self, query)
Returns a tuple of the (longitude, latitude) for the given query.
Returns a tuple of the (longitude, latitude) for the given query.
def lon_lat(self, query): "Returns a tuple of the (longitude, latitude) for the given query." return self.coords(query)
[ "def", "lon_lat", "(", "self", ",", "query", ")", ":", "return", "self", ".", "coords", "(", "query", ")" ]
[ 230, 4 ]
[ 232, 33 ]
python
en
['en', 'en', 'en']
True
GeoIP.lat_lon
(self, query)
Returns a tuple of the (latitude, longitude) for the given query.
Returns a tuple of the (latitude, longitude) for the given query.
def lat_lon(self, query): "Returns a tuple of the (latitude, longitude) for the given query." return self.coords(query, ('latitude', 'longitude'))
[ "def", "lat_lon", "(", "self", ",", "query", ")", ":", "return", "self", ".", "coords", "(", "query", ",", "(", "'latitude'", ",", "'longitude'", ")", ")" ]
[ 234, 4 ]
[ 236, 60 ]
python
en
['en', 'en', 'en']
True
GeoIP.geos
(self, query)
Returns a GEOS Point object for the given query.
Returns a GEOS Point object for the given query.
def geos(self, query): "Returns a GEOS Point object for the given query." ll = self.lon_lat(query) if ll: from django.contrib.gis.geos import Point return Point(ll, srid=4326) else: return None
[ "def", "geos", "(", "self", ",", "query", ")", ":", "ll", "=", "self", ".", "lon_lat", "(", "query", ")", "if", "ll", ":", "from", "django", ".", "contrib", ".", "gis", ".", "geos", "import", "Point", "return", "Point", "(", "ll", ",", "srid", "=...
[ 238, 4 ]
[ 245, 23 ]
python
en
['en', 'en', 'en']
True
GeoIP.country_info
(self)
Returns information about the GeoIP country database.
Returns information about the GeoIP country database.
def country_info(self): "Returns information about the GeoIP country database." if self._country is None: ci = 'No GeoIP Country data in "%s"' % self._country_file else: ci = GeoIP_database_info(self._country) return ci
[ "def", "country_info", "(", "self", ")", ":", "if", "self", ".", "_country", "is", "None", ":", "ci", "=", "'No GeoIP Country data in \"%s\"'", "%", "self", ".", "_country_file", "else", ":", "ci", "=", "GeoIP_database_info", "(", "self", ".", "_country", ")...
[ 249, 4 ]
[ 255, 17 ]
python
en
['en', 'en', 'en']
True
GeoIP.city_info
(self)
Returns information about the GeoIP city database.
Returns information about the GeoIP city database.
def city_info(self): "Returns information about the GeoIP city database." if self._city is None: ci = 'No GeoIP City data in "%s"' % self._city_file else: ci = GeoIP_database_info(self._city) return ci
[ "def", "city_info", "(", "self", ")", ":", "if", "self", ".", "_city", "is", "None", ":", "ci", "=", "'No GeoIP City data in \"%s\"'", "%", "self", ".", "_city_file", "else", ":", "ci", "=", "GeoIP_database_info", "(", "self", ".", "_city", ")", "return", ...
[ 258, 4 ]
[ 264, 17 ]
python
en
['en', 'en', 'en']
True
GeoIP.info
(self)
Returns information about the GeoIP library and databases in use.
Returns information about the GeoIP library and databases in use.
def info(self): "Returns information about the GeoIP library and databases in use." info = '' if GeoIP_lib_version: info += 'GeoIP Library:\n\t%s\n' % GeoIP_lib_version() return info + 'Country:\n\t%s\nCity:\n\t%s' % (self.country_info, self.city_info)
[ "def", "info", "(", "self", ")", ":", "info", "=", "''", "if", "GeoIP_lib_version", ":", "info", "+=", "'GeoIP Library:\\n\\t%s\\n'", "%", "GeoIP_lib_version", "(", ")", "return", "info", "+", "'Country:\\n\\t%s\\nCity:\\n\\t%s'", "%", "(", "self", ".", "country...
[ 267, 4 ]
[ 272, 89 ]
python
en
['en', 'en', 'en']
True
closing
(pool)
Return a context manager making sure the pool closes properly.
Return a context manager making sure the pool closes properly.
def closing(pool): # type: (Pool) -> Iterator[Pool] """Return a context manager making sure the pool closes properly.""" try: yield pool finally: # For Pool.imap*, close and join are needed # for the returned iterator to begin yielding. pool.close() pool.join() ...
[ "def", "closing", "(", "pool", ")", ":", "# type: (Pool) -> Iterator[Pool]", "try", ":", "yield", "pool", "finally", ":", "# For Pool.imap*, close and join are needed", "# for the returned iterator to begin yielding.", "pool", ".", "close", "(", ")", "pool", ".", "join", ...
[ 52, 0 ]
[ 62, 24 ]
python
en
['en', 'en', 'en']
True
_map_fallback
(func, iterable, chunksize=1)
Make an iterator applying func to each element in iterable. This function is the sequential fallback either on Python 2 where Pool.imap* doesn't react to KeyboardInterrupt or when sem_open is unavailable.
Make an iterator applying func to each element in iterable.
def _map_fallback(func, iterable, chunksize=1): # type: (Callable[[S], T], Iterable[S], int) -> Iterator[T] """Make an iterator applying func to each element in iterable. This function is the sequential fallback either on Python 2 where Pool.imap* doesn't react to KeyboardInterrupt or when sem_open...
[ "def", "_map_fallback", "(", "func", ",", "iterable", ",", "chunksize", "=", "1", ")", ":", "# type: (Callable[[S], T], Iterable[S], int) -> Iterator[T]", "return", "map", "(", "func", ",", "iterable", ")" ]
[ 65, 0 ]
[ 73, 30 ]
python
en
['en', 'en', 'en']
True
_map_multiprocess
(func, iterable, chunksize=1)
Chop iterable into chunks and submit them to a process pool. For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1. Return an unordered iterator of the results.
Chop iterable into chunks and submit them to a process pool.
def _map_multiprocess(func, iterable, chunksize=1): # type: (Callable[[S], T], Iterable[S], int) -> Iterator[T] """Chop iterable into chunks and submit them to a process pool. For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of...
[ "def", "_map_multiprocess", "(", "func", ",", "iterable", ",", "chunksize", "=", "1", ")", ":", "# type: (Callable[[S], T], Iterable[S], int) -> Iterator[T]", "with", "closing", "(", "ProcessPool", "(", ")", ")", "as", "pool", ":", "return", "pool", ".", "imap_uno...
[ 76, 0 ]
[ 86, 61 ]
python
en
['en', 'en', 'en']
True
_map_multithread
(func, iterable, chunksize=1)
Chop iterable into chunks and submit them to a thread pool. For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1. Return an unordered iterator of the results.
Chop iterable into chunks and submit them to a thread pool.
def _map_multithread(func, iterable, chunksize=1): # type: (Callable[[S], T], Iterable[S], int) -> Iterator[T] """Chop iterable into chunks and submit them to a thread pool. For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1...
[ "def", "_map_multithread", "(", "func", ",", "iterable", ",", "chunksize", "=", "1", ")", ":", "# type: (Callable[[S], T], Iterable[S], int) -> Iterator[T]", "with", "closing", "(", "ThreadPool", "(", "DEFAULT_POOLSIZE", ")", ")", "as", "pool", ":", "return", "pool"...
[ 89, 0 ]
[ 99, 61 ]
python
en
['en', 'en', 'en']
True
getTreeBuilder
(treeType, implementation=None, **kwargs)
Get a TreeBuilder class for various types of trees with built-in support :arg treeType: the name of the tree type required (case-insensitive). Supported values are: * "dom" - A generic builder for DOM implementations, defaulting to a xml.dom.minidom based implementation. * "etree...
Get a TreeBuilder class for various types of trees with built-in support
def getTreeBuilder(treeType, implementation=None, **kwargs): """Get a TreeBuilder class for various types of trees with built-in support :arg treeType: the name of the tree type required (case-insensitive). Supported values are: * "dom" - A generic builder for DOM implementations, defaulting t...
[ "def", "getTreeBuilder", "(", "treeType", ",", "implementation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "treeType", "=", "treeType", ".", "lower", "(", ")", "if", "treeType", "not", "in", "treeBuilderCache", ":", "if", "treeType", "==", "\"dom\"",...
[ 38, 0 ]
[ 87, 41 ]
python
en
['en', 'en', 'en']
True
assert_server_running
(server: "subprocess.Popen[bytes]", log_file: Optional[str])
Get the exit code of the server, or None if it is still running.
Get the exit code of the server, or None if it is still running.
def assert_server_running(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> None: """Get the exit code of the server, or None if it is still running.""" if server.poll() is not None: message = "Server died unexpectedly!" if log_file: message += f"\nSee {log_file}\n" ...
[ "def", "assert_server_running", "(", "server", ":", "\"subprocess.Popen[bytes]\"", ",", "log_file", ":", "Optional", "[", "str", "]", ")", "->", "None", ":", "if", "server", ".", "poll", "(", ")", "is", "not", "None", ":", "message", "=", "\"Server died unex...
[ 34, 0 ]
[ 40, 35 ]
python
en
['en', 'en', 'en']
True
create_sockets
(conf, log, fds=None)
Create a new socket for the configured addresses or file descriptors. If a configured address is a tuple then a TCP socket is created. If it is a string, a Unix socket is created. Otherwise, a TypeError is raised.
Create a new socket for the configured addresses or file descriptors.
def create_sockets(conf, log, fds=None): """ Create a new socket for the configured addresses or file descriptors. If a configured address is a tuple then a TCP socket is created. If it is a string, a Unix socket is created. Otherwise, a TypeError is raised. """ listeners = [] # get it...
[ "def", "create_sockets", "(", "conf", ",", "log", ",", "fds", "=", "None", ")", ":", "listeners", "=", "[", "]", "# get it only once", "addr", "=", "conf", ".", "address", "fdaddr", "=", "[", "bind", "for", "bind", "in", "addr", "if", "isinstance", "("...
[ 141, 0 ]
[ 203, 20 ]
python
en
['en', 'error', 'th']
False
access_user_by_id
( user_profile: UserProfile, target_user_id: int, *, allow_deactivated: bool = False, allow_bots: bool = False, for_admin: bool, )
Master function for accessing another user by ID in API code; verifies the user ID is in the same realm, and if requested checks for administrative privileges, with flags for various special cases.
Master function for accessing another user by ID in API code; verifies the user ID is in the same realm, and if requested checks for administrative privileges, with flags for various special cases.
def access_user_by_id( user_profile: UserProfile, target_user_id: int, *, allow_deactivated: bool = False, allow_bots: bool = False, for_admin: bool, ) -> UserProfile: """Master function for accessing another user by ID in API code; verifies the user ID is in the same realm, and if reque...
[ "def", "access_user_by_id", "(", "user_profile", ":", "UserProfile", ",", "target_user_id", ":", "int", ",", "*", ",", "allow_deactivated", ":", "bool", "=", "False", ",", "allow_bots", ":", "bool", "=", "False", ",", "for_admin", ":", "bool", ",", ")", "-...
[ 243, 0 ]
[ 269, 17 ]
python
en
['en', 'en', 'en']
True
format_user_row
( realm: Realm, acting_user: Optional[UserProfile], row: Dict[str, Any], client_gravatar: bool, user_avatar_url_field_optional: bool, custom_profile_field_data: Optional[Dict[str, Any]] = None, )
Formats a user row returned by a database fetch using .values(*realm_user_dict_fields) into a dictionary representation of that user for API delivery to clients. The acting_user argument is used for permissions checks.
Formats a user row returned by a database fetch using .values(*realm_user_dict_fields) into a dictionary representation of that user for API delivery to clients. The acting_user argument is used for permissions checks.
def format_user_row( realm: Realm, acting_user: Optional[UserProfile], row: Dict[str, Any], client_gravatar: bool, user_avatar_url_field_optional: bool, custom_profile_field_data: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: """Formats a user row returned by a database fetch using ...
[ "def", "format_user_row", "(", "realm", ":", "Realm", ",", "acting_user", ":", "Optional", "[", "UserProfile", "]", ",", "row", ":", "Dict", "[", "str", ",", "Any", "]", ",", "client_gravatar", ":", "bool", ",", "user_avatar_url_field_optional", ":", "bool",...
[ 372, 0 ]
[ 448, 17 ]
python
en
['en', 'en', 'en']
True
get_raw_user_data
( realm: Realm, acting_user: Optional[UserProfile], *, target_user: Optional[UserProfile] = None, client_gravatar: bool, user_avatar_url_field_optional: bool, include_custom_profile_fields: bool = True, )
Fetches data about the target user(s) appropriate for sending to acting_user via the standard format for the Zulip API. If target_user is None, we fetch all users in the realm.
Fetches data about the target user(s) appropriate for sending to acting_user via the standard format for the Zulip API. If target_user is None, we fetch all users in the realm.
def get_raw_user_data( realm: Realm, acting_user: Optional[UserProfile], *, target_user: Optional[UserProfile] = None, client_gravatar: bool, user_avatar_url_field_optional: bool, include_custom_profile_fields: bool = True, ) -> Dict[int, Dict[str, str]]: """Fetches data about the target...
[ "def", "get_raw_user_data", "(", "realm", ":", "Realm", ",", "acting_user", ":", "Optional", "[", "UserProfile", "]", ",", "*", ",", "target_user", ":", "Optional", "[", "UserProfile", "]", "=", "None", ",", "client_gravatar", ":", "bool", ",", "user_avatar_...
[ 524, 0 ]
[ 568, 17 ]
python
en
['en', 'en', 'en']
True
get_requirement_info
(dist)
Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist().
Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist().
def get_requirement_info(dist): # type: (Distribution) -> RequirementInfo """ Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist(). """ if not dist_is_editable(dist): return (None, False, []) location = os.path.normcase(os.path.abspath(dist.lo...
[ "def", "get_requirement_info", "(", "dist", ")", ":", "# type: (Distribution) -> RequirementInfo", "if", "not", "dist_is_editable", "(", "dist", ")", ":", "return", "(", "None", ",", "False", ",", "[", "]", ")", "location", "=", "os", ".", "path", ".", "norm...
[ 179, 0 ]
[ 238, 34 ]
python
en
['en', 'error', 'th']
False
load
(root)
Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package.
Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package.
def load(root): """ Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package. """ root = os.path.expanduser(root) system = compat_system(root) builder = functools.partial(build, source_dir=root, system=system) ...
[ "def", "load", "(", "root", ")", ":", "root", "=", "os", ".", "path", ".", "expanduser", "(", "root", ")", "system", "=", "compat_system", "(", "root", ")", "builder", "=", "functools", ".", "partial", "(", "build", ",", "source_dir", "=", "root", ",...
[ 61, 0 ]
[ 71, 42 ]
python
en
['en', 'error', 'th']
False
test_user_accessible_objects
(user, organization)
We cannot directly use accessible_objects for User model because both editing and read permissions are obligated to complex business logic
We cannot directly use accessible_objects for User model because both editing and read permissions are obligated to complex business logic
def test_user_accessible_objects(user, organization): """ We cannot directly use accessible_objects for User model because both editing and read permissions are obligated to complex business logic """ admin = user('admin', False) u = user('john', False) access = UserAccess(admin) assert ...
[ "def", "test_user_accessible_objects", "(", "user", ",", "organization", ")", ":", "admin", "=", "user", "(", "'admin'", ",", "False", ")", "u", "=", "user", "(", "'john'", ",", "False", ")", "access", "=", "UserAccess", "(", "admin", ")", "assert", "acc...
[ 125, 0 ]
[ 140, 45 ]
python
en
['en', 'error', 'th']
False
_parse_version
(text)
Internal parsing method. Factored out for testing purposes.
Internal parsing method. Factored out for testing purposes.
def _parse_version(text): "Internal parsing method. Factored out for testing purposes." major, major2, minor = VERSION_RE.search(text).groups() try: return int(major) * 10000 + int(major2) * 100 + int(minor) except (ValueError, TypeError): return int(major) * 10000 + int(major2) * 100
[ "def", "_parse_version", "(", "text", ")", ":", "major", ",", "major2", ",", "minor", "=", "VERSION_RE", ".", "search", "(", "text", ")", ".", "groups", "(", ")", "try", ":", "return", "int", "(", "major", ")", "*", "10000", "+", "int", "(", "major...
[ 15, 0 ]
[ 21, 53 ]
python
en
['en', 'en', 'en']
True
get_version
(connection)
Returns an integer representing the major, minor and revision number of the server. Format is the one used for the return value of libpq PQServerVersion()/``server_version`` connection attribute (available in newer psycopg2 versions.) For example, 90304 for 9.3.4. The last two digits will be 00 in...
Returns an integer representing the major, minor and revision number of the server. Format is the one used for the return value of libpq PQServerVersion()/``server_version`` connection attribute (available in newer psycopg2 versions.)
def get_version(connection): """ Returns an integer representing the major, minor and revision number of the server. Format is the one used for the return value of libpq PQServerVersion()/``server_version`` connection attribute (available in newer psycopg2 versions.) For example, 90304 for 9.3....
[ "def", "get_version", "(", "connection", ")", ":", "if", "hasattr", "(", "connection", ",", "'server_version'", ")", ":", "return", "connection", ".", "server_version", "else", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor"...
[ 24, 0 ]
[ 43, 55 ]
python
en
['en', 'error', 'th']
False
PurgeBatch.add_url
(self, url)
Adds a single URL
Adds a single URL
def add_url(self, url): """Adds a single URL""" self.urls.append(url)
[ "def", "add_url", "(", "self", ",", "url", ")", ":", "self", ".", "urls", ".", "append", "(", "url", ")" ]
[ 138, 4 ]
[ 140, 29 ]
python
en
['en', 'pl', 'en']
True
PurgeBatch.add_urls
(self, urls)
Adds multiple URLs from an iterable This is equivalent to running ``.add_url(url)`` on each URL individually
Adds multiple URLs from an iterable
def add_urls(self, urls): """ Adds multiple URLs from an iterable This is equivalent to running ``.add_url(url)`` on each URL individually """ self.urls.extend(urls)
[ "def", "add_urls", "(", "self", ",", "urls", ")", ":", "self", ".", "urls", ".", "extend", "(", "urls", ")" ]
[ 142, 4 ]
[ 149, 30 ]
python
en
['en', 'error', 'th']
False
PurgeBatch.add_page
(self, page)
Adds all URLs for the specified page This combines the page's full URL with each path that is returned by the page's `.get_cached_paths` method
Adds all URLs for the specified page
def add_page(self, page): """ Adds all URLs for the specified page This combines the page's full URL with each path that is returned by the page's `.get_cached_paths` method """ self.add_urls(_get_page_cached_urls(page))
[ "def", "add_page", "(", "self", ",", "page", ")", ":", "self", ".", "add_urls", "(", "_get_page_cached_urls", "(", "page", ")", ")" ]
[ 151, 4 ]
[ 158, 50 ]
python
en
['en', 'error', 'th']
False
PurgeBatch.add_pages
(self, pages)
Adds multiple pages from a QuerySet or an iterable This is equivalent to running ``.add_page(page)`` on each page individually
Adds multiple pages from a QuerySet or an iterable
def add_pages(self, pages): """ Adds multiple pages from a QuerySet or an iterable This is equivalent to running ``.add_page(page)`` on each page individually """ for page in pages: self.add_page(page)
[ "def", "add_pages", "(", "self", ",", "pages", ")", ":", "for", "page", "in", "pages", ":", "self", ".", "add_page", "(", "page", ")" ]
[ 160, 4 ]
[ 168, 31 ]
python
en
['en', 'error', 'th']
False
PurgeBatch.purge
(self, backend_settings=None, backends=None)
Performs the purge of all the URLs in this batch This method takes two optional keyword arguments: backend_settings and backends - backend_settings can be used to override the WAGTAILFRONTENDCACHE setting for just this call - backends can be set to a list of backend names. ...
Performs the purge of all the URLs in this batch
def purge(self, backend_settings=None, backends=None): """ Performs the purge of all the URLs in this batch This method takes two optional keyword arguments: backend_settings and backends - backend_settings can be used to override the WAGTAILFRONTENDCACHE setting for just thi...
[ "def", "purge", "(", "self", ",", "backend_settings", "=", "None", ",", "backends", "=", "None", ")", ":", "purge_urls_from_cache", "(", "self", ".", "urls", ",", "backend_settings", ",", "backends", ")" ]
[ 170, 4 ]
[ 182, 68 ]
python
en
['en', 'error', 'th']
False
serialize
(input, tree="etree", encoding=None, **serializer_opts)
Serializes the input token stream using the specified treewalker :arg input: the token stream to serialize :arg tree: the treewalker to use :arg encoding: the encoding to use :arg serializer_opts: any options to pass to the :py:class:`html5lib.serializer.HTMLSerializer` that gets created ...
Serializes the input token stream using the specified treewalker
def serialize(input, tree="etree", encoding=None, **serializer_opts): """Serializes the input token stream using the specified treewalker :arg input: the token stream to serialize :arg tree: the treewalker to use :arg encoding: the encoding to use :arg serializer_opts: any options to pass to the...
[ "def", "serialize", "(", "input", ",", "tree", "=", "\"etree\"", ",", "encoding", "=", "None", ",", "*", "*", "serializer_opts", ")", ":", "# XXX: Should we cache this?", "walker", "=", "treewalkers", ".", "getTreeWalker", "(", "tree", ")", "s", "=", "HTMLSe...
[ 74, 0 ]
[ 100, 44 ]
python
en
['en', 'en', 'en']
True
HTMLSerializer.__init__
(self, **kwargs)
Initialize HTMLSerializer :arg inject_meta_charset: Whether or not to inject the meta charset. Defaults to ``True``. :arg quote_attr_values: Whether to quote attribute values that don't require quoting per legacy browser behavior (``"legacy"``), when required by th...
Initialize HTMLSerializer
def __init__(self, **kwargs): """Initialize HTMLSerializer :arg inject_meta_charset: Whether or not to inject the meta charset. Defaults to ``True``. :arg quote_attr_values: Whether to quote attribute values that don't require quoting per legacy browser behavior (``"le...
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "unexpected_args", "=", "frozenset", "(", "kwargs", ")", "-", "frozenset", "(", "self", ".", "options", ")", "if", "len", "(", "unexpected_args", ")", ">", "0", ":", "raise", "TypeError...
[ 134, 4 ]
[ 221, 27 ]
python
de
['de', 'en', 'nl']
False
HTMLSerializer.render
(self, treewalker, encoding=None)
Serializes the stream from the treewalker into a string :arg treewalker: the treewalker to serialize :arg encoding: the string encoding to use :returns: the serialized tree Example: >>> from html5lib import parse, getTreeWalker >>> from html5lib.serializer import HTM...
Serializes the stream from the treewalker into a string
def render(self, treewalker, encoding=None): """Serializes the stream from the treewalker into a string :arg treewalker: the treewalker to serialize :arg encoding: the string encoding to use :returns: the serialized tree Example: >>> from html5lib import parse, getTr...
[ "def", "render", "(", "self", ",", "treewalker", ",", "encoding", "=", "None", ")", ":", "if", "encoding", ":", "return", "b\"\"", ".", "join", "(", "list", "(", "self", ".", "serialize", "(", "treewalker", ",", "encoding", ")", ")", ")", "else", ":"...
[ 374, 4 ]
[ 397, 60 ]
python
en
['en', 'en', 'en']
True
WSClient.job_details
(self, *job_ids)
subscribes to job status, summary, and, for the specified ids, job events
subscribes to job status, summary, and, for the specified ids, job events
def job_details(self, *job_ids): """subscribes to job status, summary, and, for the specified ids, job events""" self.subscribe(jobs=[status_changed, summary], job_events=list(job_ids))
[ "def", "job_details", "(", "self", ",", "*", "job_ids", ")", ":", "self", ".", "subscribe", "(", "jobs", "=", "[", "status_changed", ",", "summary", "]", ",", "job_events", "=", "list", "(", "job_ids", ")", ")" ]
[ 110, 4 ]
[ 112, 80 ]
python
en
['en', 'en', 'en']
True
WSClient.pending_job_details
(self)
subscribes to job status and summary, with responsive job event subscription for an id provided by AWX
subscribes to job status and summary, with responsive job event subscription for an id provided by AWX
def pending_job_details(self): """subscribes to job status and summary, with responsive job event subscription for an id provided by AWX """ self.subscribe_to_pending_events('job_events', [status_changed, summary])
[ "def", "pending_job_details", "(", "self", ")", ":", "self", ".", "subscribe_to_pending_events", "(", "'job_events'", ",", "[", "status_changed", ",", "summary", "]", ")" ]
[ 114, 4 ]
[ 118, 81 ]
python
en
['en', 'en', 'en']
True
WSClient.subscribe
(self, **groups)
Sends a subscription request for the specified channel groups. ``` ws.subscribe(jobs=[ws.status_changed, ws.summary], job_events=[1,2,3]) ```
Sends a subscription request for the specified channel groups. ``` ws.subscribe(jobs=[ws.status_changed, ws.summary], job_events=[1,2,3]) ```
def subscribe(self, **groups): """Sends a subscription request for the specified channel groups. ``` ws.subscribe(jobs=[ws.status_changed, ws.summary], job_events=[1,2,3]) ``` """ self._subscribe(groups=groups)
[ "def", "subscribe", "(", "self", ",", "*", "*", "groups", ")", ":", "self", ".", "_subscribe", "(", "groups", "=", "groups", ")" ]
[ 172, 4 ]
[ 179, 38 ]
python
en
['en', 'en', 'en']
True
read_keys
(base, key)
Return list of registry keys.
Return list of registry keys.
def read_keys(base, key): """Return list of registry keys.""" try: handle = RegOpenKeyEx(base, key) except RegError: return None L = [] i = 0 while True: try: k = RegEnumKey(handle, i) except RegError: break L.append(k) i +=...
[ "def", "read_keys", "(", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "L", "=", "[", "]", "i", "=", "0", "while", "True", ":", "try", ":", "k",...
[ 54, 0 ]
[ 69, 12 ]
python
en
['en', 'no', 'en']
True
read_values
(base, key)
Return dict of registry keys and values. All names are converted to lowercase.
Return dict of registry keys and values.
def read_values(base, key): """Return dict of registry keys and values. All names are converted to lowercase. """ try: handle = RegOpenKeyEx(base, key) except RegError: return None d = {} i = 0 while True: try: name, value, type = RegEnumValue(handle,...
[ "def", "read_values", "(", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "d", "=", "{", "}", "i", "=", "0", "while", "True", ":", "try", ":", "n...
[ 71, 0 ]
[ 90, 12 ]
python
en
['en', 'en', 'en']
True
get_build_version
()
Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6.
Return the version of MSVC that was used to build Python.
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = sys.version.find(prefix) if i == -1: return 6 ...
[ "def", "get_build_version", "(", ")", ":", "prefix", "=", "\"MSC v.\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "6", "i", "=", "i", "+", "len", "(", "prefix", ")", "s", ",", "r...
[ 146, 0 ]
[ 169, 15 ]
python
en
['en', 'en', 'en']
True
get_build_architecture
()
Return the processor architecture. Possible results are "Intel" or "AMD64".
Return the processor architecture.
def get_build_architecture(): """Return the processor architecture. Possible results are "Intel" or "AMD64". """ prefix = " bit (" i = sys.version.find(prefix) if i == -1: return "Intel" j = sys.version.find(")", i) return sys.version[i+len(prefix):j]
[ "def", "get_build_architecture", "(", ")", ":", "prefix", "=", "\" bit (\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "\"Intel\"", "j", "=", "sys", ".", "version", ".", "find", "(", ...
[ 171, 0 ]
[ 182, 39 ]
python
en
['en', 'it', 'en']
True
normalize_and_reduce_paths
(paths)
Return a list of normalized paths with duplicates removed. The current order of paths is maintained.
Return a list of normalized paths with duplicates removed.
def normalize_and_reduce_paths(paths): """Return a list of normalized paths with duplicates removed. The current order of paths is maintained. """ # Paths are normalized so things like: /a and /a/ aren't both preserved. reduced_paths = [] for p in paths: np = os.path.normpath(p) ...
[ "def", "normalize_and_reduce_paths", "(", "paths", ")", ":", "# Paths are normalized so things like: /a and /a/ aren't both preserved.", "reduced_paths", "=", "[", "]", "for", "p", "in", "paths", ":", "np", "=", "os", ".", "path", ".", "normpath", "(", "p", ")", ...
[ 184, 0 ]
[ 196, 24 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.find_exe
(self, exe)
Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none ...
Return path to an MSVC executable program.
def find_exe(self, exe): """Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute pa...
[ "def", "find_exe", "(", "self", ",", "exe", ")", ":", "for", "p", "in", "self", ".", "__paths", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "p", ")", ",", "exe", ")", "if", "os", ".", "path", ...
[ 564, 4 ]
[ 584, 18 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.get_msvc_paths
(self, path, platform='x86')
Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found.
Get a list of devstudio directories (include, lib or path).
def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. """ if not _can_read_reg: return ...
[ "def", "get_msvc_paths", "(", "self", ",", "path", ",", "platform", "=", "'x86'", ")", ":", "if", "not", "_can_read_reg", ":", "return", "[", "]", "path", "=", "path", "+", "\" dirs\"", "if", "self", ".", "__version", ">=", "7", ":", "key", "=", "(",...
[ 586, 4 ]
[ 620, 17 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.set_path_env_var
(self, name)
Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands.
Set environment variable 'name' to an MSVC path type value.
def set_path_env_var(self, name): """Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands. """ if name == "lib": p = self.get_msvc_paths("library") else: p = self.g...
[ "def", "set_path_env_var", "(", "self", ",", "name", ")", ":", "if", "name", "==", "\"lib\"", ":", "p", "=", "self", ".", "get_msvc_paths", "(", "\"library\"", ")", "else", ":", "p", "=", "self", ".", "get_msvc_paths", "(", "name", ")", "if", "p", ":...
[ 622, 4 ]
[ 634, 42 ]
python
en
['en', 'en', 'en']
True