Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
    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)
Пример #5
0
 def parse(self, src):
     raise DeprecationWarning("Should not be parsing with a unit")
     return poparser.parse_unit(poparser.ParseState(cStringIO.StringIO(src), pounit), self)
Пример #6
0
 def parse(self, src):
     return poparser.parse_unit(
         poparser.ParseState(splitlines(src), pounit), self)
Пример #7
0
 def parse(self, src):
     return poparser.parse_unit(poparser.ParseState(cStringIO.StringIO(src), pounit), self)
Пример #8
0
 def parse(self, src):
     return poparser.parse_unit(poparser.ParseState(BytesIO(src), pounit),
                                self)