Lines Matching refs:self
24 def __init__(self, single_line_quotes=False, allow_blank_lines=False):
26 self.comment_lines = []
29 self.trailing_empty_lines = []
32 self.output_lines = []
35 self.single_line_quotes = single_line_quotes
38 self.allow_blank_lines = allow_blank_lines
41 self.done_with_initial_comment = False
44 def output_line(self, line=None):
46 self.output_lines.append(line)
48 self.output_lines.append("")
50 def output_normal_line(self, line):
52 self.dump_comment_lines()
53 self.output_line(line)
55 def dump_comment_lines(self):
57 if not self.comment_lines:
60 for line in self.comment_lines:
61 self.output_line(line)
62 self.comment_lines = []
64 for line in self.trailing_empty_lines:
65 self.output_line(line)
66 self.trailing_empty_lines = []
68 def dump_converted_comment_lines(self, indent):
70 if not self.comment_lines:
73 for line in self.trailing_empty_lines:
74 self.output_line(line)
75 self.trailing_empty_lines = []
87 lines = [extract(line) for line in self.comment_lines]
98 if self.single_line_quotes \
110 self.output_line(indent + line)
113 self.output_line()
116 self.comment_lines = []
118 def queue_comment_line(self, line):
119 if self.trailing_empty_lines:
121 self.dump_comment_lines()
122 self.comment_lines.append(line)
124 def handle_empty_line(self, line):
131 if self.comment_lines and self.allow_blank_lines:
132 self.trailing_empty_lines.append(line)
134 self.output_normal_line(line)
136 def is_next_line_doc_comment(self):
137 next_line = self.next_line_rstripped
143 def process_line(self, line_num, line):
150 if self.done_with_initial_comment:
151 self.queue_comment_line(line)
153 self.output_line(line)
156 self.done_with_initial_comment = True
158 self.handle_empty_line(line)
159 elif def_match and not self.is_next_line_doc_comment():
165 self.output_line(line)
166 self.dump_converted_comment_lines(indent)
169 self.output_normal_line(line)
171 def process(self, fn, write=False):
172 self.process_file(fn)
176 for line in self.output_lines:
181 self.__init__(self.single_line_quotes, self.allow_blank_lines)