def parse(self, filename, limit=None):
        if limit is not None:
            self.limit = limit

        retry = 10
        handle = None
        while handle is None:
            try:
                handle = open(filename, 'rb')
            except:
                retry -= 1
                if retry:
                    print '%s is not available, retry %d' % (filename, retry)
                    time.sleep(0.5)
                else:
                    print '%s is not available' % (filename,)
                    sys.exit(0)

        for line in handle:
            line = line.strip()

            if not line:
                continue

            elif self.section is None:
                if self.define:
                    if line[:6] == 'define' and line[-1] == '{':
                        self.new_section(line[7:-1].strip())
                elif line[-1] == '{':
                    self.new_section(line[:-1].strip())

            elif line == '}':
                yield self.end_section()

            elif line[0] == '#':
                continue

            else:
                if self.define:
                    try:
                        space = line.index(' ')
                        self.section[line[:space]] = line[space + 1:]
                    except ValueError:
                        pass
                elif '=' in line:
                    try:
                        equal = line.index('=')
                        self.section[line[:equal]] = line[equal + 1:]
                    except __HOLE__:
                        pass
dataset/ETHPy150Open tehmaze/nagios-cli/nagios_cli/nagios.py/Parser.parse