code
stringlengths
17
6.64M
def lenet(batch_size): n = caffe.NetSpec() (n.data, n.label) = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]), dict(dim=[batch_size, 1, 1, 1])], transform_param=dict(scale=(1.0 / 255)), ntop=2) n.conv1 = L.Convolution(n.data, kernel_size=5, num_output=20, weight_filler=dict(type='xavier')) n.poo...
def anon_lenet(batch_size): (data, label) = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]), dict(dim=[batch_size, 1, 1, 1])], transform_param=dict(scale=(1.0 / 255)), ntop=2) conv1 = L.Convolution(data, kernel_size=5, num_output=20, weight_filler=dict(type='xavier')) pool1 = L.Pooling(conv1, kernel_...
def silent_net(): n = caffe.NetSpec() (n.data, n.data2) = L.DummyData(shape=[dict(dim=[3]), dict(dim=[4, 2])], ntop=2) n.silence_data = L.Silence(n.data, ntop=0) n.silence_data2 = L.Silence(n.data2, ntop=0) return n.to_proto()
class TestNetSpec(unittest.TestCase): def load_net(self, net_proto): f = tempfile.NamedTemporaryFile(mode='w+', delete=False) f.write(str(net_proto)) f.close() return caffe.Net(f.name, caffe.TEST) def test_lenet(self): 'Construct and build the Caffe version of LeNet.'...
class SimpleLayer(caffe.Layer): 'A layer that just multiplies by ten' def setup(self, bottom, top): pass def reshape(self, bottom, top): top[0].reshape(*bottom[0].data.shape) def forward(self, bottom, top): top[0].data[...] = (10 * bottom[0].data) def backward(self, top...
class ExceptionLayer(caffe.Layer): 'A layer for checking exceptions from Python' def setup(self, bottom, top): raise RuntimeError
class ParameterLayer(caffe.Layer): 'A layer that just multiplies by ten' def setup(self, bottom, top): self.blobs.add_blob(1) self.blobs[0].data[0] = 0 def reshape(self, bottom, top): top[0].reshape(*bottom[0].data.shape) def forward(self, bottom, top): pass def...
def python_net_file(): with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: f.write("name: 'pythonnet' force_backward: true\n input: 'data' input_shape { dim: 10 dim: 9 dim: 8 }\n layer { type: 'Python' name: 'one' bottom: 'data' top: 'one'\n python_param { module: 'test_...
def exception_net_file(): with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: f.write("name: 'pythonnet' force_backward: true\n input: 'data' input_shape { dim: 10 dim: 9 dim: 8 }\n layer { type: 'Python' name: 'layer' bottom: 'data' top: 'top'\n python_param { module: '...
def parameter_net_file(): with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: f.write("name: 'pythonnet' force_backward: true\n input: 'data' input_shape { dim: 10 dim: 9 dim: 8 }\n layer { type: 'Python' name: 'layer' bottom: 'data' top: 'top'\n python_param { module: '...
class TestPythonLayer(unittest.TestCase): def setUp(self): net_file = python_net_file() self.net = caffe.Net(net_file, caffe.TRAIN) os.remove(net_file) def test_forward(self): x = 8 self.net.blobs['data'].data[...] = x self.net.forward() for y in self....
class SimpleParamLayer(caffe.Layer): 'A layer that just multiplies by the numeric value of its param string' def setup(self, bottom, top): try: self.value = float(self.param_str) except ValueError: raise ValueError('Parameter string must be a legible float') def r...
def python_param_net_file(): with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: f.write("name: 'pythonnet' force_backward: true\n input: 'data' input_shape { dim: 10 dim: 9 dim: 8 }\n layer { type: 'Python' name: 'mul10' bottom: 'data' top: 'mul10'\n python_param { modu...
class TestLayerWithParam(unittest.TestCase): def setUp(self): net_file = python_param_net_file() self.net = caffe.Net(net_file, caffe.TRAIN) os.remove(net_file) def test_forward(self): x = 8 self.net.blobs['data'].data[...] = x self.net.forward() for y...
class TestSolver(unittest.TestCase): def setUp(self): self.num_output = 13 net_f = simple_net_file(self.num_output) f = tempfile.NamedTemporaryFile(mode='w+', delete=False) f.write((("net: '" + net_f) + "'\n test_iter: 10 test_interval: 10 base_lr: 0.01 momentum: 0.9\n ...
def main(argv): pycaffe_dir = os.path.dirname(__file__) parser = argparse.ArgumentParser() parser.add_argument('input_file', help='Input image, directory, or npy.') parser.add_argument('output_file', help='Output npy filename.') parser.add_argument('--model_def', default=os.path.join(pycaffe_dir, ...
def main(argv): pycaffe_dir = os.path.dirname(__file__) parser = argparse.ArgumentParser() parser.add_argument('input_file', help="Input txt/csv filename. If .txt, must be list of filenames. If .csv, must be comma-separated file with header 'filename, xmin, ymin, xmax, ymax'") parser.add...
def parse_args(): 'Parse input arguments\n ' parser = ArgumentParser(description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument('input_net_proto_file', help='Input network prototxt file') parser.add_argument('output_image_file', help='Output image file') parser.add_...
def main(): args = parse_args() net = caffe_pb2.NetParameter() text_format.Merge(open(args.input_net_proto_file).read(), net) print(('Drawing net to %s' % args.output_image_file)) caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)
def ParseNolintSuppressions(filename, raw_line, linenum, error): 'Updates the global list of error-suppressions.\n\n Parses any NOLINT comments on the current line, updating the global\n error_suppressions store. Reports an error if the NOLINT comment\n was malformed.\n\n Args:\n filename: str, the name o...
def ResetNolintSuppressions(): 'Resets the set of NOLINT suppressions to empty.' _error_suppressions.clear()
def IsErrorSuppressedByNolint(category, linenum): 'Returns true if the specified error category is suppressed on this line.\n\n Consults the global error_suppressions map populated by\n ParseNolintSuppressions/ResetNolintSuppressions.\n\n Args:\n category: str, the category of the error.\n linenum: int, ...
def Match(pattern, s): 'Matches the string with 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].match(s)
def ReplaceAll(pattern, rep, s): 'Replaces instances of pattern in a string with a replacement.\n\n The compiled regex is kept in a cache shared by Match and Search.\n\n Args:\n pattern: regex pattern\n rep: replacement text\n s: search string\n\n Returns:\n string with replacements made (or origin...
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)
class _IncludeState(dict): 'Tracks line numbers for includes, and the order in which includes appear.\n\n As a dict, an _IncludeState object serves as a mapping between include\n filename and line number on which that file was included.\n\n Call CheckNextIncludeOrder() once for each header in the file, passing...
class _CppLintState(object): 'Maintains module-wide state..' def __init__(self): self.verbose_level = 1 self.error_count = 0 self.filters = _DEFAULT_FILTERS[:] self.counting = 'total' self.errors_by_category = {} self.output_format = 'emacs' def SetOutputF...
def _OutputFormat(): "Gets the module's output format." return _cpplint_state.output_format
def _SetOutputFormat(output_format): "Sets the module's output format." _cpplint_state.SetOutputFormat(output_format)
def _VerboseLevel(): "Returns the module's verbosity setting." return _cpplint_state.verbose_level
def _SetVerboseLevel(level): "Sets the module's verbosity, and returns the previous setting." return _cpplint_state.SetVerboseLevel(level)
def _SetCountingStyle(level): "Sets the module's counting options." _cpplint_state.SetCountingStyle(level)
def _Filters(): "Returns the module's list of output filters, as a list." return _cpplint_state.filters
def _SetFilters(filters): 'Sets the module\'s error-message filters.\n\n These filters are applied when deciding whether to emit a given\n error message.\n\n Args:\n filters: A string of comma-separated filters (eg "whitespace/indent").\n Each filter should start with + or -; else we die.\n ' ...
class _FunctionState(object): 'Tracks current function name and the number of lines in its body.' _NORMAL_TRIGGER = 250 _TEST_TRIGGER = 400 def __init__(self): self.in_a_function = False self.lines_in_function = 0 self.current_function = '' def Begin(self, function_name):...
class _IncludeError(Exception): 'Indicates a problem with the include order in a file.' pass
class FileInfo(): "Provides utility functions for filenames.\n\n FileInfo provides easy access to the components of a file's path\n relative to the project root.\n " def __init__(self, filename): self._filename = filename def FullName(self): 'Make Windows paths like Unix.' ret...
def _ShouldPrintError(category, confidence, linenum): 'If confidence >= verbose, category passes filter and is not suppressed.' if IsErrorSuppressedByNolint(category, linenum): return False if (confidence < _cpplint_state.verbose_level): return False is_filtered = False for one_fil...
def Error(filename, linenum, category, confidence, message): 'Logs the fact we\'ve found a lint error.\n\n We log where the error was found, and also our confidence in the error,\n that is, how certain we are this is a legitimate style regression, and\n not a misidentification or a use that\'s sometimes justif...
def IsCppString(line): "Does line terminate so, that the next symbol is in string constant.\n\n This function does not consider single-line nor multi-line comments.\n\n Args:\n line: is a partial line of code starting from the 0..n.\n\n Returns:\n True, if next character appended to 'line' is inside a\n ...
def CleanseRawStrings(raw_lines): 'Removes C++11 raw strings from lines.\n\n Before:\n static const char kData[] = R"(\n multi-line string\n )";\n\n After:\n static const char kData[] = ""\n (replaced by blank line)\n "";\n\n Args:\n raw_lines: list of raw l...
def FindNextMultiLineCommentStart(lines, lineix): 'Find the beginning marker for a multiline comment.' while (lineix < len(lines)): if lines[lineix].strip().startswith('/*'): if (lines[lineix].strip().find('*/', 2) < 0): return lineix lineix += 1 return len(line...
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 RemoveMultiLineCommentsFromRange(lines, begin, end): 'Clears a range of lines for multi-line comments.' for i in range(begin, end): lines[i] = '// dummy'
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 = FindNextMulti...
def CleanseComments(line): 'Removes //-comments and single-line C-style /* */ comments.\n\n Args:\n line: A line of C++ source.\n\n Returns:\n The line with single-line comments removed.\n ' commentpos = line.find('//') if ((commentpos != (- 1)) and (not IsCppString(line[:commentpos]))): ...
class CleansedLines(object): "Holds 3 copies of all lines with different preprocessing applied to them.\n\n 1) elided member contains lines without strings and comments,\n 2) lines member contains lines without comments, and\n 3) raw_lines member contains all the lines without processing.\n All these three me...
def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar): 'Find the position just after the matching endchar.\n\n Args:\n line: a CleansedLines line.\n startpos: start searching at this position.\n depth: nesting level at startpos.\n startchar: expression opening character.\n endch...
def CloseExpression(clean_lines, linenum, pos): "If input points to ( or { or [ or <, finds the position that closes it.\n\n If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the\n linenum/pos that correspond to the closing of the expression.\n\n Args:\n clean_lines: A CleansedLines instanc...
def FindStartOfExpressionInLine(line, endpos, depth, startchar, endchar): 'Find position at the matching startchar.\n\n This is almost the reverse of FindEndOfExpressionInLine, but note\n that the input position and returned position differs by 1.\n\n Args:\n line: a CleansedLines line.\n endpos: start s...
def ReverseCloseExpression(clean_lines, linenum, pos): "If input points to ) or } or ] or >, finds the position that opens it.\n\n If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the\n linenum/pos that correspond to the opening of the expression.\n\n Args:\n clean_lines: A CleansedLines i...
def CheckForCopyright(filename, lines, error): 'Logs an error if a Copyright message appears at the top of the file.' for line in xrange(1, min(len(lines), 11)): if _RE_COPYRIGHT.search(lines[line], re.I): error(filename, 0, 'legal/copyright', 5, 'Copyright message found. You should not i...
def GetHeaderGuardCPPVariable(filename): 'Returns the CPP variable that should be used as a header guard.\n\n Args:\n filename: The name of a C++ header file.\n\n Returns:\n The CPP variable that should be used as a header guard in the\n named file.\n\n ' filename = re.sub('_flymake\\.h$', '.h', f...
def CheckForHeaderGuard(filename, lines, error): 'Checks that the file contains a header guard.\n\n Logs an error if no #ifndef header guard is present. For other\n headers, checks that the full pathname is used.\n\n Args:\n filename: The name of the C++ header file.\n lines: An array of strings, each r...
def CheckForBadCharacters(filename, lines, error): "Logs an error for each line containing bad characters.\n\n Two kinds of bad characters:\n\n 1. Unicode replacement characters: These indicate that either the file\n contained invalid UTF-8 (likely) or Unicode replacement characters (which\n it shouldn't). N...
def CheckForNewlineAtEOF(filename, lines, error): 'Logs an error if there is no newline char at the end of the file.\n\n Args:\n filename: The name of the current file.\n lines: An array of strings, each representing a line of the file.\n error: The function to call with any errors found.\n ' if ((...
def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): 'Logs an error if we see /* ... */ or "..." that extend past one line.\n\n /* ... */ comments are legit inside macros, for one line.\n Otherwise, we prefer // comments, so it\'s ok to warn about the\n other. Likewise, it\'s ok for...
def CheckCaffeAlternatives(filename, clean_lines, linenum, error): 'Checks for C(++) functions for which a Caffe substitute should be used.\n\n For certain native C functions (memset, memcpy), there is a Caffe alternative\n which should be used instead.\n\n Args:\n filename: The name of the current file.\n ...
def CheckCaffeDataLayerSetUp(filename, clean_lines, linenum, error): 'Except the base classes, Caffe DataLayer should define DataLayerSetUp\n instead of LayerSetUp.\n \n The base DataLayers define common SetUp steps, the subclasses should\n not override them.\n \n Args:\n filename: The name of the ...
def CheckCaffeRandom(filename, clean_lines, linenum, error): 'Checks for calls to C random functions (rand, rand_r, random, ...).\n\n Caffe code should (almost) always use the caffe_rng_* functions rather\n than these, as the internal state of these C functions is independent of the\n native Caffe RNG system w...
def CheckPosixThreading(filename, clean_lines, linenum, error): 'Checks for calls to thread-unsafe functions.\n\n Much code has been originally written without consideration of\n multi-threading. Also, engineers are relying on their old experience;\n they have learned posix before threading extensions were add...
def CheckVlogArguments(filename, clean_lines, linenum, error): 'Checks that VLOG() is only used for defining a logging level.\n\n For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and\n VLOG(FATAL) are not.\n\n Args:\n filename: The name of the current file.\n clean_lines: A Cleans...
def CheckInvalidIncrement(filename, clean_lines, linenum, error): 'Checks for invalid increment *count++.\n\n For example following function:\n void increment_counter(int* count) {\n *count++;\n }\n is invalid, because it effectively does count++, moving pointer, and should\n be replaced with ++*count, (*...
class _BlockInfo(object): 'Stores information about a generic block of code.' def __init__(self, seen_open_brace): self.seen_open_brace = seen_open_brace self.open_parentheses = 0 self.inline_asm = _NO_ASM def CheckBegin(self, filename, clean_lines, linenum, error): 'Run ...
class _ClassInfo(_BlockInfo): 'Stores information about a class.' def __init__(self, name, class_or_struct, clean_lines, linenum): _BlockInfo.__init__(self, False) self.name = name self.starting_linenum = linenum self.is_derived = False if (class_or_struct == 'struct')...
class _NamespaceInfo(_BlockInfo): 'Stores information about a namespace.' def __init__(self, name, linenum): _BlockInfo.__init__(self, False) self.name = (name or '') self.starting_linenum = linenum def CheckEnd(self, filename, clean_lines, linenum, error): 'Check end of ...
class _PreprocessorInfo(object): 'Stores checkpoints of nesting stacks when #if/#else is seen.' def __init__(self, stack_before_if): self.stack_before_if = stack_before_if self.stack_before_else = [] self.seen_else = False
class _NestingState(object): 'Holds states related to parsing braces.' def __init__(self): self.stack = [] self.pp_stack = [] def SeenOpenBrace(self): 'Check if we have seen the opening brace for the innermost block.\n\n Returns:\n True if we have seen the opening brace, ...
def CheckForNonStandardConstructs(filename, clean_lines, linenum, nesting_state, error): 'Logs an error if we see certain non-ANSI constructs ignored by gcc-2.\n\n Complain about several constructs which gcc-2 accepts, but which are\n not standard C++. Warning about these in lint is one way to ease the\n tran...
def CheckSpacingForFunctionCall(filename, line, linenum, error): 'Checks for the correctness of various spacing around function calls.\n\n Args:\n filename: The name of the current file.\n line: The text of the line to check.\n linenum: The number of the line to check.\n error: The function to call w...
def IsBlankLine(line): 'Returns true if the given line is blank.\n\n We consider a line to be blank if the line is empty or consists of\n only white spaces.\n\n Args:\n line: A line of a string.\n\n Returns:\n True, if the given line is blank.\n ' return ((not line) or line.isspace())
def CheckForFunctionLengths(filename, clean_lines, linenum, function_state, error): 'Reports for long function bodies.\n\n For an overview why this is done, see:\n http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions\n\n Uses a simplistic algorithm assuming other style guideline...
def CheckComment(comment, filename, linenum, error): 'Checks for common mistakes in TODO comments.\n\n Args:\n comment: The text of the comment from the line in question.\n filename: The name of the current file.\n linenum: The number of the line to check.\n error: The function to call with any error...
def CheckAccess(filename, clean_lines, linenum, nesting_state, error): 'Checks for improper use of DISALLOW* macros.\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLines instance containing the file.\n linenum: The number of the line to check.\n nesting_state: A _Nesting...
def FindNextMatchingAngleBracket(clean_lines, linenum, init_suffix): 'Find the corresponding > to close a template.\n\n Args:\n clean_lines: A CleansedLines instance containing the file.\n linenum: Current line number.\n init_suffix: Remainder of the current line after the initial <.\n\n Returns:\n ...
def FindPreviousMatchingAngleBracket(clean_lines, linenum, init_prefix): 'Find the corresponding < that started a template.\n\n Args:\n clean_lines: A CleansedLines instance containing the file.\n linenum: Current line number.\n init_prefix: Part of the current line before the initial >.\n\n Returns:\n...
def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): "Checks for the correctness of various spacing issues in the code.\n\n Things we check for: spaces around operators, spaces after\n if/for/while/switch, no spaces around parens in function calls, two\n spaces between code and comment, don'...
def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): 'Checks for additional blank line issues related to sections.\n\n Currently the only thing checked here is blank line before protected/private.\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLines ins...
def GetPreviousNonBlankLine(clean_lines, linenum): 'Return the most recent non-blank line and its line number.\n\n Args:\n clean_lines: A CleansedLines instance containing the file contents.\n linenum: The number of the line to check.\n\n Returns:\n A tuple with two elements. The first element is the ...
def CheckBraces(filename, clean_lines, linenum, error): 'Looks for misplaced braces (e.g. at the end of line).\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLines instance containing the file.\n linenum: The number of the line to check.\n error: The function to call wit...
def CheckEmptyBlockBody(filename, clean_lines, linenum, error): 'Look for empty loop/conditional body with only a single semicolon.\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLines instance containing the file.\n linenum: The number of the line to check.\n error: The...
def CheckCheck(filename, clean_lines, linenum, error): 'Checks the use of CHECK and EXPECT macros.\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLines instance containing the file.\n linenum: The number of the line to check.\n error: The function to call with any errors...
def CheckAltTokens(filename, clean_lines, linenum, error): 'Check alternative keywords being used in boolean expressions.\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLines instance containing the file.\n linenum: The number of the line to check.\n error: The function ...
def GetLineWidth(line): 'Determines the width of the line in column positions.\n\n Args:\n line: A string, which may be a Unicode string.\n\n Returns:\n The width of the line in column positions, accounting for Unicode\n combining characters and wide characters.\n ' if isinstance(line, unicode): ...
def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, error): "Checks rules from the 'C++ style rules' section of cppguide.html.\n\n Most of these rules are hard to test (naming, comment style), but we\n do what we can. In particular we check for 2-space indents, line lengths,\n tab us...
def _DropCommonSuffixes(filename): "Drops common suffixes like _test.cc or -inl.h from filename.\n\n For example:\n >>> _DropCommonSuffixes('foo/foo-inl.h')\n 'foo/foo'\n >>> _DropCommonSuffixes('foo/bar/foo.cc')\n 'foo/bar/foo'\n >>> _DropCommonSuffixes('foo/foo_internal.h')\n 'foo/foo'\n >...
def _IsTestFilename(filename): "Determines if the given filename has a suffix that identifies it as a test.\n\n Args:\n filename: The input filename.\n\n Returns:\n True if 'filename' looks like a test, False otherwise.\n " if (filename.endswith('_test.cc') or filename.endswith('_unittest.cc') or fil...
def _ClassifyInclude(fileinfo, include, is_system): 'Figures out what kind of header \'include\' is.\n\n Args:\n fileinfo: The current file cpplint is running over. A FileInfo instance.\n include: The path to a #included file.\n is_system: True if the #include used <> rather than "".\n\n Returns:\n ...
def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): 'Check rules that are applicable to #include lines.\n\n Strings on #include lines are NOT removed from elided line, to make\n certain tasks easier. However, to prevent false positives, checks\n applicable to #include lines in CheckLang...
def _GetTextInside(text, start_pattern): "Retrieves all the text between matching open and close parentheses.\n\n Given a string of lines and a regular expression string, retrieve all the text\n following the expression and between opening punctuation symbols like\n (, [, or {, and the matching close-punctuati...
def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, nesting_state, error): "Checks rules from the 'C++ language rules' section of cppguide.html.\n\n Some of these rules are hard to test (function overloading, using\n uint32 inappropriately), but we do the best we can.\n\n Args:\n ...
def CheckForNonConstReference(filename, clean_lines, linenum, nesting_state, error): 'Check for non-const references.\n\n Separate from CheckLanguage since it scans backwards from current\n line, instead of scanning forward.\n\n Args:\n filename: The name of the current file.\n clean_lines: A CleansedLin...
def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, error): 'Checks for a C-style cast by looking for the pattern.\n\n Args:\n filename: The name of the current file.\n linenum: The number of the line to check.\n line: The line of code to check.\n raw_line: The raw line of code...
def FilesBelongToSameModule(filename_cc, filename_h): "Check if these two filenames belong to the same module.\n\n The concept of a 'module' here is a as follows:\n foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the\n same 'module' if they are in the same directory.\n some/path/public/xyz...
def UpdateIncludeState(filename, include_state, io=codecs): 'Fill up the include_state with new includes found from the file.\n\n Args:\n filename: the name of the header to read.\n include_state: an _IncludeState instance in which the headers are inserted.\n io: The io factory to use to read the file. ...
def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, io=codecs): 'Reports for missing stl includes.\n\n This function will output warnings to make sure you are including the headers\n necessary for the stl containers and functions that you use. We only give one\n reason to include a heade...
def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): "Check that make_pair's template arguments are deduced.\n\n G++ 4.6 in C++0x mode fails badly if make_pair's template arguments are\n specified explicitly, and such use isn't intended in any case.\n\n Args:\n filename: The name of the cu...
def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions=[]): 'Processes a single line in the file.\n\n Args:\n filename: Filename of the file that is being processed.\n file_extension: The extension (dot not included) of the fi...
def ProcessFileData(filename, file_extension, lines, error, extra_check_functions=[]): 'Performs lint checks and reports any errors to the given error function.\n\n Args:\n filename: Filename of the file that is being processed.\n file_extension: The extension (dot not included) of the file.\n lines: An...
def ProcessFile(filename, vlevel, extra_check_functions=[]): 'Does google-lint on a single file.\n\n Args:\n filename: The name of the file to parse.\n\n vlevel: The level of errors to report. Every error of confidence\n >= verbose_level will be reported. 0 is a good default.\n\n extra_check_functi...