def handle_inline_comment(self, line, lineno, quotechar=None): if quotechar is None and '!' not in line and \ '"' not in line and "'" not in line: return line, quotechar i = line.find('!') put_item = self.fifo_item.append if quotechar is None and i != -1: # first try a quick method newline = line[:i] if '"' not in newline and '\'' not in newline: if self.isfix77 or not line[i:].startswith('!f2py'): put_item(self.comment_item(line[i:], lineno, lineno)) return newline, quotechar # handle cases where comment char may be a part of a character content #splitter = LineSplitter(line, quotechar) #items = [item for item in splitter] #newquotechar = splitter.quotechar items, newquotechar = splitquote(line, quotechar) noncomment_items = [] noncomment_items_append = noncomment_items.append n = len(items) commentline = None for k in range(n): item = items[k] if isinstance(item, String) or '!' not in item: noncomment_items_append(item) continue j = item.find('!') noncomment_items_append(item[:j]) items[k] = item[j:] commentline = ''.join(items[k:]) break if commentline is not None: if commentline.startswith('!f2py'): # go to next iteration: newline = ''.join(noncomment_items) + commentline[5:] self.f2py_comment_lines.append(lineno) return self.handle_inline_comment(newline, lineno, quotechar) put_item(self.comment_item(commentline, lineno, lineno)) return ''.join(noncomment_items), newquotechar
def handle_inline_comment(self, line, lineno, quotechar=None): if quotechar is None and "!" not in line and '"' not in line and "'" not in line: return line, quotechar i = line.find("!") put_item = self.fifo_item.append if quotechar is None and i != -1: # first try a quick method newline = line[:i] if '"' not in newline and "'" not in newline: if self.isfix77 or not line[i:].startswith("!f2py"): put_item(self.comment_item(line[i:], lineno, lineno)) return newline, quotechar # handle cases where comment char may be a part of a character content # splitter = LineSplitter(line, quotechar) # items = [item for item in splitter] # newquotechar = splitter.quotechar items, newquotechar = splitquote(line, quotechar) noncomment_items = [] noncomment_items_append = noncomment_items.append n = len(items) commentline = None for k in range(n): item = items[k] if isinstance(item, String) or "!" not in item: noncomment_items_append(item) continue j = item.find("!") noncomment_items_append(item[:j]) items[k] = item[j:] commentline = "".join(items[k:]) break if commentline is not None: if commentline.startswith("!f2py"): # go to next iteration: newline = "".join(noncomment_items) + commentline[5:] self.f2py_comment_lines.append(lineno) return self.handle_inline_comment(newline, lineno, quotechar) put_item(self.comment_item(commentline, lineno, lineno)) return "".join(noncomment_items), newquotechar
def handle_inline_comment(self, line, lineno, quotechar=None): """ Parameters ---------- line : str lineno : int quotechar : {None, str} Returns ------- line_with_no_comments : str quotechar : {None, str} had_comment : bool Notes ----- In-line comments are separated from line and put back to fifo sequence where it will be processed as comment line. """ had_comment = False if quotechar is None and '!' not in line and \ '"' not in line and "'" not in line: return line, quotechar, had_comment i = line.find('!') put_item = self.fifo_item.append if quotechar is None and i!=-1: # first try a quick method: newline = line[:i] if '"' not in newline and '\'' not in newline: if self.isf77 or not line[i:].startswith('!f2py'): put_item(self.comment_item(line[i:], lineno, lineno)) return newline, quotechar, True # handle cases where comment char may be a part of a character content #splitter = LineSplitter(line, quotechar) #items = [item for item in splitter] #newquotechar = splitter.quotechar items, newquotechar = splitquote(line, quotechar) noncomment_items = [] noncomment_items_append = noncomment_items.append n = len(items) commentline = None for k in range(n): item = items[k] if isinstance(item, String) or '!' not in item: noncomment_items_append(item) continue j = item.find('!') noncomment_items_append(item[:j]) items[k] = item[j:] commentline = ''.join(items[k:]) break if commentline is not None: if commentline.startswith('!f2py'): # go to next iteration: newline = ''.join(noncomment_items) + commentline[5:] self.f2py_comment_lines.append(lineno) return self.handle_inline_comment(newline, lineno, quotechar) put_item(self.comment_item(commentline, lineno, lineno)) had_comment = True return ''.join(noncomment_items), newquotechar, had_comment
def handle_inline_comment(self, line, lineno, quotechar=None): """ Parameters ---------- line : str lineno : int quotechar : {None, str} Returns ------- line_with_no_comments : str quotechar : {None, str} had_comment : bool Notes ----- In-line comments are separated from line and put back to fifo sequence where it will be processed as comment line. """ had_comment = False if quotechar is None and '!' not in line and \ '"' not in line and "'" not in line: return line, quotechar, had_comment i = line.find('!') put_item = self.fifo_item.append if quotechar is None and i != -1: # first try a quick method: newline = line[:i] if '"' not in newline and '\'' not in newline: if self.isf77 or not line[i:].startswith('!f2py'): put_item(self.comment_item(line[i:], lineno, lineno)) return newline, quotechar, True # handle cases where comment char may be a part of a character content #splitter = LineSplitter(line, quotechar) #items = [item for item in splitter] #newquotechar = splitter.quotechar items, newquotechar = splitquote(line, quotechar) noncomment_items = [] noncomment_items_append = noncomment_items.append n = len(items) commentline = None for k in range(n): item = items[k] if isinstance(item, String) or '!' not in item: noncomment_items_append(item) continue j = item.find('!') noncomment_items_append(item[:j]) items[k] = item[j:] commentline = ''.join(items[k:]) break if commentline is not None: if commentline.startswith('!f2py'): # go to next iteration: newline = ''.join(noncomment_items) + commentline[5:] self.f2py_comment_lines.append(lineno) return self.handle_inline_comment(newline, lineno, quotechar) put_item(self.comment_item(commentline, lineno, lineno)) had_comment = True return ''.join(noncomment_items), newquotechar, had_comment