Exemple #1
0
    def __prepareZones(self):
        last = -1
        while 1:
            # getting where is 'include' directive
            pos = self.contents.find('zone ', last + 1)
            if pos == -1: return None
            # fix
            if pos > 1:
                char = self.contents[pos - 1]
                if char <> '\n' and char <> '\r' and \
                   char <> ' '  and char <> '\t' and \
                   char <> ';':
                    return None
            # marking 'include' position
            last = pos

            # creating a Zone instance
            thisZone = Zone()
            try:
                OneZonePart = self.contents[pos:].split('}')[0]
                # Getting Name
                thisZone.setName(self.__getStr(OneZonePart.split('{')[0]))
                # Getting Filename
                thisZone.setFile(
                    self.__getStr(OneZonePart.split('file')[1].split(';')[0]))
                #Getting type
                if OneZonePart.split('type')[1].split(';')[0].upper().find(
                        'SLAVE') <> -1:
                    thisZone.setType('slave')
                else:
                    thisZone.setType('master')

                self.zones.append(thisZone)
            except:
                pass

            # destroying thisZone instance
            thisZone = None
    def __prepareZones(self):
        last = -1
        while 1:
            # getting where is 'include' directive
            pos = self.contents.find('zone ', last+1)
            if pos == -1: return None
            # fix
            if pos > 1:
                char = self.contents[pos-1]
                if char <> '\n' and char <> '\r' and \
                   char <> ' '  and char <> '\t' and \
                   char <> ';':
                       return None
            # marking 'include' position
            last = pos
            
            # creating a Zone instance
            thisZone = Zone()
            try:
                OneZonePart = self.contents[pos:].split('}')[0]
                # Getting Name
                thisZone.setName( self.__getStr( OneZonePart.split('{')[0] ) )
                # Getting Filename
                thisZone.setFile( self.__getStr( OneZonePart.split('file')[1].split(';')[0] ) )
                #Getting type
                if OneZonePart.split('type')[1].split(';')[0].upper().find('SLAVE') <> -1:
                    thisZone.setType('slave')
                else:
                    thisZone.setType('master')
                    
                self.zones.append(thisZone)
            except:
                pass

            # destroying thisZone instance
            thisZone = None