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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ReplaceAll | (pattern, rep, s) | Replaces instances of pattern in a string with a replacement.
The compiled regex is kept in a cache shared by Match and Search.
Args:
pattern: regex pattern
rep: replacement text
s: search string
Returns:
string with replacements made (or original string if no replacements)
| Replaces instances of pattern in a string with a replacement. | def ReplaceAll(pattern, rep, s):
"""Replaces instances of pattern in a string with a replacement.
The compiled regex is kept in a cache shared by Match and Search.
Args:
pattern: regex pattern
rep: replacement text
s: search string
Returns:
string with replacements made (or original string if... | [
"def",
"ReplaceAll",
"(",
"pattern",
",",
"rep",
",",
"s",
")",
":",
"if",
"pattern",
"not",
"in",
"_regexp_compile_cache",
":",
"_regexp_compile_cache",
"[",
"pattern",
"]",
"=",
"sre_compile",
".",
"compile",
"(",
"pattern",
")",
"return",
"_regexp_compile_c... | [
766,
0
] | [
781,
51
] | python | en | ['en', 'en', 'en'] | True |
Search | (pattern, s) | Searches the string for the pattern, caching the compiled regexp. | Searches the string for the pattern, caching the compiled regexp. | def Search(pattern, s):
"""Searches the string for the pattern, caching the compiled regexp."""
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
return _regexp_compile_cache[pattern].search(s) | [
"def",
"Search",
"(",
"pattern",
",",
"s",
")",
":",
"if",
"pattern",
"not",
"in",
"_regexp_compile_cache",
":",
"_regexp_compile_cache",
"[",
"pattern",
"]",
"=",
"sre_compile",
".",
"compile",
"(",
"pattern",
")",
"return",
"_regexp_compile_cache",
"[",
"pat... | [
784,
0
] | [
788,
49
] | python | en | ['en', 'en', 'en'] | True |
_IsSourceExtension | (s) | File extension (excluding dot) matches a source file extension. | File extension (excluding dot) matches a source file extension. | def _IsSourceExtension(s):
"""File extension (excluding dot) matches a source file extension."""
return s in GetNonHeaderExtensions() | [
"def",
"_IsSourceExtension",
"(",
"s",
")",
":",
"return",
"s",
"in",
"GetNonHeaderExtensions",
"(",
")"
] | [
791,
0
] | [
793,
38
] | python | en | ['en', 'en', 'en'] | True |
_OutputFormat | () | Gets the module's output format. | Gets the module's output format. | def _OutputFormat():
"""Gets the module's output format."""
return _cpplint_state.output_format | [
"def",
"_OutputFormat",
"(",
")",
":",
"return",
"_cpplint_state",
".",
"output_format"
] | [
1123,
0
] | [
1125,
37
] | python | en | ['en', 'en', 'en'] | True |
_SetOutputFormat | (output_format) | Sets the module's output format. | Sets the module's output format. | def _SetOutputFormat(output_format):
"""Sets the module's output format."""
_cpplint_state.SetOutputFormat(output_format) | [
"def",
"_SetOutputFormat",
"(",
"output_format",
")",
":",
"_cpplint_state",
".",
"SetOutputFormat",
"(",
"output_format",
")"
] | [
1128,
0
] | [
1130,
47
] | python | en | ['en', 'en', 'en'] | True |
_VerboseLevel | () | Returns the module's verbosity setting. | Returns the module's verbosity setting. | def _VerboseLevel():
"""Returns the module's verbosity setting."""
return _cpplint_state.verbose_level | [
"def",
"_VerboseLevel",
"(",
")",
":",
"return",
"_cpplint_state",
".",
"verbose_level"
] | [
1133,
0
] | [
1135,
37
] | python | en | ['en', 'no', 'en'] | True |
_SetVerboseLevel | (level) | Sets the module's verbosity, and returns the previous setting. | Sets the module's verbosity, and returns the previous setting. | def _SetVerboseLevel(level):
"""Sets the module's verbosity, and returns the previous setting."""
return _cpplint_state.SetVerboseLevel(level) | [
"def",
"_SetVerboseLevel",
"(",
"level",
")",
":",
"return",
"_cpplint_state",
".",
"SetVerboseLevel",
"(",
"level",
")"
] | [
1138,
0
] | [
1140,
46
] | python | en | ['en', 'en', 'en'] | True |
_SetCountingStyle | (level) | Sets the module's counting options. | Sets the module's counting options. | def _SetCountingStyle(level):
"""Sets the module's counting options."""
_cpplint_state.SetCountingStyle(level) | [
"def",
"_SetCountingStyle",
"(",
"level",
")",
":",
"_cpplint_state",
".",
"SetCountingStyle",
"(",
"level",
")"
] | [
1143,
0
] | [
1145,
40
] | python | en | ['en', 'en', 'en'] | True |
_Filters | () | Returns the module's list of output filters, as a list. | Returns the module's list of output filters, as a list. | def _Filters():
"""Returns the module's list of output filters, as a list."""
return _cpplint_state.filters | [
"def",
"_Filters",
"(",
")",
":",
"return",
"_cpplint_state",
".",
"filters"
] | [
1148,
0
] | [
1150,
31
] | python | en | ['en', 'en', 'en'] | True |
_SetFilters | (filters) | Sets the module's error-message filters.
These filters are applied when deciding whether to emit a given
error message.
Args:
filters: A string of comma-separated filters (eg "whitespace/indent").
Each filter should start with + or -; else we die.
| Sets the module's error-message filters. | def _SetFilters(filters):
"""Sets the module's error-message filters.
These filters are applied when deciding whether to emit a given
error message.
Args:
filters: A string of comma-separated filters (eg "whitespace/indent").
Each filter should start with + or -; else we die.
"""
_cpplint... | [
"def",
"_SetFilters",
"(",
"filters",
")",
":",
"_cpplint_state",
".",
"SetFilters",
"(",
"filters",
")"
] | [
1153,
0
] | [
1163,
36
] | python | en | ['en', 'en', 'en'] | True |
_AddFilters | (filters) | Adds more filter overrides.
Unlike _SetFilters, this function does not reset the current list of filters
available.
Args:
filters: A string of comma-separated filters (eg "whitespace/indent").
Each filter should start with + or -; else we die.
| Adds more filter overrides. | def _AddFilters(filters):
"""Adds more filter overrides.
Unlike _SetFilters, this function does not reset the current list of filters
available.
Args:
filters: A string of comma-separated filters (eg "whitespace/indent").
Each filter should start with + or -; else we die.
"""
_cpplint_sta... | [
"def",
"_AddFilters",
"(",
"filters",
")",
":",
"_cpplint_state",
".",
"AddFilters",
"(",
"filters",
")"
] | [
1165,
0
] | [
1175,
36
] | python | en | ['en', 'en', 'en'] | True |
_BackupFilters | () | Saves the current filter list to backup storage. | Saves the current filter list to backup storage. | def _BackupFilters():
""" Saves the current filter list to backup storage."""
_cpplint_state.BackupFilters() | [
"def",
"_BackupFilters",
"(",
")",
":",
"_cpplint_state",
".",
"BackupFilters",
"(",
")"
] | [
1177,
0
] | [
1179,
32
] | python | en | ['en', 'en', 'en'] | True |
_RestoreFilters | () | Restores filters previously backed up. | Restores filters previously backed up. | def _RestoreFilters():
""" Restores filters previously backed up."""
_cpplint_state.RestoreFilters() | [
"def",
"_RestoreFilters",
"(",
")",
":",
"_cpplint_state",
".",
"RestoreFilters",
"(",
")"
] | [
1181,
0
] | [
1183,
33
] | python | en | ['en', 'en', 'en'] | True |
_ShouldPrintError | (category, confidence, linenum) | If confidence >= verbose, category passes filter and is not suppressed. | If confidence >= verbose, category passes filter and is not suppressed. | def _ShouldPrintError(category, confidence, linenum):
"""If confidence >= verbose, category passes filter and is not suppressed."""
# There are three ways we might decide not to print an error message:
# a "NOLINT(category)" comment appears in the source,
# the verbosity level isn't high enough, or the filters... | [
"def",
"_ShouldPrintError",
"(",
"category",
",",
"confidence",
",",
"linenum",
")",
":",
"# There are three ways we might decide not to print an error message:",
"# a \"NOLINT(category)\" comment appears in the source,",
"# the verbosity level isn't high enough, or the filters filter it out... | [
1354,
0
] | [
1379,
13
] | python | en | ['en', 'en', 'en'] | True |
Error | (filename, linenum, category, confidence, message) | Logs the fact we've found a lint error.
We log where the error was found, and also our confidence in the error,
that is, how certain we are this is a legitimate style regression, and
not a misidentification or a use that's sometimes justified.
False positives can be suppressed by the use of
"cpplint(categor... | Logs the fact we've found a lint error. | def Error(filename, linenum, category, confidence, message):
"""Logs the fact we've found a lint error.
We log where the error was found, and also our confidence in the error,
that is, how certain we are this is a legitimate style regression, and
not a misidentification or a use that's sometimes justified.
... | [
"def",
"Error",
"(",
"filename",
",",
"linenum",
",",
"category",
",",
"confidence",
",",
"message",
")",
":",
"if",
"_ShouldPrintError",
"(",
"category",
",",
"confidence",
",",
"linenum",
")",
":",
"_cpplint_state",
".",
"IncrementErrorCount",
"(",
"category... | [
1382,
0
] | [
1418,
37
] | python | en | ['en', 'en', 'en'] | True |
IsCppString | (line) | Does line terminate so, that the next symbol is in string constant.
This function does not consider single-line nor multi-line comments.
Args:
line: is a partial line of code starting from the 0..n.
Returns:
True, if next character appended to 'line' is inside a
string constant.
| Does line terminate so, that the next symbol is in string constant. | def IsCppString(line):
"""Does line terminate so, that the next symbol is in string constant.
This function does not consider single-line nor multi-line comments.
Args:
line: is a partial line of code starting from the 0..n.
Returns:
True, if next character appended to 'line' is inside a
string c... | [
"def",
"IsCppString",
"(",
"line",
")",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"r'\\\\'",
",",
"'XX'",
")",
"# after this, \\\\\" does not match to \\\"",
"return",
"(",
"(",
"line",
".",
"count",
"(",
"'\"'",
")",
"-",
"line",
".",
"count",
"(",
... | [
1440,
0
] | [
1454,
78
] | python | en | ['en', 'en', 'en'] | True |
CleanseRawStrings | (raw_lines) | Removes C++11 raw strings from lines.
Before:
static const char kData[] = R"(
multi-line string
)";
After:
static const char kData[] = ""
(replaced by blank line)
"";
Args:
raw_lines: list of raw lines.
Returns:
list of lines with C++11 raw str... | Removes C++11 raw strings from lines. | def CleanseRawStrings(raw_lines):
"""Removes C++11 raw strings from lines.
Before:
static const char kData[] = R"(
multi-line string
)";
After:
static const char kData[] = ""
(replaced by blank line)
"";
Args:
raw_lines: list of raw lines.
Return... | [
"def",
"CleanseRawStrings",
"(",
"raw_lines",
")",
":",
"delimiter",
"=",
"None",
"lines_without_raw_strings",
"=",
"[",
"]",
"for",
"line",
"in",
"raw_lines",
":",
"if",
"delimiter",
":",
"# Inside a raw string, look for the end",
"end",
"=",
"line",
".",
"find",... | [
1457,
0
] | [
1530,
34
] | python | en | ['en', 'en', 'en'] | True |
FindNextMultiLineCommentStart | (lines, lineix) | Find the beginning marker for a multiline comment. | Find the beginning marker for a multiline comment. | def FindNextMultiLineCommentStart(lines, lineix):
"""Find the beginning marker for a multiline comment."""
while lineix < len(lines):
if lines[lineix].strip().startswith('/*'):
# Only return this marker if the comment goes beyond this line
if lines[lineix].strip().find('*/', 2) < 0:
return l... | [
"def",
"FindNextMultiLineCommentStart",
"(",
"lines",
",",
"lineix",
")",
":",
"while",
"lineix",
"<",
"len",
"(",
"lines",
")",
":",
"if",
"lines",
"[",
"lineix",
"]",
".",
"strip",
"(",
")",
".",
"startswith",
"(",
"'/*'",
")",
":",
"# Only return this... | [
1533,
0
] | [
1541,
19
] | python | en | ['en', 'en', 'en'] | True |
FindNextMultiLineCommentEnd | (lines, lineix) | We are inside a comment, find the end marker. | We are inside a comment, find the end marker. | def FindNextMultiLineCommentEnd(lines, lineix):
"""We are inside a comment, find the end marker."""
while lineix < len(lines):
if lines[lineix].strip().endswith('*/'):
return lineix
lineix += 1
return len(lines) | [
"def",
"FindNextMultiLineCommentEnd",
"(",
"lines",
",",
"lineix",
")",
":",
"while",
"lineix",
"<",
"len",
"(",
"lines",
")",
":",
"if",
"lines",
"[",
"lineix",
"]",
".",
"strip",
"(",
")",
".",
"endswith",
"(",
"'*/'",
")",
":",
"return",
"lineix",
... | [
1544,
0
] | [
1550,
19
] | python | en | ['en', 'en', 'en'] | True |
RemoveMultiLineCommentsFromRange | (lines, begin, end) | Clears a range of lines for multi-line comments. | Clears a range of lines for multi-line comments. | def RemoveMultiLineCommentsFromRange(lines, begin, end):
"""Clears a range of lines for multi-line comments."""
# Having // dummy comments makes the lines non-empty, so we will not get
# unnecessary blank line warnings later in the code.
for i in range(begin, end):
lines[i] = '/**/' | [
"def",
"RemoveMultiLineCommentsFromRange",
"(",
"lines",
",",
"begin",
",",
"end",
")",
":",
"# Having // dummy comments makes the lines non-empty, so we will not get",
"# unnecessary blank line warnings later in the code.",
"for",
"i",
"in",
"range",
"(",
"begin",
",",
"end",
... | [
1553,
0
] | [
1558,
21
] | python | en | ['en', 'en', 'en'] | True |
RemoveMultiLineComments | (filename, lines, error) | Removes multiline (c-style) comments from lines. | Removes multiline (c-style) comments from lines. | def RemoveMultiLineComments(filename, lines, error):
"""Removes multiline (c-style) comments from lines."""
lineix = 0
while lineix < len(lines):
lineix_begin = FindNextMultiLineCommentStart(lines, lineix)
if lineix_begin >= len(lines):
return
lineix_end = FindNextMultiLineCommentEnd(lines, line... | [
"def",
"RemoveMultiLineComments",
"(",
"filename",
",",
"lines",
",",
"error",
")",
":",
"lineix",
"=",
"0",
"while",
"lineix",
"<",
"len",
"(",
"lines",
")",
":",
"lineix_begin",
"=",
"FindNextMultiLineCommentStart",
"(",
"lines",
",",
"lineix",
")",
"if",
... | [
1561,
0
] | [
1574,
27
] | python | en | ['en', 'en', 'en'] | True |
CleanseComments | (line) | Removes //-comments and single-line C-style /* */ comments.
Args:
line: A line of C++ source.
Returns:
The line with single-line comments removed.
| Removes //-comments and single-line C-style /* */ comments. | def CleanseComments(line):
"""Removes //-comments and single-line C-style /* */ comments.
Args:
line: A line of C++ source.
Returns:
The line with single-line comments removed.
"""
commentpos = line.find('//')
if commentpos != -1 and not IsCppString(line[:commentpos]):
line = line[:commentpos]... | [
"def",
"CleanseComments",
"(",
"line",
")",
":",
"commentpos",
"=",
"line",
".",
"find",
"(",
"'//'",
")",
"if",
"commentpos",
"!=",
"-",
"1",
"and",
"not",
"IsCppString",
"(",
"line",
"[",
":",
"commentpos",
"]",
")",
":",
"line",
"=",
"line",
"[",
... | [
1577,
0
] | [
1590,
58
] | python | en | ['en', 'en', 'en'] | True |
FindEndOfExpressionInLine | (line, startpos, stack) | Find the position just after the end of current parenthesized expression.
Args:
line: a CleansedLines line.
startpos: start searching at this position.
stack: nesting stack at startpos.
Returns:
On finding matching end: (index just after matching end, None)
On finding an unclosed expression: (... | Find the position just after the end of current parenthesized expression. | def FindEndOfExpressionInLine(line, startpos, stack):
"""Find the position just after the end of current parenthesized expression.
Args:
line: a CleansedLines line.
startpos: start searching at this position.
stack: nesting stack at startpos.
Returns:
On finding matching end: (index just after m... | [
"def",
"FindEndOfExpressionInLine",
"(",
"line",
",",
"startpos",
",",
"stack",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"startpos",
",",
"len",
"(",
"line",
")",
")",
":",
"char",
"=",
"line",
"[",
"i",
"]",
"if",
"char",
"in",
"'([{'",
":",
"# ... | [
1688,
0
] | [
1763,
20
] | python | en | ['en', 'en', 'en'] | True |
CloseExpression | (clean_lines, linenum, pos) | If input points to ( or { or [ or <, finds the position that closes it.
If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
linenum/pos that correspond to the closing of the expression.
TODO(unknown): cpplint spends a fair bit of time matching parentheses.
Ideally we would want to index all... | If input points to ( or { or [ or <, finds the position that closes it. | def CloseExpression(clean_lines, linenum, pos):
"""If input points to ( or { or [ or <, finds the position that closes it.
If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
linenum/pos that correspond to the closing of the expression.
TODO(unknown): cpplint spends a fair bit of time match... | [
"def",
"CloseExpression",
"(",
"clean_lines",
",",
"linenum",
",",
"pos",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"if",
"(",
"line",
"[",
"pos",
"]",
"not",
"in",
"'({[<'",
")",
"or",
"Match",
"(",
"r'<[<=]'",
",",
"... | [
1766,
0
] | [
1807,
43
] | python | en | ['en', 'en', 'en'] | True |
FindStartOfExpressionInLine | (line, endpos, stack) | Find position at the matching start of current expression.
This is almost the reverse of FindEndOfExpressionInLine, but note
that the input position and returned position differs by 1.
Args:
line: a CleansedLines line.
endpos: start searching at this position.
stack: nesting stack at endpos.
Retu... | Find position at the matching start of current expression. | def FindStartOfExpressionInLine(line, endpos, stack):
"""Find position at the matching start of current expression.
This is almost the reverse of FindEndOfExpressionInLine, but note
that the input position and returned position differs by 1.
Args:
line: a CleansedLines line.
endpos: start searching at... | [
"def",
"FindStartOfExpressionInLine",
"(",
"line",
",",
"endpos",
",",
"stack",
")",
":",
"i",
"=",
"endpos",
"while",
"i",
">=",
"0",
":",
"char",
"=",
"line",
"[",
"i",
"]",
"if",
"char",
"in",
"')]}'",
":",
"# Found end of expression, push to expression s... | [
1810,
0
] | [
1884,
20
] | python | en | ['en', 'en', 'en'] | True |
ReverseCloseExpression | (clean_lines, linenum, pos) | If input points to ) or } or ] or >, finds the position that opens it.
If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the
linenum/pos that correspond to the opening of the expression.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to ... | If input points to ) or } or ] or >, finds the position that opens it. | def ReverseCloseExpression(clean_lines, linenum, pos):
"""If input points to ) or } or ] or >, finds the position that opens it.
If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the
linenum/pos that correspond to the opening of the expression.
Args:
clean_lines: A CleansedLines instance ... | [
"def",
"ReverseCloseExpression",
"(",
"clean_lines",
",",
"linenum",
",",
"pos",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"if",
"line",
"[",
"pos",
"]",
"not",
"in",
"')}]>'",
":",
"return",
"(",
"line",
",",
"0",
",",
... | [
1887,
0
] | [
1922,
22
] | python | en | ['en', 'en', 'en'] | True |
CheckForCopyright | (filename, lines, error) | Logs an error if no Copyright message appears at the top of the file. | Logs an error if no Copyright message appears at the top of the file. | def CheckForCopyright(filename, lines, error):
"""Logs an error if no Copyright message appears at the top of the file."""
# We'll say it should occur by line 10. Don't forget there's a
# dummy line at the front.
for line in range(1, min(len(lines), 11)):
if re.search(r'Copyright', lines[line], re.I): brea... | [
"def",
"CheckForCopyright",
"(",
"filename",
",",
"lines",
",",
"error",
")",
":",
"# We'll say it should occur by line 10. Don't forget there's a",
"# dummy line at the front.",
"for",
"line",
"in",
"range",
"(",
"1",
",",
"min",
"(",
"len",
"(",
"lines",
")",
",",... | [
1925,
0
] | [
1935,
73
] | python | en | ['en', 'en', 'en'] | True |
GetIndentLevel | (line) | Return the number of leading spaces in line.
Args:
line: A string to check.
Returns:
An integer count of leading spaces, possibly zero.
| Return the number of leading spaces in line. | def GetIndentLevel(line):
"""Return the number of leading spaces in line.
Args:
line: A string to check.
Returns:
An integer count of leading spaces, possibly zero.
"""
indent = Match(r'^( *)\S', line)
if indent:
return len(indent.group(1))
else:
return 0 | [
"def",
"GetIndentLevel",
"(",
"line",
")",
":",
"indent",
"=",
"Match",
"(",
"r'^( *)\\S'",
",",
"line",
")",
"if",
"indent",
":",
"return",
"len",
"(",
"indent",
".",
"group",
"(",
"1",
")",
")",
"else",
":",
"return",
"0"
] | [
1938,
0
] | [
1951,
12
] | python | en | ['en', 'en', 'en'] | True |
GetHeaderGuardCPPVariable | (filename) | Returns the CPP variable that should be used as a header guard.
Args:
filename: The name of a C++ header file.
Returns:
The CPP variable that should be used as a header guard in the
named file.
| Returns the CPP variable that should be used as a header guard. | def GetHeaderGuardCPPVariable(filename):
"""Returns the CPP variable that should be used as a header guard.
Args:
filename: The name of a C++ header file.
Returns:
The CPP variable that should be used as a header guard in the
named file.
"""
# Restores original filename in case that cpplint is... | [
"def",
"GetHeaderGuardCPPVariable",
"(",
"filename",
")",
":",
"# Restores original filename in case that cpplint is invoked from Emacs's",
"# flymake.",
"filename",
"=",
"re",
".",
"sub",
"(",
"r'_flymake\\.h$'",
",",
"'.h'",
",",
"filename",
")",
"filename",
"=",
"re",
... | [
1954,
0
] | [
1982,
72
] | python | en | ['en', 'en', 'en'] | True |
CheckForHeaderGuard | (filename, clean_lines, error) | Checks that the file contains a header guard.
Logs an error if no #ifndef header guard is present. For other
headers, checks that the full pathname is used.
Args:
filename: The name of the C++ header file.
clean_lines: A CleansedLines instance containing the file.
error: The function to call with a... | Checks that the file contains a header guard. | def CheckForHeaderGuard(filename, clean_lines, error):
"""Checks that the file contains a header guard.
Logs an error if no #ifndef header guard is present. For other
headers, checks that the full pathname is used.
Args:
filename: The name of the C++ header file.
clean_lines: A CleansedLines instance... | [
"def",
"CheckForHeaderGuard",
"(",
"filename",
",",
"clean_lines",
",",
"error",
")",
":",
"# Don't check for header guards if there are error suppression",
"# comments somewhere in this file.",
"#",
"# Because this is silencing a warning for a nonexistent line, we",
"# only support the ... | [
1985,
0
] | [
2085,
57
] | python | en | ['en', 'en', 'en'] | True |
CheckHeaderFileIncluded | (filename, include_state, error) | Logs an error if a source file does not include its header. | Logs an error if a source file does not include its header. | def CheckHeaderFileIncluded(filename, include_state, error):
"""Logs an error if a source file does not include its header."""
# Do not check test files
fileinfo = FileInfo(filename)
if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
return
for ext in GetHeaderExtensions():
basefilename = filename... | [
"def",
"CheckHeaderFileIncluded",
"(",
"filename",
",",
"include_state",
",",
"error",
")",
":",
"# Do not check test files",
"fileinfo",
"=",
"FileInfo",
"(",
"filename",
")",
"if",
"Search",
"(",
"_TEST_FILE_SUFFIX",
",",
"fileinfo",
".",
"BaseName",
"(",
")",
... | [
2088,
0
] | [
2112,
66
] | python | en | ['en', 'en', 'en'] | True |
CheckForBadCharacters | (filename, lines, error) | Logs an error for each line containing bad characters.
Two kinds of bad characters:
1. Unicode replacement characters: These indicate that either the file
contained invalid UTF-8 (likely) or Unicode replacement characters (which
it shouldn't). Note that it's possible for this to throw off line
numbering if... | Logs an error for each line containing bad characters. | def CheckForBadCharacters(filename, lines, error):
"""Logs an error for each line containing bad characters.
Two kinds of bad characters:
1. Unicode replacement characters: These indicate that either the file
contained invalid UTF-8 (likely) or Unicode replacement characters (which
it shouldn't). Note that... | [
"def",
"CheckForBadCharacters",
"(",
"filename",
",",
"lines",
",",
"error",
")",
":",
"for",
"linenum",
",",
"line",
"in",
"enumerate",
"(",
"lines",
")",
":",
"if",
"unicode_escape_decode",
"(",
"'\\ufffd'",
")",
"in",
"line",
":",
"error",
"(",
"filenam... | [
2115,
0
] | [
2137,
79
] | python | en | ['en', 'en', 'en'] | True |
CheckForNewlineAtEOF | (filename, lines, error) | Logs an error if there is no newline char at the end of the file.
Args:
filename: The name of the current file.
lines: An array of strings, each representing a line of the file.
error: The function to call with any errors found.
| Logs an error if there is no newline char at the end of the file. | def CheckForNewlineAtEOF(filename, lines, error):
"""Logs an error if there is no newline char at the end of the file.
Args:
filename: The name of the current file.
lines: An array of strings, each representing a line of the file.
error: The function to call with any errors found.
"""
# The array ... | [
"def",
"CheckForNewlineAtEOF",
"(",
"filename",
",",
"lines",
",",
"error",
")",
":",
"# The array lines() was created by adding two newlines to the",
"# original file (go figure), then splitting on \\n.",
"# To verify that the file ends in \\n, we just have to make sure the",
"# last-but-... | [
2140,
0
] | [
2155,
71
] | python | en | ['en', 'en', 'en'] | True |
CheckForMultilineCommentsAndStrings | (filename, clean_lines, linenum, error) | Logs an error if we see /* ... */ or "..." that extend past one line.
/* ... */ comments are legit inside macros, for one line.
Otherwise, we prefer // comments, so it's ok to warn about the
other. Likewise, it's ok for strings to extend across multiple
lines, as long as a line continuation character (backsla... | Logs an error if we see /* ... */ or "..." that extend past one line. | def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error):
"""Logs an error if we see /* ... */ or "..." that extend past one line.
/* ... */ comments are legit inside macros, for one line.
Otherwise, we prefer // comments, so it's ok to warn about the
other. Likewise, it's ok for strings... | [
"def",
"CheckForMultilineCommentsAndStrings",
"(",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"# Remove all \\\\ (escaped backslashes) from the line. They are OK, and the",
"# secon... | [
2158,
0
] | [
2193,
60
] | python | en | ['en', 'en', 'en'] | True |
CheckPosixThreading | (filename, clean_lines, linenum, error) | Checks for calls to thread-unsafe functions.
Much code has been originally written without consideration of
multi-threading. Also, engineers are relying on their old experience;
they have learned posix before threading extensions were added. These
tests guide the engineers to use thread-safe functions (when us... | Checks for calls to thread-unsafe functions. | def CheckPosixThreading(filename, clean_lines, linenum, error):
"""Checks for calls to thread-unsafe functions.
Much code has been originally written without consideration of
multi-threading. Also, engineers are relying on their old experience;
they have learned posix before threading extensions were added. Th... | [
"def",
"CheckPosixThreading",
"(",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"for",
"single_thread_func",
",",
"multithread_safe_func",
",",
"pattern",
"in",
"_THREADIN... | [
2226,
0
] | [
2249,
47
] | python | en | ['en', 'en', 'en'] | True |
CheckVlogArguments | (filename, clean_lines, linenum, error) | Checks that VLOG() is only used for defining a logging level.
For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and
VLOG(FATAL) are not.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to ... | Checks that VLOG() is only used for defining a logging level. | def CheckVlogArguments(filename, clean_lines, linenum, error):
"""Checks that VLOG() is only used for defining a logging level.
For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and
VLOG(FATAL) are not.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines i... | [
"def",
"CheckVlogArguments",
"(",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"if",
"Search",
"(",
"r'\\bVLOG\\((INFO|ERROR|WARNING|DFATAL|FATAL)\\)'",
",",
"line",
")",
... | [
2252,
0
] | [
2268,
60
] | python | en | ['en', 'en', 'en'] | True |
CheckInvalidIncrement | (filename, clean_lines, linenum, error) | Checks for invalid increment *count++.
For example following function:
void increment_counter(int* count) {
*count++;
}
is invalid, because it effectively does count++, moving pointer, and should
be replaced with ++*count, (*count)++ or *count += 1.
Args:
filename: The name of the current file.
... | Checks for invalid increment *count++. | def CheckInvalidIncrement(filename, clean_lines, linenum, error):
"""Checks for invalid increment *count++.
For example following function:
void increment_counter(int* count) {
*count++;
}
is invalid, because it effectively does count++, moving pointer, and should
be replaced with ++*count, (*count)++ ... | [
"def",
"CheckInvalidIncrement",
"(",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"if",
"_RE_PATTERN_INVALID_INCREMENT",
".",
"match",
"(",
"line",
")",
":",
"error",
... | [
2276,
0
] | [
2295,
78
] | python | en | ['en', 'en', 'en'] | True |
_IncludeState.FindHeader | (self, header) | Check if a header has already been included.
Args:
header: header to check.
Returns:
Line number of previous occurrence, or -1 if the header has not
been seen before.
| Check if a header has already been included. | def FindHeader(self, header):
"""Check if a header has already been included.
Args:
header: header to check.
Returns:
Line number of previous occurrence, or -1 if the header has not
been seen before.
"""
for section_list in self.include_list:
for f in section_list:
i... | [
"def",
"FindHeader",
"(",
"self",
",",
"header",
")",
":",
"for",
"section_list",
"in",
"self",
".",
"include_list",
":",
"for",
"f",
"in",
"section_list",
":",
"if",
"f",
"[",
"0",
"]",
"==",
"header",
":",
"return",
"f",
"[",
"1",
"]",
"return",
... | [
837,
2
] | [
850,
13
] | python | en | ['en', 'en', 'en'] | True |
_IncludeState.ResetSection | (self, directive) | Reset section checking for preprocessor directive.
Args:
directive: preprocessor directive (e.g. "if", "else").
| Reset section checking for preprocessor directive. | def ResetSection(self, directive):
"""Reset section checking for preprocessor directive.
Args:
directive: preprocessor directive (e.g. "if", "else").
"""
# The name of the current section.
self._section = self._INITIAL_SECTION
# The path of last found header.
self._last_header = ''
... | [
"def",
"ResetSection",
"(",
"self",
",",
"directive",
")",
":",
"# The name of the current section.",
"self",
".",
"_section",
"=",
"self",
".",
"_INITIAL_SECTION",
"# The path of last found header.",
"self",
".",
"_last_header",
"=",
"''",
"# Update list of includes. No... | [
852,
2
] | [
868,
32
] | python | en | ['en', 'en', 'en'] | True |
_IncludeState.CanonicalizeAlphabeticalOrder | (self, header_path) | Returns a path canonicalized for alphabetical comparison.
- replaces "-" with "_" so they both cmp the same.
- removes '-inl' since we don't require them to be after the main header.
- lowercase everything, just in case.
Args:
header_path: Path to be canonicalized.
Returns:
Canonicali... | Returns a path canonicalized for alphabetical comparison. | def CanonicalizeAlphabeticalOrder(self, header_path):
"""Returns a path canonicalized for alphabetical comparison.
- replaces "-" with "_" so they both cmp the same.
- removes '-inl' since we don't require them to be after the main header.
- lowercase everything, just in case.
Args:
header_p... | [
"def",
"CanonicalizeAlphabeticalOrder",
"(",
"self",
",",
"header_path",
")",
":",
"return",
"header_path",
".",
"replace",
"(",
"'-inl.h'",
",",
"'.h'",
")",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
".",
"lower",
"(",
")"
] | [
873,
2
] | [
886,
72
] | python | en | ['en', 'en', 'en'] | True |
_IncludeState.IsInAlphabeticalOrder | (self, clean_lines, linenum, header_path) | Check if a header is in alphabetical order with the previous header.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
header_path: Canonicalized header to be checked.
Returns:
Returns true if the header is in alphabetical order.... | Check if a header is in alphabetical order with the previous header. | def IsInAlphabeticalOrder(self, clean_lines, linenum, header_path):
"""Check if a header is in alphabetical order with the previous header.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
header_path: Canonicalized header to be checke... | [
"def",
"IsInAlphabeticalOrder",
"(",
"self",
",",
"clean_lines",
",",
"linenum",
",",
"header_path",
")",
":",
"# If previous section is different from current section, _last_header will",
"# be reset to empty string, so it's always less than current header.",
"#",
"# If previous line ... | [
888,
2
] | [
907,
15
] | python | en | ['en', 'en', 'en'] | True |
_IncludeState.CheckNextIncludeOrder | (self, header_type) | Returns a non-empty error message if the next header is out of order.
This function also updates the internal state to be ready to check
the next include.
Args:
header_type: One of the _XXX_HEADER constants defined above.
Returns:
The empty string if the header is in the right order, or a... | Returns a non-empty error message if the next header is out of order. | def CheckNextIncludeOrder(self, header_type):
"""Returns a non-empty error message if the next header is out of order.
This function also updates the internal state to be ready to check
the next include.
Args:
header_type: One of the _XXX_HEADER constants defined above.
Returns:
The e... | [
"def",
"CheckNextIncludeOrder",
"(",
"self",
",",
"header_type",
")",
":",
"error_message",
"=",
"(",
"'Found %s after %s'",
"%",
"(",
"self",
".",
"_TYPE_NAMES",
"[",
"header_type",
"]",
",",
"self",
".",
"_SECTION_NAMES",
"[",
"self",
".",
"_section",
"]",
... | [
909,
2
] | [
960,
13
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.SetOutputFormat | (self, output_format) | Sets the output format for errors. | Sets the output format for errors. | def SetOutputFormat(self, output_format):
"""Sets the output format for errors."""
self.output_format = output_format | [
"def",
"SetOutputFormat",
"(",
"self",
",",
"output_format",
")",
":",
"self",
".",
"output_format",
"=",
"output_format"
] | [
988,
2
] | [
990,
38
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.SetVerboseLevel | (self, level) | Sets the module's verbosity, and returns the previous setting. | Sets the module's verbosity, and returns the previous setting. | def SetVerboseLevel(self, level):
"""Sets the module's verbosity, and returns the previous setting."""
last_verbose_level = self.verbose_level
self.verbose_level = level
return last_verbose_level | [
"def",
"SetVerboseLevel",
"(",
"self",
",",
"level",
")",
":",
"last_verbose_level",
"=",
"self",
".",
"verbose_level",
"self",
".",
"verbose_level",
"=",
"level",
"return",
"last_verbose_level"
] | [
992,
2
] | [
996,
29
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.SetCountingStyle | (self, counting_style) | Sets the module's counting options. | Sets the module's counting options. | def SetCountingStyle(self, counting_style):
"""Sets the module's counting options."""
self.counting = counting_style | [
"def",
"SetCountingStyle",
"(",
"self",
",",
"counting_style",
")",
":",
"self",
".",
"counting",
"=",
"counting_style"
] | [
998,
2
] | [
1000,
34
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.SetFilters | (self, filters) | Sets the error-message filters.
These filters are applied when deciding whether to emit a given
error message.
Args:
filters: A string of comma-separated filters (eg "+whitespace/indent").
Each filter should start with + or -; else we die.
Raises:
ValueError: The comma-sepa... | Sets the error-message filters. | def SetFilters(self, filters):
"""Sets the error-message filters.
These filters are applied when deciding whether to emit a given
error message.
Args:
filters: A string of comma-separated filters (eg "+whitespace/indent").
Each filter should start with + or -; else we die.
Ra... | [
"def",
"SetFilters",
"(",
"self",
",",
"filters",
")",
":",
"# Default filters always have less priority than the flag ones.",
"self",
".",
"filters",
"=",
"_DEFAULT_FILTERS",
"[",
":",
"]",
"self",
".",
"AddFilters",
"(",
"filters",
")"
] | [
1002,
2
] | [
1018,
28
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.AddFilters | (self, filters) | Adds more filters to the existing list of error-message filters. | Adds more filters to the existing list of error-message filters. | def AddFilters(self, filters):
""" Adds more filters to the existing list of error-message filters. """
for filt in filters.split(','):
clean_filt = filt.strip()
if clean_filt:
self.filters.append(clean_filt)
for filt in self.filters:
if not (filt.startswith('+') or filt.startswith... | [
"def",
"AddFilters",
"(",
"self",
",",
"filters",
")",
":",
"for",
"filt",
"in",
"filters",
".",
"split",
"(",
"','",
")",
":",
"clean_filt",
"=",
"filt",
".",
"strip",
"(",
")",
"if",
"clean_filt",
":",
"self",
".",
"filters",
".",
"append",
"(",
... | [
1020,
2
] | [
1029,
49
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.BackupFilters | (self) | Saves the current filter list to backup storage. | Saves the current filter list to backup storage. | def BackupFilters(self):
""" Saves the current filter list to backup storage."""
self._filters_backup = self.filters[:] | [
"def",
"BackupFilters",
"(",
"self",
")",
":",
"self",
".",
"_filters_backup",
"=",
"self",
".",
"filters",
"[",
":",
"]"
] | [
1031,
2
] | [
1033,
42
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.RestoreFilters | (self) | Restores filters previously backed up. | Restores filters previously backed up. | def RestoreFilters(self):
""" Restores filters previously backed up."""
self.filters = self._filters_backup[:] | [
"def",
"RestoreFilters",
"(",
"self",
")",
":",
"self",
".",
"filters",
"=",
"self",
".",
"_filters_backup",
"[",
":",
"]"
] | [
1035,
2
] | [
1037,
42
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.ResetErrorCounts | (self) | Sets the module's error statistic back to zero. | Sets the module's error statistic back to zero. | def ResetErrorCounts(self):
"""Sets the module's error statistic back to zero."""
self.error_count = 0
self.errors_by_category = {} | [
"def",
"ResetErrorCounts",
"(",
"self",
")",
":",
"self",
".",
"error_count",
"=",
"0",
"self",
".",
"errors_by_category",
"=",
"{",
"}"
] | [
1039,
2
] | [
1042,
32
] | python | en | ['en', 'it', 'en'] | True |
_CppLintState.IncrementErrorCount | (self, category) | Bumps the module's error statistic. | Bumps the module's error statistic. | def IncrementErrorCount(self, category):
"""Bumps the module's error statistic."""
self.error_count += 1
if self.counting in ('toplevel', 'detailed'):
if self.counting != 'detailed':
category = category.split('/')[0]
if category not in self.errors_by_category:
self.errors_by_cate... | [
"def",
"IncrementErrorCount",
"(",
"self",
",",
"category",
")",
":",
"self",
".",
"error_count",
"+=",
"1",
"if",
"self",
".",
"counting",
"in",
"(",
"'toplevel'",
",",
"'detailed'",
")",
":",
"if",
"self",
".",
"counting",
"!=",
"'detailed'",
":",
"cat... | [
1044,
2
] | [
1052,
44
] | python | en | ['en', 'it', 'en'] | True |
_CppLintState.PrintErrorCounts | (self) | Print a summary of errors by category, and the total. | Print a summary of errors by category, and the total. | def PrintErrorCounts(self):
"""Print a summary of errors by category, and the total."""
for category, count in sorted(iteritems(self.errors_by_category)):
self.PrintInfo('Category \'%s\' errors found: %d\n' %
(category, count))
if self.error_count > 0:
self.PrintInfo('Tota... | [
"def",
"PrintErrorCounts",
"(",
"self",
")",
":",
"for",
"category",
",",
"count",
"in",
"sorted",
"(",
"iteritems",
"(",
"self",
".",
"errors_by_category",
")",
")",
":",
"self",
".",
"PrintInfo",
"(",
"'Category \\'%s\\' errors found: %d\\n'",
"%",
"(",
"cat... | [
1054,
2
] | [
1060,
67
] | python | en | ['en', 'en', 'en'] | True |
_FunctionState.Begin | (self, function_name) | Start analyzing function body.
Args:
function_name: The name of the function being tracked.
| Start analyzing function body. | def Begin(self, function_name):
"""Start analyzing function body.
Args:
function_name: The name of the function being tracked.
"""
self.in_a_function = True
self.lines_in_function = 0
self.current_function = function_name | [
"def",
"Begin",
"(",
"self",
",",
"function_name",
")",
":",
"self",
".",
"in_a_function",
"=",
"True",
"self",
".",
"lines_in_function",
"=",
"0",
"self",
".",
"current_function",
"=",
"function_name"
] | [
1196,
2
] | [
1204,
41
] | python | en | ['en', 'ru-Latn', 'en'] | True |
_FunctionState.Count | (self) | Count line in current function body. | Count line in current function body. | def Count(self):
"""Count line in current function body."""
if self.in_a_function:
self.lines_in_function += 1 | [
"def",
"Count",
"(",
"self",
")",
":",
"if",
"self",
".",
"in_a_function",
":",
"self",
".",
"lines_in_function",
"+=",
"1"
] | [
1206,
2
] | [
1209,
33
] | python | en | ['en', 'en', 'en'] | True |
_FunctionState.Check | (self, error, filename, linenum) | Report if too many lines in function body.
Args:
error: The function to call with any errors found.
filename: The name of the current file.
linenum: The number of the line to check.
| Report if too many lines in function body. | def Check(self, error, filename, linenum):
"""Report if too many lines in function body.
Args:
error: The function to call with any errors found.
filename: The name of the current file.
linenum: The number of the line to check.
"""
if not self.in_a_function:
return
if Match... | [
"def",
"Check",
"(",
"self",
",",
"error",
",",
"filename",
",",
"linenum",
")",
":",
"if",
"not",
"self",
".",
"in_a_function",
":",
"return",
"if",
"Match",
"(",
"r'T(EST|est)'",
",",
"self",
".",
"current_function",
")",
":",
"base_trigger",
"=",
"sel... | [
1211,
2
] | [
1237,
72
] | python | en | ['en', 'en', 'en'] | True |
_FunctionState.End | (self) | Stop analyzing function body. | Stop analyzing function body. | def End(self):
"""Stop analyzing function body."""
self.in_a_function = False | [
"def",
"End",
"(",
"self",
")",
":",
"self",
".",
"in_a_function",
"=",
"False"
] | [
1239,
2
] | [
1241,
30
] | python | en | ['en', 'en', 'en'] | True |
FileInfo.FullName | (self) | Make Windows paths like Unix. | Make Windows paths like Unix. | def FullName(self):
"""Make Windows paths like Unix."""
return os.path.abspath(self._filename).replace('\\', '/') | [
"def",
"FullName",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"_filename",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")"
] | [
1259,
2
] | [
1261,
61
] | python | en | ['en', 'ny', 'en'] | True |
FileInfo.RepositoryName | (self) | r"""FullName after removing the local path to the repository.
If we have a real absolute path name here we can try to do something smart:
detecting the root of the checkout and truncating /path/to/checkout from
the name so that we get header guards that don't include things like
"C:\Documents and Setti... | r"""FullName after removing the local path to the repository. | def RepositoryName(self):
r"""FullName after removing the local path to the repository.
If we have a real absolute path name here we can try to do something smart:
detecting the root of the checkout and truncating /path/to/checkout from
the name so that we get header guards that don't include things li... | [
"def",
"RepositoryName",
"(",
"self",
")",
":",
"fullname",
"=",
"self",
".",
"FullName",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fullname",
")",
":",
"project_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"fullname",
")",
"# If ... | [
1263,
2
] | [
1321,
19
] | python | en | ['en', 'en', 'en'] | True |
FileInfo.Split | (self) | Splits the file into the directory, basename, and extension.
For 'chrome/browser/browser.cc', Split() would
return ('chrome/browser', 'browser', '.cc')
Returns:
A tuple of (directory, basename, extension).
| Splits the file into the directory, basename, and extension. | def Split(self):
"""Splits the file into the directory, basename, and extension.
For 'chrome/browser/browser.cc', Split() would
return ('chrome/browser', 'browser', '.cc')
Returns:
A tuple of (directory, basename, extension).
"""
googlename = self.RepositoryName()
project, rest = os... | [
"def",
"Split",
"(",
"self",
")",
":",
"googlename",
"=",
"self",
".",
"RepositoryName",
"(",
")",
"project",
",",
"rest",
"=",
"os",
".",
"path",
".",
"split",
"(",
"googlename",
")",
"return",
"(",
"project",
",",
")",
"+",
"os",
".",
"path",
"."... | [
1323,
2
] | [
1335,
46
] | python | en | ['en', 'en', 'en'] | True |
FileInfo.BaseName | (self) | File base name - text after the final slash, before the final period. | File base name - text after the final slash, before the final period. | def BaseName(self):
"""File base name - text after the final slash, before the final period."""
return self.Split()[1] | [
"def",
"BaseName",
"(",
"self",
")",
":",
"return",
"self",
".",
"Split",
"(",
")",
"[",
"1",
"]"
] | [
1337,
2
] | [
1339,
26
] | python | en | ['en', 'en', 'en'] | True |
FileInfo.Extension | (self) | File extension - text following the final period, includes that period. | File extension - text following the final period, includes that period. | def Extension(self):
"""File extension - text following the final period, includes that period."""
return self.Split()[2] | [
"def",
"Extension",
"(",
"self",
")",
":",
"return",
"self",
".",
"Split",
"(",
")",
"[",
"2",
"]"
] | [
1341,
2
] | [
1343,
26
] | python | en | ['en', 'en', 'en'] | True |
FileInfo.NoExtension | (self) | File has no source file extension. | File has no source file extension. | def NoExtension(self):
"""File has no source file extension."""
return '/'.join(self.Split()[0:2]) | [
"def",
"NoExtension",
"(",
"self",
")",
":",
"return",
"'/'",
".",
"join",
"(",
"self",
".",
"Split",
"(",
")",
"[",
"0",
":",
"2",
"]",
")"
] | [
1345,
2
] | [
1347,
38
] | python | en | ['en', 'en', 'en'] | True |
FileInfo.IsSource | (self) | File has a source file extension. | File has a source file extension. | def IsSource(self):
"""File has a source file extension."""
return _IsSourceExtension(self.Extension()[1:]) | [
"def",
"IsSource",
"(",
"self",
")",
":",
"return",
"_IsSourceExtension",
"(",
"self",
".",
"Extension",
"(",
")",
"[",
"1",
":",
"]",
")"
] | [
1349,
2
] | [
1351,
51
] | python | en | ['en', 'en', 'en'] | True |
CleansedLines.NumLines | (self) | Returns the number of lines represented. | Returns the number of lines represented. | def NumLines(self):
"""Returns the number of lines represented."""
return self.num_lines | [
"def",
"NumLines",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_lines"
] | [
1616,
2
] | [
1618,
25
] | python | en | ['en', 'en', 'en'] | True |
CleansedLines._CollapseStrings | (elided) | Collapses strings and chars on a line to simple "" or '' blocks.
We nix strings first so we're not fooled by text like '"http://"'
Args:
elided: The line being processed.
Returns:
The line with collapsed strings.
| Collapses strings and chars on a line to simple "" or '' blocks. | def _CollapseStrings(elided):
"""Collapses strings and chars on a line to simple "" or '' blocks.
We nix strings first so we're not fooled by text like '"http://"'
Args:
elided: The line being processed.
Returns:
The line with collapsed strings.
"""
if _RE_PATTERN_INCLUDE.match(el... | [
"def",
"_CollapseStrings",
"(",
"elided",
")",
":",
"if",
"_RE_PATTERN_INCLUDE",
".",
"match",
"(",
"elided",
")",
":",
"return",
"elided",
"# Remove escaped characters first to make quote/single quote collapsing",
"# basic. Things that look like escaped characters shouldn't occur... | [
1621,
2
] | [
1685,
20
] | python | en | ['en', 'en', 'en'] | True |
_BlockInfo.CheckBegin | (self, filename, clean_lines, linenum, error) | Run checks that applies to text up to the opening brace.
This is mostly for checking the text after the class identifier
and the "{", usually where the base class is specified. For other
blocks, there isn't much to check, so we always pass.
Args:
filename: The name of the current file.
cl... | Run checks that applies to text up to the opening brace. | def CheckBegin(self, filename, clean_lines, linenum, error):
"""Run checks that applies to text up to the opening brace.
This is mostly for checking the text after the class identifier
and the "{", usually where the base class is specified. For other
blocks, there isn't much to check, so we always pas... | [
"def",
"CheckBegin",
"(",
"self",
",",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"pass"
] | [
2322,
2
] | [
2335,
8
] | python | en | ['en', 'en', 'en'] | True |
_BlockInfo.CheckEnd | (self, filename, clean_lines, linenum, error) | Run checks that applies to text after the closing brace.
This is mostly used for checking end of namespace comments.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
error: The function to... | Run checks that applies to text after the closing brace. | def CheckEnd(self, filename, clean_lines, linenum, error):
"""Run checks that applies to text after the closing brace.
This is mostly used for checking end of namespace comments.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
line... | [
"def",
"CheckEnd",
"(",
"self",
",",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"pass"
] | [
2337,
2
] | [
2348,
8
] | python | en | ['en', 'en', 'en'] | True |
_BlockInfo.IsBlockInfo | (self) | Returns true if this block is a _BlockInfo.
This is convenient for verifying that an object is an instance of
a _BlockInfo, but not an instance of any of the derived classes.
Returns:
True for this class, False for derived classes.
| Returns true if this block is a _BlockInfo. | def IsBlockInfo(self):
"""Returns true if this block is a _BlockInfo.
This is convenient for verifying that an object is an instance of
a _BlockInfo, but not an instance of any of the derived classes.
Returns:
True for this class, False for derived classes.
"""
return self.__class__ == _... | [
"def",
"IsBlockInfo",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"==",
"_BlockInfo"
] | [
2350,
2
] | [
2359,
39
] | python | en | ['en', 'en', 'en'] | True |
_NamespaceInfo.CheckEnd | (self, filename, clean_lines, linenum, error) | Check end of namespace comments. | Check end of namespace comments. | def CheckEnd(self, filename, clean_lines, linenum, error):
"""Check end of namespace comments."""
line = clean_lines.raw_lines[linenum]
# Check how many lines is enclosed in this namespace. Don't issue
# warning for missing namespace comments if there aren't enough
# lines. However, do apply chec... | [
"def",
"CheckEnd",
"(",
"self",
",",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"raw_lines",
"[",
"linenum",
"]",
"# Check how many lines is enclosed in this namespace. Don't issue",
"# warning for missing n... | [
2446,
2
] | [
2496,
79
] | python | en | ['en', 'en', 'en'] | True |
NestingState.SeenOpenBrace | (self) | Check if we have seen the opening brace for the innermost block.
Returns:
True if we have seen the opening brace, False if the innermost
block is still expecting an opening brace.
| Check if we have seen the opening brace for the innermost block. | def SeenOpenBrace(self):
"""Check if we have seen the opening brace for the innermost block.
Returns:
True if we have seen the opening brace, False if the innermost
block is still expecting an opening brace.
"""
return (not self.stack) or self.stack[-1].seen_open_brace | [
"def",
"SeenOpenBrace",
"(",
"self",
")",
":",
"return",
"(",
"not",
"self",
".",
"stack",
")",
"or",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
".",
"seen_open_brace"
] | [
2539,
2
] | [
2546,
61
] | python | en | ['en', 'en', 'en'] | True |
NestingState.InNamespaceBody | (self) | Check if we are currently one level inside a namespace body.
Returns:
True if top of the stack is a namespace block, False otherwise.
| Check if we are currently one level inside a namespace body. | def InNamespaceBody(self):
"""Check if we are currently one level inside a namespace body.
Returns:
True if top of the stack is a namespace block, False otherwise.
"""
return self.stack and isinstance(self.stack[-1], _NamespaceInfo) | [
"def",
"InNamespaceBody",
"(",
"self",
")",
":",
"return",
"self",
".",
"stack",
"and",
"isinstance",
"(",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
",",
"_NamespaceInfo",
")"
] | [
2548,
2
] | [
2554,
68
] | python | en | ['en', 'en', 'en'] | True |
NestingState.InExternC | (self) | Check if we are currently one level inside an 'extern "C"' block.
Returns:
True if top of the stack is an extern block, False otherwise.
| Check if we are currently one level inside an 'extern "C"' block. | def InExternC(self):
"""Check if we are currently one level inside an 'extern "C"' block.
Returns:
True if top of the stack is an extern block, False otherwise.
"""
return self.stack and isinstance(self.stack[-1], _ExternCInfo) | [
"def",
"InExternC",
"(",
"self",
")",
":",
"return",
"self",
".",
"stack",
"and",
"isinstance",
"(",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
",",
"_ExternCInfo",
")"
] | [
2556,
2
] | [
2562,
66
] | python | en | ['en', 'en', 'en'] | True |
NestingState.InClassDeclaration | (self) | Check if we are currently one level inside a class or struct declaration.
Returns:
True if top of the stack is a class/struct, False otherwise.
| Check if we are currently one level inside a class or struct declaration. | def InClassDeclaration(self):
"""Check if we are currently one level inside a class or struct declaration.
Returns:
True if top of the stack is a class/struct, False otherwise.
"""
return self.stack and isinstance(self.stack[-1], _ClassInfo) | [
"def",
"InClassDeclaration",
"(",
"self",
")",
":",
"return",
"self",
".",
"stack",
"and",
"isinstance",
"(",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
",",
"_ClassInfo",
")"
] | [
2564,
2
] | [
2570,
64
] | python | en | ['en', 'en', 'en'] | True |
NestingState.InAsmBlock | (self) | Check if we are currently one level inside an inline ASM block.
Returns:
True if the top of the stack is a block containing inline ASM.
| Check if we are currently one level inside an inline ASM block. | def InAsmBlock(self):
"""Check if we are currently one level inside an inline ASM block.
Returns:
True if the top of the stack is a block containing inline ASM.
"""
return self.stack and self.stack[-1].inline_asm != _NO_ASM | [
"def",
"InAsmBlock",
"(",
"self",
")",
":",
"return",
"self",
".",
"stack",
"and",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
".",
"inline_asm",
"!=",
"_NO_ASM"
] | [
2572,
2
] | [
2578,
62
] | python | en | ['en', 'en', 'en'] | True |
NestingState.InTemplateArgumentList | (self, clean_lines, linenum, pos) | Check if current position is inside template argument list.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
pos: position just after the suspected template argument.
Returns:
True if (linenum, pos) is inside template arguments.
... | Check if current position is inside template argument list. | def InTemplateArgumentList(self, clean_lines, linenum, pos):
"""Check if current position is inside template argument list.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
pos: position just after the suspected template argument.
... | [
"def",
"InTemplateArgumentList",
"(",
"self",
",",
"clean_lines",
",",
"linenum",
",",
"pos",
")",
":",
"while",
"linenum",
"<",
"clean_lines",
".",
"NumLines",
"(",
")",
":",
"# Find the earliest character that might indicate a template argument",
"line",
"=",
"clean... | [
2580,
2
] | [
2630,
16
] | python | en | ['en', 'en', 'en'] | True |
NestingState.UpdatePreprocessor | (self, line) | Update preprocessor stack.
We need to handle preprocessors due to classes like this:
#ifdef SWIG
struct ResultDetailsPageElementExtensionPoint {
#else
struct ResultDetailsPageElementExtensionPoint : public Extension {
#endif
We make the following assumptions (good enough for most... | Update preprocessor stack. | def UpdatePreprocessor(self, line):
"""Update preprocessor stack.
We need to handle preprocessors due to classes like this:
#ifdef SWIG
struct ResultDetailsPageElementExtensionPoint {
#else
struct ResultDetailsPageElementExtensionPoint : public Extension {
#endif
We make the ... | [
"def",
"UpdatePreprocessor",
"(",
"self",
",",
"line",
")",
":",
"if",
"Match",
"(",
"r'^\\s*#\\s*(if|ifdef|ifndef)\\b'",
",",
"line",
")",
":",
"# Beginning of #if block, save the nesting stack here. The saved",
"# stack will allow us to restore the parsing state in the #else cas... | [
2632,
2
] | [
2686,
12
] | python | en | ['en', 'co', 'en'] | True |
NestingState.Update | (self, filename, clean_lines, linenum, error) | Update nesting state with current line.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
error: The function to call with any errors found.
| Update nesting state with current line. | def Update(self, filename, clean_lines, linenum, error):
"""Update nesting state with current line.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
error: The function to call with any err... | [
"def",
"Update",
"(",
"self",
",",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"# Remember top of the previous nesting stack.",
"#",
"# The stack is always pushed/popped and no... | [
2689,
2
] | [
2849,
17
] | python | en | ['en', 'en', 'en'] | True |
getArticlesOn_n_pages | (num_pages_to_check) |
clanki se pojavijo na strani sele, ko se zloada javascript,
zato se uporabi selenium knjiznjica
|
clanki se pojavijo na strani sele, ko se zloada javascript,
zato se uporabi selenium knjiznjica
| def getArticlesOn_n_pages(num_pages_to_check):
'''
clanki se pojavijo na strani sele, ko se zloada javascript,
zato se uporabi selenium knjiznjica
'''
options = Options()
options.set_headless(headless=True)
options.add_argument("--window-size=1920x1080")
driver = webdriver.Chrome... | [
"def",
"getArticlesOn_n_pages",
"(",
"num_pages_to_check",
")",
":",
"options",
"=",
"Options",
"(",
")",
"options",
".",
"set_headless",
"(",
"headless",
"=",
"True",
")",
"options",
".",
"add_argument",
"(",
"\"--window-size=1920x1080\"",
")",
"driver",
"=",
"... | [
47,
0
] | [
82,
19
] | python | en | ['en', 'error', 'th'] | False |
remove | (self:Pipeline, t) | Remove an instance of `t` from `self` if present | Remove an instance of `t` from `self` if present | def remove(self:Pipeline, t):
"Remove an instance of `t` from `self` if present"
for i,o in enumerate(self.fs):
if isinstance(o, t.__class__): self.fs.pop(i) | [
"def",
"remove",
"(",
"self",
":",
"Pipeline",
",",
"t",
")",
":",
"for",
"i",
",",
"o",
"in",
"enumerate",
"(",
"self",
".",
"fs",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"t",
".",
"__class__",
")",
":",
"self",
".",
"fs",
".",
"pop",
"... | [
51,
0
] | [
54,
53
] | python | en | ['en', 'en', 'en'] | True |
set_base_transforms | (self:DataLoader) | Removes all transforms with a `size` parameter | Removes all transforms with a `size` parameter | def set_base_transforms(self:DataLoader):
"Removes all transforms with a `size` parameter"
attrs = ['after_item', 'after_batch']
for i, attr in enumerate(attrs):
tfms = getattr(self, attr)
for j, o in enumerate(tfms):
if hasattr(o, 'size'):
tfms.remove(o)
... | [
"def",
"set_base_transforms",
"(",
"self",
":",
"DataLoader",
")",
":",
"attrs",
"=",
"[",
"'after_item'",
",",
"'after_batch'",
"]",
"for",
"i",
",",
"attr",
"in",
"enumerate",
"(",
"attrs",
")",
":",
"tfms",
"=",
"getattr",
"(",
"self",
",",
"attr",
... | [
56,
0
] | [
64,
33
] | python | en | ['en', 'en', 'en'] | True |
icevision_tta | (model_type, items, model) | Simple TTA with horizontal and vertical flips as augmentations | Simple TTA with horizontal and vertical flips as augmentations | def icevision_tta(model_type, items, model) -> list:
"Simple TTA with horizontal and vertical flips as augmentations"
infer_tfms = tfms.A.Adapter([tfms.A.Normalize()])
hflip_tfms = tfms.A.Adapter([tfms.A.Normalize(), tfms.A.HorizontalFlip(p=1)])
vflip_tfms = tfms.A.Adapter([tfms.A.Normalize(), tfms.A.Ve... | [
"def",
"icevision_tta",
"(",
"model_type",
",",
"items",
",",
"model",
")",
"->",
"list",
":",
"infer_tfms",
"=",
"tfms",
".",
"A",
".",
"Adapter",
"(",
"[",
"tfms",
".",
"A",
".",
"Normalize",
"(",
")",
"]",
")",
"hflip_tfms",
"=",
"tfms",
".",
"A... | [
68,
0
] | [
99,
16
] | python | en | ['en', 'en', 'en'] | True |
predict_bboxes | (path_to_model_config:Param("Path to pretrained model folder",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
processing_dir:Param("Directory to save the intermediate tiles. De... | Detect bounding boxes from a new image using a pretrained model | Detect bounding boxes from a new image using a pretrained model | def predict_bboxes(path_to_model_config:Param("Path to pretrained model folder",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
processing_dir:Param("Directory to save the inte... | [
"def",
"predict_bboxes",
"(",
"path_to_model_config",
":",
"Param",
"(",
"\"Path to pretrained model folder\"",
",",
"type",
"=",
"str",
")",
",",
"path_to_image",
":",
"Param",
"(",
"\"Path to image to annotate\"",
",",
"type",
"=",
"str",
")",
",",
"outfile",
":... | [
104,
0
] | [
195,
10
] | python | en | ['en', 'en', 'en'] | True |
predict_instance_masks_detectron2 | (path_to_model_config:Param("Path to pretrained model folder",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
processin... | Segment instance masks from a new image using a pretrained model | Segment instance masks from a new image using a pretrained model | def predict_instance_masks_detectron2(path_to_model_config:Param("Path to pretrained model folder",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
... | [
"def",
"predict_instance_masks_detectron2",
"(",
"path_to_model_config",
":",
"Param",
"(",
"\"Path to pretrained model folder\"",
",",
"type",
"=",
"str",
")",
",",
"path_to_image",
":",
"Param",
"(",
"\"Path to image to annotate\"",
",",
"type",
"=",
"str",
")",
","... | [
206,
0
] | [
308,
10
] | python | en | ['en', 'en', 'en'] | True |
predict_instance_masks_icevision | (path_to_model_config:Param("Path to pretrained model folder",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
processing_dir:... | Segment instance masks from a new image using a pretrained model | Segment instance masks from a new image using a pretrained model | def predict_instance_masks_icevision(path_to_model_config:Param("Path to pretrained model folder",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
... | [
"def",
"predict_instance_masks_icevision",
"(",
"path_to_model_config",
":",
"Param",
"(",
"\"Path to pretrained model folder\"",
",",
"type",
"=",
"str",
")",
",",
"path_to_image",
":",
"Param",
"(",
"\"Path to image to annotate\"",
",",
"type",
"=",
"str",
")",
",",... | [
317,
0
] | [
414,
10
] | python | en | ['en', 'en', 'en'] | True |
predict_segmentation | (path_to_model:Param("Path to pretrained model file",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
processing_dir:Param("Directory to save the intermediate ... | Segment image into land cover classes with a pretrained models
TODO save also information about label and class
TODO add test-time augmentations | Segment image into land cover classes with a pretrained models
TODO save also information about label and class
TODO add test-time augmentations | def predict_segmentation(path_to_model:Param("Path to pretrained model file",type=str),
path_to_image:Param("Path to image to annotate", type=str),
outfile:Param('Path and filename for output raster', type=str),
processing_dir:Param("Directory t... | [
"def",
"predict_segmentation",
"(",
"path_to_model",
":",
"Param",
"(",
"\"Path to pretrained model file\"",
",",
"type",
"=",
"str",
")",
",",
"path_to_image",
":",
"Param",
"(",
"\"Path to image to annotate\"",
",",
"type",
"=",
"str",
")",
",",
"outfile",
":",
... | [
420,
0
] | [
511,
10
] | python | en | ['en', 'en', 'en'] | True |
to_int_8_16_32_64_128_256 | (self, cast) | Check the toInt(8|16|32|64|128|256) functions with DateTime64 extended range
| Check the toInt(8|16|32|64|128|256) functions with DateTime64 extended range
| def to_int_8_16_32_64_128_256(self, cast):
"""Check the toInt(8|16|32|64|128|256) functions with DateTime64 extended range
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
datetimes... | [
"def",
"to_int_8_16_32_64_128_256",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Giv... | [
20,
0
] | [
53,
85
] | python | en | ['en', 'en', 'en'] | True |
to_uint_8_16_32_64_256 | (self, cast) | Check the toUInt(8|16|32|64|256) functions with DateTime64 extended range
| Check the toUInt(8|16|32|64|256) functions with DateTime64 extended range
| def to_uint_8_16_32_64_256(self, cast):
"""Check the toUInt(8|16|32|64|256) functions with DateTime64 extended range
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
datetimes = sel... | [
"def",
"to_uint_8_16_32_64_256",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given"... | [
61,
0
] | [
94,
85
] | python | en | ['en', 'en', 'en'] | True |
to_float_32_64 | (self, cast) | Check the toFloat(32|64) functions with DateTime64 extended range
| Check the toFloat(32|64) functions with DateTime64 extended range
| def to_float_32_64(self, cast):
"""Check the toFloat(32|64) functions with DateTime64 extended range
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
datetimes = select_dates_in_yea... | [
"def",
"to_float_32_64",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",... | [
102,
0
] | [
130,
81
] | python | en | ['en', 'en', 'en'] | True |
to_datetime64_from_string_missing_time | (self) | Check the toDateTime64() with DateTime64 extended range conversion when string is missing the time part.
| Check the toDateTime64() with DateTime64 extended range conversion when string is missing the time part.
| def to_datetime64_from_string_missing_time(self):
"""Check the toDateTime64() with DateTime64 extended range conversion when string is missing the time part.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes... | [
"def",
"to_datetime64_from_string_missing_time",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",... | [
137,
0
] | [
157,
73
] | python | en | ['en', 'en', 'en'] | True |
to_datetime64 | (self) | Check the toDateTime64() conversion with DateTime64. This is supposed to work in normal range ONLY.
| Check the toDateTime64() conversion with DateTime64. This is supposed to work in normal range ONLY.
| def to_datetime64(self):
"""Check the toDateTime64() conversion with DateTime64. This is supposed to work in normal range ONLY.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
date... | [
"def",
"to_datetime64",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I select da... | [
164,
0
] | [
183,
69
] | python | en | ['en', 'en', 'en'] | True |
to_date | (self, cast) | Check the toDate() conversion with DateTime64. This is supposed to work in normal range ONLY.
| Check the toDate() conversion with DateTime64. This is supposed to work in normal range ONLY.
| def to_date(self, cast):
"""Check the toDate() conversion with DateTime64. This is supposed to work in normal range ONLY.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
datetimes ... | [
"def",
"to_date",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"... | [
191,
0
] | [
219,
80
] | python | en | ['en', 'en', 'en'] | True |
to_datetime | (self, cast) | Check the toDateTime() conversion with DateTime64. This is supposed to work in normal range ONLY.
| Check the toDateTime() conversion with DateTime64. This is supposed to work in normal range ONLY.
| def to_datetime(self, cast):
"""Check the toDateTime() conversion with DateTime64. This is supposed to work in normal range ONLY.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
da... | [
"def",
"to_datetime",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
... | [
227,
0
] | [
258,
73
] | python | en | ['en', 'en', 'en'] | True |
to_string | (self, cast) | Check the toString() with DateTime64 extended range.
| Check the toString() with DateTime64 extended range.
| def to_string(self, cast):
"""Check the toString() with DateTime64 extended range.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
datetimes = select_dates_in_year(year=year, stres... | [
"def",
"to_string",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f... | [
266,
0
] | [
287,
71
] | python | en | ['en', 'en', 'en'] | True |
valid_decimal_range | (bit_depth, S) | A helper to find valid range for Decimal(32|64|128|256) with given scale (S) | A helper to find valid range for Decimal(32|64|128|256) with given scale (S) | def valid_decimal_range(bit_depth, S):
"""A helper to find valid range for Decimal(32|64|128|256) with given scale (S)"""
return {32: -1 * 10 ** (9 - S), 64: -1 * 10 ** (18 - S), 128: -1 * 10 ** (38 - S), 256: -1 * 10 ** (76 - S)}[
bit_depth] | [
"def",
"valid_decimal_range",
"(",
"bit_depth",
",",
"S",
")",
":",
"return",
"{",
"32",
":",
"-",
"1",
"*",
"10",
"**",
"(",
"9",
"-",
"S",
")",
",",
"64",
":",
"-",
"1",
"*",
"10",
"**",
"(",
"18",
"-",
"S",
")",
",",
"128",
":",
"-",
"... | [
290,
0
] | [
293,
18
] | python | en | ['en', 'en', 'en'] | True |
to_decimal_32_64_128_256 | (self, cast) | Check the toDecimal(32|64|128|256) functions with DateTime64 extended range.
Decimal32(S) - ( -1 * 10^(9 - S), 1 * 10^(9 - S) )
Decimal64(S) - ( -1 * 10^(18 - S), 1 * 10^(18 - S) )
Decimal128(S) - ( -1 * 10^(38 - S), 1 * 10^(38 - S) )
Decimal256(S) - ( -1 * 10^(76 - S), 1 * 10^(76 - S) )
| Check the toDecimal(32|64|128|256) functions with DateTime64 extended range.
Decimal32(S) - ( -1 * 10^(9 - S), 1 * 10^(9 - S) )
Decimal64(S) - ( -1 * 10^(18 - S), 1 * 10^(18 - S) )
Decimal128(S) - ( -1 * 10^(38 - S), 1 * 10^(38 - S) )
Decimal256(S) - ( -1 * 10^(76 - S), 1 * 10^(76 - S) )
| def to_decimal_32_64_128_256(self, cast):
"""Check the toDecimal(32|64|128|256) functions with DateTime64 extended range.
Decimal32(S) - ( -1 * 10^(9 - S), 1 * 10^(9 - S) )
Decimal64(S) - ( -1 * 10^(18 - S), 1 * 10^(18 - S) )
Decimal128(S) - ( -1 * 10^(38 - S), 1 * 10^(38 - S) )
Decimal256(S) - ( -1... | [
"def",
"to_decimal_32_64_128_256",
"(",
"self",
",",
"cast",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"scales",
"=",
"{",
"32",
":",
"9",
",",
"64",
":",
"18",
",",
"128",
... | [
301,
0
] | [
334,
85
] | python | en | ['en', 'en', 'en'] | True |
to_unix_timestamp64_milli_micro_nano | (self, scale) | Check the toUnixTimestamp64[Milli/Micro/Nano] functions with DateTime64 extended range.
:param scale: 3 for milli, 6 for micro, 9 for nano; int
| Check the toUnixTimestamp64[Milli/Micro/Nano] functions with DateTime64 extended range.
:param scale: 3 for milli, 6 for micro, 9 for nano; int
| def to_unix_timestamp64_milli_micro_nano(self, scale):
"""Check the toUnixTimestamp64[Milli/Micro/Nano] functions with DateTime64 extended range.
:param scale: 3 for milli, 6 for micro, 9 for nano; int
"""
stress = self.context.stress
timezones = timezones_range(stress)
func = {3: 'Milli', 6: 'M... | [
"def",
"to_unix_timestamp64_milli_micro_nano",
"(",
"self",
",",
"scale",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"func",
"=",
"{",
"3",
":",
"'Milli'",
",",
"6",
":",
"'Micro... | [
338,
0
] | [
367,
73
] | python | en | ['en', 'en', 'en'] | True |
to_unix_timestamp64_milli | (self) | Check the toUnixTimestamp64Milli functions with DateTime64 extended range.
| Check the toUnixTimestamp64Milli functions with DateTime64 extended range.
| def to_unix_timestamp64_milli(self):
"""Check the toUnixTimestamp64Milli functions with DateTime64 extended range.
"""
to_unix_timestamp64_milli_micro_nano(scale=3) | [
"def",
"to_unix_timestamp64_milli",
"(",
"self",
")",
":",
"to_unix_timestamp64_milli_micro_nano",
"(",
"scale",
"=",
"3",
")"
] | [
374,
0
] | [
377,
49
] | python | en | ['en', 'en', 'en'] | True |
to_unix_timestamp64_micro | (self) | Check the toUnixTimestamp64Micro functions with DateTime64 extended range.
| Check the toUnixTimestamp64Micro functions with DateTime64 extended range.
| def to_unix_timestamp64_micro(self):
"""Check the toUnixTimestamp64Micro functions with DateTime64 extended range.
"""
to_unix_timestamp64_milli_micro_nano(scale=6) | [
"def",
"to_unix_timestamp64_micro",
"(",
"self",
")",
":",
"to_unix_timestamp64_milli_micro_nano",
"(",
"scale",
"=",
"6",
")"
] | [
384,
0
] | [
387,
49
] | python | en | ['en', 'en', 'en'] | True |
to_unix_timestamp64_nano | (self) | Check the toUnixTimestamp64Nano functions with DateTime64 extended range.
| Check the toUnixTimestamp64Nano functions with DateTime64 extended range.
| def to_unix_timestamp64_nano(self):
"""Check the toUnixTimestamp64Nano functions with DateTime64 extended range.
"""
to_unix_timestamp64_milli_micro_nano(scale=9) | [
"def",
"to_unix_timestamp64_nano",
"(",
"self",
")",
":",
"to_unix_timestamp64_milli_micro_nano",
"(",
"scale",
"=",
"9",
")"
] | [
394,
0
] | [
397,
49
] | python | en | ['en', 'en', 'en'] | True |
from_unix_timestamp64_milli_micro_nano | (self, scale) | Check the fromUnixTimestamp64[Milli/Micro/Nano] functions with DateTime64 extended range.
:param scale: 3 for milli, 6 for micro, 9 for nano; int
| Check the fromUnixTimestamp64[Milli/Micro/Nano] functions with DateTime64 extended range.
:param scale: 3 for milli, 6 for micro, 9 for nano; int
| def from_unix_timestamp64_milli_micro_nano(self, scale):
"""Check the fromUnixTimestamp64[Milli/Micro/Nano] functions with DateTime64 extended range.
:param scale: 3 for milli, 6 for micro, 9 for nano; int
"""
stress = self.context.stress
timezones = timezones_range(stress)
func = {3: 'Milli', 6... | [
"def",
"from_unix_timestamp64_milli_micro_nano",
"(",
"self",
",",
"scale",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"func",
"=",
"{",
"3",
":",
"'Milli'",
",",
"6",
":",
"'Mic... | [
401,
0
] | [
431,
70
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.