@@ -0,0 +1,2746 @@
+%22%22%22 addons.xml generator %22%22%22%0A%0Aimport os, md5%0A%0Aclass Generator:%0A    %22%22%22%0A        Generates a new addons.xml file from each addons addon.xml file.%0A        Must be run from the root of the checked-out repo. Only handles%0A        single depth folder structure.%0A    %22%22%22%0A    def __init__( self ):%0A        # generate file%0A        self._generate_addons_file()%0A        self._generate_md5_file()%0A        %0A    def _generate_addons_file( self ):%0A        # addon list%0A        addons = os.listdir( %22.%22 )%0A        # final addons text%0A        addons_xml = u%22%3C?xml version=%5C%221.0%5C%22 encoding=%5C%22UTF-8%5C%22?%3E%5Cn%3Caddons%3E%5Cn%22%0A        # loop thru and add each addons addon.xml file%0A        for addon in addons:%0A            try:%0A                # skip any file or .svn folder%0A                if ( not os.path.isdir( addon ) or addon == %22.svn%22 ): continue%0A                # create path%0A                _path = os.path.join( addon, %22addon.xml%22 )%0A                # split lines for stripping%0A                xml_lines = open( _path, %22r%22 ).read().splitlines()%0A                # new addon%0A                addon_xml = %22%22%0A                # loop thru cleaning each line%0A                for line in xml_lines:%0A                    # skip encoding format line%0A                    if ( line.find( %22%3C?xml%22 ) %3E= 0 ): continue%0A                    # add line%0A                    addon_xml += unicode( line.rstrip() + %22%5Cn%22, %22utf-8%22 )%0A                # we succeeded so add to our final addons.xml text%0A                addons_xml += addon_xml.rstrip() + %22%5Cn%5Cn%22%0A            except Exception, e:%0A                # missing or poorly formatted addon.xml%0A                print %22Excluding %25s for %25s%22 %25 ( _path, e, )%0A        # clean and add closing tag%0A        addons_xml = addons_xml.strip() + u%22%5Cn%3C/addons%3E%5Cn%22%0A        # save file%0A        self._save_addons_file( addons_xml )%0A%0A    def _save_addons_file( self, addons_xml ):%0A        try:%0A            # write the bytestring to the file%0A            open( %22addons.xml%22, %22w%22 ).write( addons_xml.encode( %22utf-8%22 ) )%0A        except Exception, e:%0A            # oops%0A            print %22An error occurred saving file%5Cn%25s%22 %25 ( e, )%0A%0A    def _generate_md5_file( self ):%0A        try:%0A            # create a new md5 object%0A            m = md5.new()%0A        except Exception, e:%0A            print %22An error occurred creating md5 object%5Cn%25s%22 %25 (e, )%0A        else:%0A            try:%0A                # update the md5 object with the contents of addons.xml%0A                m.update(open( %22addons.xml%22).read())%0A                # write md5 file%0A                open( %22addons.xml.md5%22, %22w%22 ).write( m.hexdigest() )%0A            except Exception, e:%0A                print %22An error occured saving md5 file%5Cn%25s%22 %25 ( e, )%0A%0Aif ( __name__ == %22__main__%22 ):%0A    # start%0A    Generator()%0A

Create addons_xml_generator.py