def parseManPage(self, manpage): d = Deroffer() d.deroff(manpage) output = d.get_output() lines = output.split("\n") got_something = False # Discard lines until we get to DESCRIPTION or OPTIONS while lines and not ( lines[0].startswith("DESCRIPTION") or lines[0].startswith("OPTIONS") or lines[0].startswith("COMMAND OPTIONS") ): lines.pop(0) # Look for BUGS and stop there for idx in range(len(lines)): line = lines[idx] if line.startswith("BUGS"): # Drop remaining elements lines[idx:] = [] break while lines: # Pop until we get to the next option while lines and not self.is_option(lines[0]): line = lines.pop(0) if not lines: continue options = lines.pop(0) # Pop until we get to either an empty line or a line starting with - description = "" while lines and self.could_be_description(lines[0]): if description: description += " " description += lines.pop(0) builtcommand(options, description) got_something = True return got_something
def parse_man_page(self, manpage): d = Deroffer() d.deroff(manpage) output = d.get_output() lines = output.split("\n") got_something = False # Discard lines until we get to DESCRIPTION or OPTIONS while lines and not ( lines[0].startswith("DESCRIPTION") or lines[0].startswith("OPTIONS") or lines[0].startswith("COMMAND OPTIONS") ): lines.pop(0) # Look for BUGS and stop there for idx in range(len(lines)): line = lines[idx] if line.startswith("BUGS"): # Drop remaining elements lines[idx:] = [] break while lines: # Pop until we get to the next option while lines and not self.is_option(lines[0]): line = lines.pop(0) if not lines: continue options = lines.pop(0) # Pop until we get to either an empty line or a line starting with - description = "" while lines and self.could_be_description(lines[0]): if description: description += " " description += lines.pop(0) built_command(options, description) got_something = True return got_something