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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Match | (pattern, s) | Matches the string with the pattern, caching the compiled regexp. | Matches the string with the pattern, caching the compiled regexp. | def Match(pattern, s):
"""Matches the string with the pattern, caching the compiled regexp."""
# The regexp compilation caching is inlined in both Match and Search for
# performance reasons; factoring it out into a separate function turns out
# to be noticeably expensive.
if pattern not in _regexp_compile_cac... | [
"def",
"Match",
"(",
"pattern",
",",
"s",
")",
":",
"# The regexp compilation caching is inlined in both Match and Search for",
"# performance reasons; factoring it out into a separate function turns out",
"# to be noticeably expensive.",
"if",
"pattern",
"not",
"in",
"_regexp_compile_... | [
787,
0
] | [
794,
48
] | python | en | ['en', 'en', 'en'] | True |
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... | [
797,
0
] | [
812,
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... | [
815,
0
] | [
819,
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",
"(",
")"
] | [
822,
0
] | [
824,
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"
] | [
1161,
0
] | [
1163,
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",
")"
] | [
1166,
0
] | [
1168,
47
] | python | en | ['en', 'en', 'en'] | True |
_Quiet | () | Return's the module's quiet setting. | Return's the module's quiet setting. | def _Quiet():
"""Return's the module's quiet setting."""
return _cpplint_state.quiet | [
"def",
"_Quiet",
"(",
")",
":",
"return",
"_cpplint_state",
".",
"quiet"
] | [
1170,
0
] | [
1172,
29
] | python | en | ['en', 'la', 'en'] | True |
_SetQuiet | (quiet) | Set the module's quiet status, and return previous setting. | Set the module's quiet status, and return previous setting. | def _SetQuiet(quiet):
"""Set the module's quiet status, and return previous setting."""
return _cpplint_state.SetQuiet(quiet) | [
"def",
"_SetQuiet",
"(",
"quiet",
")",
":",
"return",
"_cpplint_state",
".",
"SetQuiet",
"(",
"quiet",
")"
] | [
1174,
0
] | [
1176,
39
] | 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"
] | [
1179,
0
] | [
1181,
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",
")"
] | [
1184,
0
] | [
1186,
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",
")"
] | [
1189,
0
] | [
1191,
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"
] | [
1194,
0
] | [
1196,
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",
")"
] | [
1199,
0
] | [
1209,
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",
")"
] | [
1211,
0
] | [
1221,
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",
"(",
")"
] | [
1223,
0
] | [
1225,
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",
"(",
")"
] | [
1227,
0
] | [
1229,
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... | [
1400,
0
] | [
1425,
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... | [
1428,
0
] | [
1464,
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",
"(",
... | [
1486,
0
] | [
1500,
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",... | [
1503,
0
] | [
1576,
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... | [
1579,
0
] | [
1587,
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",
... | [
1590,
0
] | [
1596,
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",
... | [
1599,
0
] | [
1604,
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",
... | [
1607,
0
] | [
1620,
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",
"[",
... | [
1623,
0
] | [
1636,
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",
"'([{'",
":",
"# ... | [
1734,
0
] | [
1809,
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'<[<=]'",
",",
"... | [
1812,
0
] | [
1853,
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... | [
1856,
0
] | [
1930,
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",
",",
... | [
1933,
0
] | [
1968,
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 xrange(1, min(len(lines), 11)):
if re.search(r'Copyright', lines[line], re.I): bre... | [
"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",
"xrange",
"(",
"1",
",",
"min",
"(",
"len",
"(",
"lines",
")",
","... | [
1971,
0
] | [
1981,
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"
] | [
1984,
0
] | [
1997,
12
] | python | en | ['en', 'en', 'en'] | True |
PathSplitToList | (path) | Returns the path split into a list by the separator.
Args:
path: An absolute or relative path (e.g. '/a/b/c/' or '../a')
Returns:
A list of path components (e.g. ['a', 'b', 'c]).
| Returns the path split into a list by the separator. | def PathSplitToList(path):
"""Returns the path split into a list by the separator.
Args:
path: An absolute or relative path (e.g. '/a/b/c/' or '../a')
Returns:
A list of path components (e.g. ['a', 'b', 'c]).
"""
lst = []
while True:
(head, tail) = os.path.split(path)
if head == path: # a... | [
"def",
"PathSplitToList",
"(",
"path",
")",
":",
"lst",
"=",
"[",
"]",
"while",
"True",
":",
"(",
"head",
",",
"tail",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"if",
"head",
"==",
"path",
":",
"# absolute paths end",
"lst",
".",... | [
1999,
0
] | [
2022,
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",
... | [
2024,
0
] | [
2097,
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 ... | [
2100,
0
] | [
2200,
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[0... | [
"def",
"CheckHeaderFileIncluded",
"(",
"filename",
",",
"include_state",
",",
"error",
")",
":",
"# Do not check test files",
"fileinfo",
"=",
"FileInfo",
"(",
"filename",
")",
"if",
"Search",
"(",
"_TEST_FILE_SUFFIX",
",",
"fileinfo",
".",
"BaseName",
"(",
")",
... | [
2203,
0
] | [
2227,
64
] | 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... | [
2230,
0
] | [
2252,
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-... | [
2255,
0
] | [
2270,
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... | [
2273,
0
] | [
2308,
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... | [
2341,
0
] | [
2364,
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",
")",
... | [
2367,
0
] | [
2383,
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",
... | [
2391,
0
] | [
2410,
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",
... | [
868,
2
] | [
881,
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... | [
883,
2
] | [
899,
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",
"(",
")"
] | [
904,
2
] | [
917,
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 ... | [
919,
2
] | [
938,
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",
"]",
... | [
940,
2
] | [
991,
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"
] | [
1020,
2
] | [
1022,
38
] | python | en | ['en', 'en', 'en'] | True |
_CppLintState.SetQuiet | (self, quiet) | Sets the module's quiet settings, and returns the previous setting. | Sets the module's quiet settings, and returns the previous setting. | def SetQuiet(self, quiet):
"""Sets the module's quiet settings, and returns the previous setting."""
last_quiet = self.quiet
self.quiet = quiet
return last_quiet | [
"def",
"SetQuiet",
"(",
"self",
",",
"quiet",
")",
":",
"last_quiet",
"=",
"self",
".",
"quiet",
"self",
".",
"quiet",
"=",
"quiet",
"return",
"last_quiet"
] | [
1024,
2
] | [
1028,
21
] | 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"
] | [
1030,
2
] | [
1034,
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"
] | [
1036,
2
] | [
1038,
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",
")"
] | [
1040,
2
] | [
1056,
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",
"(",
... | [
1058,
2
] | [
1067,
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",
"[",
":",
"]"
] | [
1069,
2
] | [
1071,
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",
"[",
":",
"]"
] | [
1073,
2
] | [
1075,
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",
"=",
"{",
"}"
] | [
1077,
2
] | [
1080,
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... | [
1082,
2
] | [
1090,
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... | [
1092,
2
] | [
1098,
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"
] | [
1242,
2
] | [
1250,
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"
] | [
1252,
2
] | [
1255,
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... | [
1257,
2
] | [
1283,
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"
] | [
1285,
2
] | [
1287,
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",
"(",
"'\\\\'",
",",
"'/'",
")"
] | [
1305,
2
] | [
1307,
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 ... | [
1309,
2
] | [
1367,
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",
"."... | [
1369,
2
] | [
1381,
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",
"]"
] | [
1383,
2
] | [
1385,
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",
"]"
] | [
1387,
2
] | [
1389,
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",
"]",
")"
] | [
1391,
2
] | [
1393,
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",
":",
"]",
")"
] | [
1395,
2
] | [
1397,
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"
] | [
1662,
2
] | [
1664,
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... | [
1667,
2
] | [
1731,
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"
] | [
2437,
2
] | [
2450,
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"
] | [
2452,
2
] | [
2463,
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"
] | [
2465,
2
] | [
2474,
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... | [
2561,
2
] | [
2611,
79
] | python | en | ['en', 'en', 'en'] | True |
subquery_expr_preceding | (self) | Check using subquery expr in preceding.
| Check using subquery expr in preceding.
| def subquery_expr_preceding(self):
"""Check using subquery expr in preceding.
"""
expected = convert_output("""
sum | unique1
-----+---------
0 | 0
1 | 1
3 | 2
5 | 3
7 | 4
9 | 5
11 | 6
13 | 7
... | [
"def",
"subquery_expr_preceding",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum | unique1\n -----+---------\n 0 | 0\n 1 | 1\n 3 | 2\n 5 | 3\n 7 | 4\n 9 | 5\n 11 | 6\n 13 ... | [
6,
0
] | [
30,
5
] | python | en | ['en', 'en', 'en'] | True |
window_functions_in_select_expression | (self) | Check using multiple window functions in an expression.
| Check using multiple window functions in an expression.
| def window_functions_in_select_expression(self):
"""Check using multiple window functions in an expression.
"""
expected = convert_output("""
cntsum
--------
22
22
87
24
24
82
92
51
92
136
""")
execute_query(
"SELECT (count(*) OVER ... | [
"def",
"window_functions_in_select_expression",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n cntsum\n --------\n 22\n 22\n 87\n 24\n 24\n 82\n 92\n 51\n 92\n 136\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT ... | [
33,
0
] | [
56,
5
] | python | en | ['en', 'en', 'en'] | True |
window_functions_in_subquery | (self) | Check using window functions in a subquery.
| Check using window functions in a subquery.
| def window_functions_in_subquery(self):
"""Check using window functions in a subquery.
"""
expected = convert_output("""
total | fourcount | twosum
-------+-----------+--------
""")
execute_query(
"SELECT * FROM ("
" SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + ... | [
"def",
"window_functions_in_subquery",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n total | fourcount | twosum\n -------+-----------+--------\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT * FROM (\"",
"\" SELECT count(*) OVER (PARTITION BY four ... | [
59,
0
] | [
76,
5
] | python | en | ['en', 'en', 'en'] | True |
group_by_and_one_window | (self) | Check running window function with group by and one window.
| Check running window function with group by and one window.
| def group_by_and_one_window(self):
"""Check running window function with group by and one window.
"""
expected = convert_output("""
four | ten | sum | avg
------+-----+------+------------------------
0 | 0 | 0 | 0
0 | 2 | 0 | 2
0 | 4 | 0 | ... | [
"def",
"group_by_and_one_window",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n four | ten | sum | avg\n ------+-----+------+------------------------\n 0 | 0 | 0 | 0\n 0 | 2 | 0 | 2\n 0 | 4 | 0 | 4\n ... | [
79,
0
] | [
110,
5
] | python | en | ['en', 'en', 'en'] | True |
group_by_and_multiple_windows | (self) | Check running window function with group by and multiple windows.
| Check running window function with group by and multiple windows.
| def group_by_and_multiple_windows(self):
"""Check running window function with group by and multiple windows.
"""
expected = convert_output("""
sum1 | row_number | sum2
-------+------------+-------
25100 | 1 | 47100
7400 | 2 | 22000
14600 | 3 | 14600
... | [
"def",
"group_by_and_multiple_windows",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum1 | row_number | sum2\n -------+------------+-------\n 25100 | 1 | 47100\n 7400 | 2 | 22000\n 14600 | 3 | 14600\n \"\"\"",
")"... | [
113,
0
] | [
129,
5
] | python | en | ['en', 'en', 'en'] | True |
query_with_order_by_and_one_window | (self) | Check using a window function in the query that has `ORDER BY` clause.
| Check using a window function in the query that has `ORDER BY` clause.
| def query_with_order_by_and_one_window(self):
"""Check using a window function in the query that has `ORDER BY` clause.
"""
expected = convert_output("""
depname | empno | salary | rank
----------+----------+--------+---------
sales | 3 | 4800 | 1
personnel | 5 ... | [
"def",
"query_with_order_by_and_one_window",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n depname | empno | salary | rank\n ----------+----------+--------+---------\n sales | 3 | 4800 | 1\n personnel | 5 | 3500 | 1\n ... | [
132,
0
] | [
152,
5
] | python | en | ['en', 'en', 'en'] | True |
with_union_all | (self) | Check using window over rows obtained with `UNION ALL`.
| Check using window over rows obtained with `UNION ALL`.
| def with_union_all(self):
"""Check using window over rows obtained with `UNION ALL`.
"""
expected = convert_output("""
count
-------
""")
execute_query(
"SELECT count(*) OVER (PARTITION BY four) AS count FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) LIMIT 0",
exp... | [
"def",
"with_union_all",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n count\n -------\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT count(*) OVER (PARTITION BY four) AS count FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) LIMIT 0\"",
",... | [
155,
0
] | [
166,
5
] | python | en | ['en', 'en', 'en'] | True |
empty_table | (self) | Check using an empty table with a window function.
| Check using an empty table with a window function.
| def empty_table(self):
"""Check using an empty table with a window function.
"""
expected = convert_output("""
count
-------
""")
execute_query(
"SELECT count(*) OVER (PARTITION BY four) AS count FROM (SELECT * FROM tenk1 WHERE 0)",
expected=expected
) | [
"def",
"empty_table",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n count\n -------\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT count(*) OVER (PARTITION BY four) AS count FROM (SELECT * FROM tenk1 WHERE 0)\"",
",",
"expected",
"=",
"expect... | [
169,
0
] | [
180,
5
] | python | en | ['en', 'en', 'en'] | True |
from_subquery | (self) | Check using a window function over data from subquery.
| Check using a window function over data from subquery.
| def from_subquery(self):
"""Check using a window function over data from subquery.
"""
expected = convert_output("""
count | four
-------+------
4 | 1
4 | 1
4 | 1
4 | 1
2 | 3
2 | 3
""")
execute_query(
"SELECT c... | [
"def",
"from_subquery",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n count | four\n -------+------\n 4 | 1\n 4 | 1\n 4 | 1\n 4 | 1\n 2 | 3\n 2 | 3\n \"\"\"",
")",
"execute_query",
"(",
... | [
183,
0
] | [
200,
5
] | python | en | ['en', 'en', 'en'] | True |
groups_frame | (self) | Check using `GROUPS` frame.
| Check using `GROUPS` frame.
| def groups_frame(self):
"""Check using `GROUPS` frame.
"""
exitcode, message = groups_frame_error()
expected = convert_output("""
sum | unique1 | four
-----+---------+------
12 | 0 | 0
12 | 8 | 0
12 | 4 | 0
27 | 5 | 1
27 | ... | [
"def",
"groups_frame",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"groups_frame_error",
"(",
")",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum | unique1 | four\n -----+---------+------\n 12 | 0 | 0\n 12 | 8 | 0\n 12 | ... | [
203,
0
] | [
229,
5
] | python | en | ['en', 'en', 'en'] | True |
count_with_empty_over_clause_without_start | (self) | Check that we can use `count()` window function without passing
`*` argument when using empty over clause.
| Check that we can use `count()` window function without passing
`*` argument when using empty over clause.
| def count_with_empty_over_clause_without_start(self):
"""Check that we can use `count()` window function without passing
`*` argument when using empty over clause.
"""
exitcode = 0
message = "1"
sql = ("SELECT count() OVER () FROM tenk1 LIMIT 1")
with When("I execute query", description=sq... | [
"def",
"count_with_empty_over_clause_without_start",
"(",
"self",
")",
":",
"exitcode",
"=",
"0",
"message",
"=",
"\"1\"",
"sql",
"=",
"(",
"\"SELECT count() OVER () FROM tenk1 LIMIT 1\"",
")",
"with",
"When",
"(",
"\"I execute query\"",
",",
"description",
"=",
"sql"... | [
232,
0
] | [
242,
81
] | python | en | ['en', 'en', 'en'] | True |
subquery_multiple_window_functions | (self) | Check using multiple window functions is a subquery.
| Check using multiple window functions is a subquery.
| def subquery_multiple_window_functions(self):
"""Check using multiple window functions is a subquery.
"""
expected = convert_output("""
depname | depsalary | depminsalary
--------+-------------+--------------
sales | 5000 | 5000
sales | 9800 | 4800
sales | 146... | [
"def",
"subquery_multiple_window_functions",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n depname | depsalary | depminsalary\n --------+-------------+--------------\n sales | 5000 | 5000\n sales | 9800 | 4800\n sales | 14600 ... | [
246,
0
] | [
266,
5
] | python | en | ['en', 'en', 'en'] | True |
windows_with_same_partitioning_but_different_ordering | (self) | Check using using two windows that use the same partitioning
but different ordering.
| Check using using two windows that use the same partitioning
but different ordering.
| def windows_with_same_partitioning_but_different_ordering(self):
"""Check using using two windows that use the same partitioning
but different ordering.
"""
expected = convert_output("""
first | last
------+-----
7 | 7
7 | 9
7 | 10
7 | 11
7 | 8
5 ... | [
"def",
"windows_with_same_partitioning_but_different_ordering",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n first | last\n ------+-----\n 7 | 7\n 7 | 9\n 7 | 10\n 7 | 11\n 7 | 8\n 5 | 5\n 5 | 2\n 3 | 3... | [
269,
0
] | [
295,
5
] | python | en | ['en', 'en', 'en'] | True |
subquery_with_multiple_windows_filtering | (self) | Check filtering rows from a subquery that uses multiple window functions.
| Check filtering rows from a subquery that uses multiple window functions.
| def subquery_with_multiple_windows_filtering(self):
"""Check filtering rows from a subquery that uses multiple window functions.
"""
expected = convert_output("""
depname | empno | salary | enroll_date | first_emp | last_emp
----------+-------+----------+--------------+-------------+--------... | [
"def",
"subquery_with_multiple_windows_filtering",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n depname | empno | salary | enroll_date | first_emp | last_emp\n ----------+-------+----------+--------------+-------------+----------\n develop | 8 |... | [
298,
0
] | [
324,
5
] | python | en | ['en', 'en', 'en'] | True |
exclude_clause | (self) | Check if exclude clause is supported.
| Check if exclude clause is supported.
| def exclude_clause(self):
"""Check if exclude clause is supported.
"""
exitcode, message = syntax_error()
expected = convert_output("""
sum | unique1 | four
-----+---------+------
7 | 4 | 0
13 | 2 | 2
22 | 1 | 1
26 | 6 | 2
29 |... | [
"def",
"exclude_clause",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"syntax_error",
"(",
")",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum | unique1 | four\n -----+---------+------\n 7 | 4 | 0\n 13 | 2 | 2\n 22 | ... | [
327,
0
] | [
352,
5
] | python | en | ['en', 'en', 'en'] | True |
in_view | (self) | Check using a window function in a view.
| Check using a window function in a view.
| def in_view(self):
"""Check using a window function in a view.
"""
with Given("I create a view"):
sql = """
CREATE VIEW v_window AS
SELECT number, sum(number) over (order by number rows between 1 preceding and 1 following) as sum_rows
FROM numbers(1, 10)
"""
c... | [
"def",
"in_view",
"(",
"self",
")",
":",
"with",
"Given",
"(",
"\"I create a view\"",
")",
":",
"sql",
"=",
"\"\"\"\n CREATE VIEW v_window AS\n SELECT number, sum(number) over (order by number rows between 1 preceding and 1 following) as sum_rows\n FROM numbers(1, 10... | [
355,
0
] | [
384,
5
] | python | en | ['en', 'en', 'en'] | True |
feature | (self) | Check misc cases for frame clause.
| Check misc cases for frame clause.
| def feature(self):
"""Check misc cases for frame clause.
"""
for scenario in loads(current_module(), Scenario):
Scenario(run=scenario, flags=TE) | [
"def",
"feature",
"(",
"self",
")",
":",
"for",
"scenario",
"in",
"loads",
"(",
"current_module",
"(",
")",
",",
"Scenario",
")",
":",
"Scenario",
"(",
"run",
"=",
"scenario",
",",
"flags",
"=",
"TE",
")"
] | [
391,
0
] | [
395,
40
] | python | en | ['en', 'en', 'en'] | True |
feature | (self) | Check functions with Int128, Int256, UInt256, and Decimal256.
| Check functions with Int128, Int256, UInt256, and Decimal256.
| def feature(self):
"""Check functions with Int128, Int256, UInt256, and Decimal256.
"""
Feature(run=load("extended_precision_data_types.tests.conversion", "feature"))
Feature(run=load("extended_precision_data_types.tests.arithmetic", "feature"))
Feature(run=load("extended_precision_data_types.tests.... | [
"def",
"feature",
"(",
"self",
")",
":",
"Feature",
"(",
"run",
"=",
"load",
"(",
"\"extended_precision_data_types.tests.conversion\"",
",",
"\"feature\"",
")",
")",
"Feature",
"(",
"run",
"=",
"load",
"(",
"\"extended_precision_data_types.tests.arithmetic\"",
",",
... | [
6,
0
] | [
18,
77
] | python | en | ['en', 'en', 'en'] | True |
privilege_granted_directly_or_via_role | (self, node=None) | Check that user is only able to execute CREATE DATABASE when they have required privilege, either directly or via role.
| Check that user is only able to execute CREATE DATABASE when they have required privilege, either directly or via role.
| def privilege_granted_directly_or_via_role(self, node=None):
"""Check that user is only able to execute CREATE DATABASE when they have required privilege, either directly or via role.
"""
role_name = f"role_{getuid()}"
user_name = f"user_{getuid()}"
if node is None:
node = self.context.node... | [
"def",
"privilege_granted_directly_or_via_role",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"role_name",
"=",
"f\"role_{getuid()}\"",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node... | [
5,
0
] | [
27,
92
] | python | en | ['en', 'en', 'en'] | True |
privilege_check | (grant_target_name, user_name, node=None) | Run scenarios to check the user's access with different privileges.
| Run scenarios to check the user's access with different privileges.
| def privilege_check(grant_target_name, user_name, node=None):
"""Run scenarios to check the user's access with different privileges.
"""
exitcode, message = errors.not_enough_privileges(name=f"{user_name}")
with Scenario("user without privilege"):
db_name = f"db_{getuid()}"
try:
... | [
"def",
"privilege_check",
"(",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"f\"{user_name}\"",
")",
"with",
"Scenario",
"(",
"\"user without... | [
29,
0
] | [
114,
64
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1", stress=None, parallel=None) | Check the RBAC functionality of CREATE DATABASE.
| Check the RBAC functionality of CREATE DATABASE.
| def feature(self, node="clickhouse1", stress=None, parallel=None):
"""Check the RBAC functionality of CREATE DATABASE.
"""
self.context.node = self.context.cluster.node(node)
if parallel is not None:
self.context.parallel = parallel
if stress is not None:
self.context.stress = stres... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
",",
"stress",
"=",
"None",
",",
"parallel",
"=",
"None",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
... | [
123,
0
] | [
134,
48
] | python | en | ['en', 'en', 'en'] | True |
ParseNolintSuppressions | (filename, raw_line, linenum, error) | Updates the global list of line error-suppressions.
Parses any NOLINT comments on the current line, updating the global
error_suppressions store. Reports an error if the NOLINT comment
was malformed.
Args:
filename: str, the name of the input file.
raw_line: str, the line of input text, with comments... | Updates the global list of line error-suppressions. | def ParseNolintSuppressions(filename, raw_line, linenum, error):
"""Updates the global list of line error-suppressions.
Parses any NOLINT comments on the current line, updating the global
error_suppressions store. Reports an error if the NOLINT comment
was malformed.
Args:
filename: str, the name of th... | [
"def",
"ParseNolintSuppressions",
"(",
"filename",
",",
"raw_line",
",",
"linenum",
",",
"error",
")",
":",
"matched",
"=",
"Search",
"(",
"r'\\bNOLINT(NEXTLINE)?\\b(\\([^)]+\\))?'",
",",
"raw_line",
")",
"if",
"matched",
":",
"if",
"matched",
".",
"group",
"(",... | [
682,
0
] | [
711,
63
] | python | en | ['en', 'en', 'en'] | True |
ProcessGlobalSuppresions | (lines) | Updates the list of global error suppressions.
Parses any lint directives in the file that have global effect.
Args:
lines: An array of strings, each representing a line of the file, with the
last element being empty if the file is terminated with a newline.
| Updates the list of global error suppressions. | def ProcessGlobalSuppresions(lines):
"""Updates the list of global error suppressions.
Parses any lint directives in the file that have global effect.
Args:
lines: An array of strings, each representing a line of the file, with the
last element being empty if the file is terminated with a newline... | [
"def",
"ProcessGlobalSuppresions",
"(",
"lines",
")",
":",
"for",
"line",
"in",
"lines",
":",
"if",
"_SEARCH_C_FILE",
".",
"search",
"(",
"line",
")",
":",
"for",
"category",
"in",
"_DEFAULT_C_SUPPRESSED_CATEGORIES",
":",
"_global_error_suppressions",
"[",
"catego... | [
714,
0
] | [
729,
51
] | python | en | ['en', 'en', 'en'] | True |
ResetNolintSuppressions | () | Resets the set of NOLINT suppressions to empty. | Resets the set of NOLINT suppressions to empty. | def ResetNolintSuppressions():
"""Resets the set of NOLINT suppressions to empty."""
_error_suppressions.clear()
_global_error_suppressions.clear() | [
"def",
"ResetNolintSuppressions",
"(",
")",
":",
"_error_suppressions",
".",
"clear",
"(",
")",
"_global_error_suppressions",
".",
"clear",
"(",
")"
] | [
732,
0
] | [
735,
36
] | python | en | ['en', 'en', 'en'] | True |
IsErrorSuppressedByNolint | (category, linenum) | Returns true if the specified error category is suppressed on this line.
Consults the global error_suppressions map populated by
ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions.
Args:
category: str, the category of the error.
linenum: int, the current line number.
Returns:
... | Returns true if the specified error category is suppressed on this line. | def IsErrorSuppressedByNolint(category, linenum):
"""Returns true if the specified error category is suppressed on this line.
Consults the global error_suppressions map populated by
ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions.
Args:
category: str, the category of the error.
... | [
"def",
"IsErrorSuppressedByNolint",
"(",
"category",
",",
"linenum",
")",
":",
"return",
"(",
"_global_error_suppressions",
".",
"get",
"(",
"category",
",",
"False",
")",
"or",
"linenum",
"in",
"_error_suppressions",
".",
"get",
"(",
"category",
",",
"set",
"... | [
738,
0
] | [
753,
58
] | python | en | ['en', 'en', 'en'] | True |
Match | (pattern, s) | Matches the string with the pattern, caching the compiled regexp. | Matches the string with the pattern, caching the compiled regexp. | def Match(pattern, s):
"""Matches the string with the pattern, caching the compiled regexp."""
# The regexp compilation caching is inlined in both Match and Search for
# performance reasons; factoring it out into a separate function turns out
# to be noticeably expensive.
if pattern not in _regexp_compile_cac... | [
"def",
"Match",
"(",
"pattern",
",",
"s",
")",
":",
"# The regexp compilation caching is inlined in both Match and Search for",
"# performance reasons; factoring it out into a separate function turns out",
"# to be noticeably expensive.",
"if",
"pattern",
"not",
"in",
"_regexp_compile_... | [
756,
0
] | [
763,
48
] | 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.