def parse(self, input): """Parses the given file or file source string.""" if hasattr(input, 'name'): self.filename = input.name elif not getattr(self, 'filename', ''): self.filename = '' if isinstance(input, bytes): input = BytesIO(input) # clear units to get rid of automatically generated headers before parsing self.units = [] poparser.parse_units(poparser.ParseState(input, pounit), self)
def parse(self, input): """Parses the given file or file source string.""" if hasattr(input, "name"): self.filename = input.name elif not getattr(self, "filename", ""): self.filename = "" if not isinstance(input, bytes): input = input.read() lines, self.newline = splitlines(input) # clear units to get rid of automatically generated headers before parsing self.units = [] poparser.parse_units( poparser.ParseState(iter(lines), self.create_unit), self)
def parse(self, input): """Parses the given file or file source string.""" try: if hasattr(input, 'name'): self.filename = input.name elif not getattr(self, 'filename', ''): self.filename = '' if isinstance(input, str): input = cStringIO.StringIO(input) # clear units to get rid of automatically generated headers before parsing self.units = [] poparser.parse_units(poparser.ParseState(input, pounit), self) except Exception, e: raise base.ParseError(e)
def parse(self, input, duplicatestyle="merge"): """Parses the given file or file source string.""" if hasattr(input, 'name'): self.filename = input.name elif not getattr(self, 'filename', ''): self.filename = '' if isinstance(input, bytes): input = BytesIO(input) # clear units to get rid of automatically generated headers before parsing self.units = [] poparser.parse_units(poparser.ParseState(input, pounit), self) # duplicates are now removed by default unless duplicatestyle=allow if duplicatestyle != "allow": self.removeduplicates(duplicatestyle=duplicatestyle)
def parse(self, src): raise DeprecationWarning("Should not be parsing with a unit") return poparser.parse_unit(poparser.ParseState(cStringIO.StringIO(src), pounit), self)
def parse(self, src): return poparser.parse_unit( poparser.ParseState(splitlines(src), pounit), self)
def parse(self, src): return poparser.parse_unit(poparser.ParseState(cStringIO.StringIO(src), pounit), self)
def parse(self, src): return poparser.parse_unit(poparser.ParseState(BytesIO(src), pounit), self)