_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q253400
OutgoingPacket.send
validation
def send(self, dispatcher): """Sends this outgoing packet to dispatcher's socket""" if self.sent_complete: return
python
{ "resource": "" }
q253401
IncomingPacket.create_packet
validation
def create_packet(header, data): """Creates an IncomingPacket object from header and data This method is for testing purposes """ packet = IncomingPacket() packet.header = header packet.data = data
python
{ "resource": "" }
q253402
IncomingPacket.read
validation
def read(self, dispatcher): """Reads incoming data from asyncore.dispatcher""" try: if not self.is_header_read: # try reading header to_read = HeronProtocol.HEADER_SIZE - len(self.header) self.header += dispatcher.recv(to_read) if len(self.header) == HeronProtocol.HEADER_SI...
python
{ "resource": "" }
q253403
REQID.generate
validation
def generate(): """Generates a random REQID for request""" data_bytes = bytearray(random.getrandbits(8) for i
python
{ "resource": "" }
q253404
yaml_config_reader
validation
def yaml_config_reader(config_path): """Reads yaml config file and returns auto-typed config_dict""" if not config_path.endswith(".yaml"): raise ValueError("Config file
python
{ "resource": "" }
q253405
SingleThreadHeronInstance.send_buffered_messages
validation
def send_buffered_messages(self): """Send messages in out_stream to the Stream Manager""" while not self.out_stream.is_empty() and self._stmgr_client.is_registered: tuple_set = self.out_stream.poll() if isinstance(tuple_set, tuple_pb2.HeronTupleSet):
python
{ "resource": "" }
q253406
SingleThreadHeronInstance._handle_state_change_msg
validation
def _handle_state_change_msg(self, new_helper): """Called when state change is commanded by stream manager""" assert self.my_pplan_helper is not None assert self.my_instance is not None and self.my_instance.py_class is not None if self.my_pplan_helper.get_topology_state() != new_helper.get_topology_sta...
python
{ "resource": "" }
q253407
PhysicalPlanHelper.check_output_schema
validation
def check_output_schema(self, stream_id, tup): """Checks if a given stream_id and tuple matches with the output schema :type stream_id: str :param stream_id: stream id into which tuple is sent :type tup: list :param tup: tuple that is going to be sent """ # do some checking to make sure tha...
python
{ "resource": "" }
q253408
PhysicalPlanHelper.get_topology_config
validation
def get_topology_config(self): """Returns the topology config""" if self.pplan.topology.HasField("topology_config"):
python
{ "resource": "" }
q253409
PhysicalPlanHelper.set_topology_context
validation
def set_topology_context(self, metrics_collector): """Sets a new topology context""" Log.debug("Setting topology context") cluster_config = self.get_topology_config() cluster_config.update(self._get_dict_from_config(self.my_component.config)) task_to_component_map = self._get_task_to_comp_map()
python
{ "resource": "" }
q253410
PhysicalPlanHelper._get_dict_from_config
validation
def _get_dict_from_config(topology_config): """Converts Config protobuf message to python dictionary Values are converted according to the rules below: - Number string (e.g. "12" or "1.2") is appropriately converted to ``int`` or ``float`` - Boolean string ("true", "True", "false" or "False") is conve...
python
{ "resource": "" }
q253411
PhysicalPlanHelper._setup_custom_grouping
validation
def _setup_custom_grouping(self, topology): """Checks whether there are any bolts that consume any of my streams using custom grouping""" for i in range(len(topology.bolts)): for in_stream in topology.bolts[i].inputs: if in_stream.stream.component_name == self.my_component_name and \ in_...
python
{ "resource": "" }
q253412
CustomGroupingHelper.add
validation
def add(self, stream_id, task_ids, grouping, source_comp_name): """Adds the target component :type stream_id: str :param stream_id: stream id into which tuples are emitted :type task_ids: list of str :param task_ids: list of task ids to which tuples are emitted :type grouping: ICustomStreamGrou...
python
{ "resource": "" }
q253413
CustomGroupingHelper.prepare
validation
def prepare(self, context): """Prepares the custom grouping for this component"""
python
{ "resource": "" }
q253414
CustomGroupingHelper.choose_tasks
validation
def choose_tasks(self, stream_id, values): """Choose tasks for a given stream_id and values and Returns a list of target tasks"""
python
{ "resource": "" }
q253415
format_mode
validation
def format_mode(sres): """ Format a line in the directory list based on the file's type and other attributes. """ mode = sres.st_mode root = (mode & 0o700) >> 6 group = (mode & 0o070) >> 3 user = (mode & 0o7) def stat_type(md): ''' stat type''' if stat.S_ISDIR(md): return 'd' elif st...
python
{ "resource": "" }
q253416
format_mtime
validation
def format_mtime(mtime): """ Format the date associated with a file to be displayed in directory listing. """ now = datetime.now() dt = datetime.fromtimestamp(mtime) return '%s %2d %5s' % (
python
{ "resource": "" }
q253417
format_prefix
validation
def format_prefix(filename, sres): """ Prefix to a filename in the directory listing. This is to make the listing similar to an output of "ls -alh". """ try: pwent = pwd.getpwuid(sres.st_uid) user = pwent.pw_name except KeyError: user = sres.st_uid try: grent = grp.getgrgid(sres.st_gid) ...
python
{ "resource": "" }
q253418
read_chunk
validation
def read_chunk(filename, offset=-1, length=-1, escape_data=False): """ Read a chunk of a file from an offset upto the length. """ try: length = int(length) offset = int(offset) except ValueError: return {} if not os.path.isfile(filename): return {} try: fstat = os.stat(filename) ex...
python
{ "resource": "" }
q253419
pipe
validation
def pipe(prev_proc, to_cmd): """ Pipes output of prev_proc into to_cmd. Returns piped process """ stdin = None if prev_proc is None else prev_proc.stdout process =
python
{ "resource": "" }
q253420
str_cmd
validation
def str_cmd(cmd, cwd, env): """ Runs the command and returns its stdout and stderr. """ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, env=env) stdout_builder, stderr_builder = proc.async_stdout_stderr_builder(process)
python
{ "resource": "" }
q253421
chain
validation
def chain(cmd_list): """ Feed output of one command to the next and return final output Returns string output of chained application of commands. """ command = ' | '.join(map(lambda x:
python
{ "resource": "" }
q253422
parse_topo_loc
validation
def parse_topo_loc(cl_args): """ parse topology location """ try: topo_loc = cl_args['cluster/[role]/[env]'].split('/') topo_name = cl_args['topology-name'] topo_loc.append(topo_name) if len(topo_loc) != 4:
python
{ "resource": "" }
q253423
to_table
validation
def to_table(metrics): """ normalize raw metrics API result to table """ all_queries = tracker_access.metric_queries() m = tracker_access.queries_map() names = metrics.values()[0].keys() stats = [] for n in names: info = [n] for field in all_queries: try:
python
{ "resource": "" }
q253424
run_metrics
validation
def run_metrics(command, parser, cl_args, unknown_args): """ run metrics subcommand """ cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ'] topology = cl_args['topology-name'] try: result = tracker_access.get_topology_info(cluster, env, topology, role) spouts = result['physical_...
python
{ "resource": "" }
q253425
run_bolts
validation
def run_bolts(command, parser, cl_args, unknown_args): """ run bolts subcommand """ cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ'] topology = cl_args['topology-name'] try: result = tracker_access.get_topology_info(cluster, env, topology, role) bolts = result['physical_plan'...
python
{ "resource": "" }
q253426
run_containers
validation
def run_containers(command, parser, cl_args, unknown_args): """ run containers subcommand """ cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ'] topology = cl_args['topology-name'] container_id = cl_args['id'] try: result = tracker_access.get_topology_info(cluster, env, topology,...
python
{ "resource": "" }
q253427
BaseBolt.spec
validation
def spec(cls, name=None, inputs=None, par=1, config=None, optional_outputs=None): """Register this bolt to the topology and create ``HeronComponentSpec`` This method takes an optional ``outputs`` argument for supporting dynamic output fields declaration. However, it is recommended that ``outputs`` should b...
python
{ "resource": "" }
q253428
TupleHelper.make_tuple
validation
def make_tuple(stream, tuple_key, values, roots=None): """Creates a HeronTuple :param stream: protobuf message ``StreamId`` :param tuple_key: tuple id :param values: a list of values :param roots: a list of protobuf message ``RootId`` """ component_name = stream.component_name stream_id...
python
{ "resource": "" }
q253429
TupleHelper.make_tick_tuple
validation
def make_tick_tuple(): """Creates a TickTuple""" return HeronTuple(id=TupleHelper.TICK_TUPLE_ID, component=TupleHelper.TICK_SOURCE_COMPONENT,
python
{ "resource": "" }
q253430
TupleHelper.make_root_tuple_info
validation
def make_root_tuple_info(stream_id, tuple_id): """Creates a RootTupleInfo""" key = random.getrandbits(TupleHelper.MAX_SFIXED64_RAND_BITS)
python
{ "resource": "" }
q253431
ParseNolintSuppressions
validation
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...
python
{ "resource": "" }
q253432
ProcessGlobalSuppresions
validation
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...
python
{ "resource": "" }
q253433
IsErrorSuppressedByNolint
validation
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. ...
python
{ "resource": "" }
q253434
Match
validation
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.
python
{ "resource": "" }
q253435
ReplaceAll
validation
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...
python
{ "resource": "" }
q253436
Search
validation
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]
python
{ "resource": "" }
q253437
_ShouldPrintError
validation
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...
python
{ "resource": "" }
q253438
IsCppString
validation
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...
python
{ "resource": "" }
q253439
CleanseRawStrings
validation
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...
python
{ "resource": "" }
q253440
FindNextMultiLineCommentStart
validation
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
python
{ "resource": "" }
q253441
FindNextMultiLineCommentEnd
validation
def FindNextMultiLineCommentEnd(lines, lineix): """We are inside a comment, find the end marker.""" while lineix < len(lines):
python
{ "resource": "" }
q253442
RemoveMultiLineCommentsFromRange
validation
def RemoveMultiLineCommentsFromRange(lines, begin, end): """Clears a range of lines for multi-line comments.""" # Having //
python
{ "resource": "" }
q253443
FindEndOfExpressionInLine
validation
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...
python
{ "resource": "" }
q253444
CloseExpression
validation
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...
python
{ "resource": "" }
q253445
FindStartOfExpressionInLine
validation
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...
python
{ "resource": "" }
q253446
ReverseCloseExpression
validation
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 ...
python
{ "resource": "" }
q253447
CheckForCopyright
validation
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...
python
{ "resource": "" }
q253448
GetIndentLevel
validation
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. """
python
{ "resource": "" }
q253449
GetHeaderGuardCPPVariable
validation
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...
python
{ "resource": "" }
q253450
CheckForHeaderGuard
validation
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...
python
{ "resource": "" }
q253451
CheckHeaderFileIncluded
validation
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...
python
{ "resource": "" }
q253452
CheckForBadCharacters
validation
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...
python
{ "resource": "" }
q253453
CheckForNewlineAtEOF
validation
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 ...
python
{ "resource": "" }
q253454
CheckPosixThreading
validation
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...
python
{ "resource": "" }
q253455
CheckSpacingForFunctionCall
validation
def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error): """Checks for the correctness of various spacing around function calls. 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: T...
python
{ "resource": "" }
q253456
CheckForFunctionLengths
validation
def CheckForFunctionLengths(filename, clean_lines, linenum, function_state, error): """Reports for long function bodies. For an overview why this is done, see: https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions Uses a simplistic algorithm assuming...
python
{ "resource": "" }
q253457
CheckComment
validation
def CheckComment(line, filename, linenum, next_line_start, error): """Checks for common mistakes in comments. Args: line: The line in question. filename: The name of the current file. linenum: The number of the line to check. next_line_start: The first non-whitespace column of the next line. er...
python
{ "resource": "" }
q253458
CheckSpacing
validation
def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): """Checks for the correctness of various spacing issues in the code. Things we check for: spaces around operators, spaces after if/for/while/switch, no spaces around parens in function calls, two spaces between code and comment, don't star...
python
{ "resource": "" }
q253459
CheckParenthesisSpacing
validation
def CheckParenthesisSpacing(filename, clean_lines, linenum, error): """Checks for horizontal spacing around parentheses. 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 wit...
python
{ "resource": "" }
q253460
CheckCommaSpacing
validation
def CheckCommaSpacing(filename, clean_lines, linenum, error): """Checks for horizontal spacing near commas and semicolons. 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 w...
python
{ "resource": "" }
q253461
_IsType
validation
def _IsType(clean_lines, nesting_state, expr): """Check if expression looks like a type name, returns true if so. Args: clean_lines: A CleansedLines instance containing the file. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks b...
python
{ "resource": "" }
q253462
CheckBracesSpacing
validation
def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error): """Checks for horizontal spacing near commas. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingStat...
python
{ "resource": "" }
q253463
CheckSectionSpacing
validation
def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): """Checks for additional blank line issues related to sections. Currently the only thing checked here is blank line before protected/private. Args: filename: The name of the current file. clean_lines: A CleansedLines instance co...
python
{ "resource": "" }
q253464
GetPreviousNonBlankLine
validation
def GetPreviousNonBlankLine(clean_lines, linenum): """Return the most recent non-blank line and its line number. Args: clean_lines: A CleansedLines instance containing the file contents. linenum: The number of the line to check. Returns: A tuple with two elements. The first element is the contents ...
python
{ "resource": "" }
q253465
CheckTrailingSemicolon
validation
def CheckTrailingSemicolon(filename, clean_lines, linenum, error): """Looks for redundant trailing semicolon. 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 error...
python
{ "resource": "" }
q253466
FindCheckMacro
validation
def FindCheckMacro(line): """Find a replaceable CHECK-like macro. Args: line: line to search on. Returns: (macro name, start position), or (None, -1) if no replaceable macro is found. """ for macro in _CHECK_MACROS: i = line.find(macro) if i >= 0: # Find opening parenthesis. Do a r...
python
{ "resource": "" }
q253467
CheckCheck
validation
def CheckCheck(filename, clean_lines, linenum, error): """Checks the use of CHECK and EXPECT macros. 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. ...
python
{ "resource": "" }
q253468
CheckAltTokens
validation
def CheckAltTokens(filename, clean_lines, linenum, error): """Check alternative keywords being used in boolean expressions. 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 ...
python
{ "resource": "" }
q253469
GetLineWidth
validation
def GetLineWidth(line): """Determines the width of the line in column positions. Args: line: A string, which may be a Unicode string. Returns: The width of the line in column positions, accounting for Unicode combining characters and wide characters. """ if isinstance(line, unicode): width =...
python
{ "resource": "" }
q253470
_DropCommonSuffixes
validation
def _DropCommonSuffixes(filename): """Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCom...
python
{ "resource": "" }
q253471
_ClassifyInclude
validation
def _ClassifyInclude(fileinfo, include, is_system): """Figures out what kind of header 'include' is. Args: fileinfo: The current file cpplint is running over. A FileInfo instance. include: The path to a #included file. is_system: True if the #include used <> rather than "". Returns: One of the _...
python
{ "resource": "" }
q253472
_GetTextInside
validation
def _GetTextInside(text, start_pattern): r"""Retrieves all the text between matching open and close parentheses. Given a string of lines and a regular expression string, retrieve all the text following the expression and between opening punctuation symbols like (, [, or {, and the matching close-punctuation sy...
python
{ "resource": "" }
q253473
CheckGlobalStatic
validation
def CheckGlobalStatic(filename, clean_lines, linenum, error): """Check for unsafe global or static objects. 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 ...
python
{ "resource": "" }
q253474
CheckPrintf
validation
def CheckPrintf(filename, clean_lines, linenum, error): """Check for printf related issues. 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. """ l...
python
{ "resource": "" }
q253475
IsDerivedFunction
validation
def IsDerivedFunction(clean_lines, linenum): """Check if current line contains an inherited function. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains a function with "override" virt-specifier. """ ...
python
{ "resource": "" }
q253476
IsOutOfLineMethodDefinition
validation
def IsOutOfLineMethodDefinition(clean_lines, linenum): """Check if current line contains an out-of-line method definition. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains an out-of-line method definition...
python
{ "resource": "" }
q253477
IsInitializerList
validation
def IsInitializerList(clean_lines, linenum): """Check if current line is inside constructor initializer list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line appears to be inside constructor initializer list,...
python
{ "resource": "" }
q253478
CheckForNonConstReference
validation
def CheckForNonConstReference(filename, clean_lines, linenum, nesting_state, error): """Check for non-const references. Separate from CheckLanguage since it scans backwards from current line, instead of scanning forward. Args: filename: The name of the current file. clean...
python
{ "resource": "" }
q253479
CheckCasts
validation
def CheckCasts(filename, clean_lines, linenum, error): """Various cast related checks. 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. """ line =...
python
{ "resource": "" }
q253480
CheckCStyleCast
validation
def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): """Checks for a C-style cast by looking for the pattern. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. cast_type: The ...
python
{ "resource": "" }
q253481
ExpectingFunctionArgs
validation
def ExpectingFunctionArgs(clean_lines, linenum): """Checks whether where function type arguments are expected. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if the line at 'linenum' is inside something that expects arguments ...
python
{ "resource": "" }
q253482
FilesBelongToSameModule
validation
def FilesBelongToSameModule(filename_cc, filename_h): """Check if these two filenames belong to the same module. The concept of a 'module' here is a as follows: foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the same 'module' if they are in the same directory. some/path/public/xyzzy and ...
python
{ "resource": "" }
q253483
UpdateIncludeState
validation
def UpdateIncludeState(filename, include_dict, io=codecs): """Fill up the include_dict with new includes found from the file. Args: filename: the name of the header to read. include_dict: a dictionary in which the headers are inserted. io: The io factory to use to read the file. Provided for testabilit...
python
{ "resource": "" }
q253484
CheckMakePairUsesDeduction
validation
def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): """Check that make_pair's template arguments are deduced. G++ 4.6 in C++11 mode fails badly if make_pair's template arguments are specified explicitly, and such use isn't intended in any case. Args: filename: The name of the current fi...
python
{ "resource": "" }
q253485
CheckRedundantVirtual
validation
def CheckRedundantVirtual(filename, clean_lines, linenum, error): """Check if line contains a redundant "virtual" function-specifier. 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 functio...
python
{ "resource": "" }
q253486
CheckRedundantOverrideOrFinal
validation
def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): """Check if line contains a redundant "override" or "final" virt-specifier. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. er...
python
{ "resource": "" }
q253487
IsBlockInNameSpace
validation
def IsBlockInNameSpace(nesting_state, is_forward_declaration): """Checks that the new block is directly in a namespace. Args: nesting_state: The _NestingState object that contains info about our state. is_forward_declaration: If the class is a forward declared class. Returns: Whether or not the new b...
python
{ "resource": "" }
q253488
ShouldCheckNamespaceIndentation
validation
def ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, raw_lines_no_comments, linenum): """This method determines if we should apply our namespace indentation check. Args: nesting_state: The current nesting state. is_namespace_indent_item: If we jus...
python
{ "resource": "" }
q253489
FlagCxx14Features
validation
def FlagCxx14Features(filename, clean_lines, linenum, error): """Flag those C++14 features that we restrict. 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...
python
{ "resource": "" }
q253490
ProcessFileData
validation
def ProcessFileData(filename, file_extension, lines, error, extra_check_functions=None): """Performs lint checks and reports any errors to the given error function. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file...
python
{ "resource": "" }
q253491
ProcessConfigOverrides
validation
def ProcessConfigOverrides(filename): """ Loads the configuration files and processes the config overrides. Args: filename: The name of the file being processed by the linter. Returns: False if the current |filename| should not be processed further. """ abs_filename = os.path.abspath(filename) cf...
python
{ "resource": "" }
q253492
ProcessFile
validation
def ProcessFile(filename, vlevel, extra_check_functions=None): """Does google-lint on a single file. Args: filename: The name of the file to parse. vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. extra_check_functions: An ...
python
{ "resource": "" }
q253493
PrintCategories
validation
def PrintCategories(): """Prints a list of all the error-categories used by error messages. These are the categories used to filter messages via --filter.
python
{ "resource": "" }
q253494
ParseArguments
validation
def ParseArguments(args): """Parses the command line arguments. This may set the output format and verbosity level as side-effects. Args: args: The command line arguments: Returns: The list of filenames to lint. """ try: (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose...
python
{ "resource": "" }
q253495
_ExpandDirectories
validation
def _ExpandDirectories(filenames): """Searches a list of filenames and replaces directories in the list with all files descending from those directories. Files with extensions not in the valid extensions list are excluded. Args: filenames: A list of files or directories Returns: A list of all files ...
python
{ "resource": "" }
q253496
_IncludeState.FindHeader
validation
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
python
{ "resource": "" }
q253497
_IncludeState.ResetSection
validation
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 = '' ...
python
{ "resource": "" }
q253498
_IncludeState.IsInAlphabeticalOrder
validation
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...
python
{ "resource": "" }
q253499
_IncludeState.CheckNextIncludeOrder
validation
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...
python
{ "resource": "" }