Lines Matching refs:self
69 def __init__(self, filename, line, line_no, pos, name): argument
71 self.filename = filename
72 self.line = line
73 self.line_no = line_no
74 self.pos = pos
75 self.name = name
77 def __str__(self): argument
81 gutter = format(self.line_no, "4d")
82 underline = self.pos[0] * " " + (self.pos[1] - self.pos[0]) * "^"
86 " {0} | {1}".format(gutter, self.line) +
98 def __init__(self): argument
99 self.textwrapper = textwrap.TextWrapper()
100 self.textwrapper.width = 80
101 self.textwrapper.initial_indent = " > "
102 self.textwrapper.subsequent_indent = " "
104 def __str__(self): argument
108 if self.__class__.quiet:
109 return self.quiet_output()
110 return self.verbose_output()
113 def quiet_output(self): argument
120 def verbose_output(self): argument
135 def __init__(self, symbol_name): argument
136 self.symbol_name = symbol_name
137 Problem.__init__(self)
139 def quiet_output(self): argument
140 return "{0}".format(self.symbol_name)
142 def verbose_output(self): argument
143 return self.textwrapper.fill(
146 .format(self.symbol_name))
157 def __init__(self, pattern, match): argument
158 self.pattern = pattern
159 self.match = match
160 Problem.__init__(self)
163 def quiet_output(self): argument
166 .format(self.match.filename, self.match.line_no, self.match.name)
169 def verbose_output(self): argument
170 return self.textwrapper.fill(
173 self.match.filename,
174 self.match.line_no,
175 self.match.name,
176 self.pattern
178 ) + "\n" + str(self.match)
189 def __init__(self, match): argument
190 self.match = match
191 Problem.__init__(self)
193 def quiet_output(self): argument
196 .format(self.match.filename, self.match.line_no, self.match.name)
199 def verbose_output(self): argument
200 return self.textwrapper.fill(
204 .format(self.match.filename, self.match.line_no, self.match.name)
205 ) + "\n" + str(self.match)
213 def __init__(self, log): argument
214 self.log = log
218 self.files = {}
222 self.excluded_files = ["*/bn_mul", "*/compat-2.x.h"]
224 def comprehensive_parse(self): argument
231 self.log.info("Parsing source code...")
232 self.log.debug(
234 .format(str(self.excluded_files))
238 all_macros["public"] = self.parse_macros([
244 all_macros["internal"] = self.parse_macros([
248 all_macros["private"] = self.parse_macros([
251 enum_consts = self.parse_enum_consts([
259 identifiers, excluded_identifiers = self.parse_identifiers([
266 mbed_psa_words = self.parse_mbed_psa_words([
276 symbols = self.parse_symbols()
286 self.log.debug("Found:")
289 self.log.debug(" {:4} Total {} Macros"
291 self.log.debug(" {:4} {} Non-identifier Macros"
293 self.log.debug(" {:4} Enum Constants".format(len(enum_consts)))
294 self.log.debug(" {:4} Identifiers".format(len(identifiers)))
295 self.log.debug(" {:4} Exported Symbols".format(len(symbols)))
307 def is_file_excluded(self, path, exclude_wildcards): argument
310 exclude_wildcards = (exclude_wildcards or []) + self.excluded_files
316 def get_all_files(self, include_wildcards, exclude_wildcards): argument
340 if self.is_file_excluded(path, exclude_wildcards):
346 def get_included_files(self, include_wildcards, exclude_wildcards): argument
365 if not self.is_file_excluded(path, exclude_wildcards))
367 def parse_macros(self, include, exclude=None): argument
382 files = self.get_included_files(include, exclude)
383 self.log.debug("Looking for macros in {} files".format(len(files)))
402 def parse_mbed_psa_words(self, include, exclude=None): argument
417 files = self.get_included_files(include, exclude)
418 self.log.debug(
440 def parse_enum_consts(self, include, exclude=None): argument
450 files = self.get_included_files(include, exclude)
451 self.log.debug("Looking for enum consts in {} files".format(len(files)))
502 def strip_comments_and_literals(self, line, in_block_comment): argument
530 line = re.sub(self.IGNORED_CHUNK_REGEX,
568 def parse_identifiers_in_file(self, header_file, identifiers): argument
586 self.strip_comments_and_literals(line, in_block_comment)
588 if self.EXCLUSION_LINES.match(line):
612 identifier = self.IDENTIFIER_REGEX.search(line)
629 def parse_identifiers(self, include, exclude=None): argument
648 self.get_all_files(include, exclude)
650 self.log.debug("Looking for included identifiers in {} files".format \
656 self.parse_identifiers_in_file(header_file, included_identifiers)
658 self.parse_identifiers_in_file(header_file, excluded_identifiers)
662 def parse_symbols(self): argument
672 self.log.info("Compiling...")
707 symbols = self.parse_symbols_from_nm([
719 self.log.debug(error.output)
731 def parse_symbols_from_nm(self, object_files): argument
765 self.log.error(line)
773 def __init__(self, parse_result, log): argument
774 self.parse_result = parse_result
775 self.log = log
777 def perform_checks(self, quiet=False): argument
785 self.log.info("=============")
788 problems += self.check_symbols_declared_in_header()
797 problems += self.check_match_pattern(group, check_pattern)
799 problems += self.check_for_typos()
801 self.log.info("=============")
803 self.log.info("FAIL: {0} problem(s) to fix".format(str(problems)))
805 self.log.info("Remove --quiet to see explanations.")
807 self.log.info("Use --quiet for minimal output.")
810 self.log.info("PASS")
813 def check_symbols_declared_in_header(self): argument
822 all_identifiers = self.parse_result["identifiers"] + \
823 self.parse_result["excluded_identifiers"]
825 for symbol in self.parse_result["symbols"]:
835 self.output_check_result("All symbols in header", problems)
838 def check_match_pattern(self, group_to_check, check_pattern): argument
851 for item_match in self.parse_result[group_to_check]:
859 self.output_check_result(
864 def check_for_typos(self): argument
878 in self.parse_result["public_macros"] +
879 self.parse_result["internal_macros"] +
880 self.parse_result["private_macros"] +
881 self.parse_result["enum_consts"]
887 for name_match in self.parse_result["mbed_psa_words"]:
902 self.output_check_result("Likely typos", problems)
905 def output_check_result(self, name, problems): argument
915 self.log.info("{}: FAIL\n".format(name))
917 self.log.warning(str(problem))
919 self.log.info("{}: PASS".format(name))