@@ -0,0 +1,1589 @@
+import re%0A%0Aclass Specfile(object):%0A    def __init__(self, specfile):%0A        if not isinstance(specfile, str):%0A            self.specfile = ''.join(specfile)%0A        else:%0A            self.specfile = specfile%0A%0A        self.sections = self.split_sections()%0A    %0A    def split_sections(self):%0A        headers_re = %5Bre.compile(x, re.M) for x in %5Br'%5E%25description',%0A                                                    r'%5E%25package',%0A                                                    r'%5E%25prep',%0A                                                    r'%5E%25build',%0A                                                    r'%5E%25install',%0A                                                    r'%5E%25clean',%0A                                                    r'%5E%25check',%0A                                                    r'%5E%25files',%0A                                                    r'%5E%25changelog'%5D%5D%0A        section_starts = %5B%5D%0A        for header in headers_re:%0A            for match in header.finditer(self.specfile):%0A                section_starts.append(match.start())%0A%0A        section_starts.sort()%0A        sections = %5B('%25header', self.specfile%5B:section_starts%5B0%5D%5D)%5D%0A        for i in range(len(section_starts)):%0A            if len(section_starts) %3E i + 1:%0A                curr_section = self.specfile%5Bsection_starts%5Bi%5D:section_starts%5Bi+1%5D%5D%0A            else:%0A                curr_section = self.specfile%5Bsection_starts%5Bi%5D:%5D%0A            for header in headers_re:%0A                if header.match(curr_section):%0A                    sections.append((header.pattern%5B1:%5D, curr_section))%0A%0A        return sections%0A

Create a specfile class - so that we can easily split sections of specfiles