Ejemplo n.º 1
0
    def __init__(self, filename):
        self.parser = IFaceParser()
        self.category_parser = CategoryParser()
        self.comment_parser = CommentParser()

        self.filename = filename

        self.current_cat = ""
        self.categories = {}

        self.current_comment = ""

        self.set_category("Basics")
        self.__parse_iface()
Ejemplo n.º 2
0
    def __init__(self, filename):
        self.parser = IFaceParser()
        self.category_parser = CategoryParser()
        self.comment_parser = CommentParser()

        self.filename = filename

        self.current_cat = ""
        self.categories = {}

        self.current_comment = ""

        self.set_category("Basics")
        self.__parse_iface()
Ejemplo n.º 3
0
class IFace:
    def __init__(self, filename):
        self.parser = IFaceParser()
        self.category_parser = CategoryParser()
        self.comment_parser = CommentParser()

        self.filename = filename

        self.current_cat = ""
        self.categories = {}

        self.current_comment = ""

        self.set_category("Basics")
        self.__parse_iface()

    def set_category(self, name):
        self.current_cat = name

    def add_to_category(self, what, values):
        try:
            cat = self.categories[self.current_cat]
        except KeyError:
            cat = self.categories[self.current_cat] = {}

        try:
            defs = cat[what]
        except KeyError:
            defs = cat[what] = []

        defs.append((values, self.current_comment))

    def get_categories(self):
        return self.categories

    def is_deprecated(self, cat):
        """returns true if given category is deprecated"""
        return cat.lower() == "deprecated"

    def __parse_iface(self):
        iface_f = open(self.filename, "r")

        line = iface_f.readline()

        while (line):
            str = line.rstrip()
            # empty line or unuseful comments:
            if self.parser.is_empty_comment(str):
                # resets the current useful comment
                self.current_comment = ""
                line = iface_f.readline()
                continue

            # useful comments:
            try:
                com = self.comment_parser.parse(str)
                if self.current_comment == "":
                    self.current_comment = com
                else:
                    self.current_comment += "\n%s" % com
                line = iface_f.readline()
                continue
            except NotMatchedError:
                pass

            # categories:
            try:
                self.set_category(self.category_parser.parse(str))
                line = iface_f.readline()
                continue
            except NotMatchedError:
                pass

            # XXX: change it to class
            for parser in self.parser.parsers:
                try:
                    self.add_to_category(parser.category, parser.parse(str))
                except NotMatchedError:
                    pass

            line = iface_f.readline()


#129
Ejemplo n.º 4
0
class IFace:

    def __init__(self, filename):
        self.parser = IFaceParser()
        self.category_parser = CategoryParser()
        self.comment_parser = CommentParser()

        self.filename = filename

        self.current_cat = ""
        self.categories = {}

        self.current_comment = ""

        self.set_category("Basics")
        self.__parse_iface()


    def set_category(self, name):
        self.current_cat = name


    def add_to_category(self, what, values):
        try:
            cat = self.categories[self.current_cat]
        except KeyError:
            cat = self.categories[self.current_cat] = {}
        
        try:
            defs = cat[what]
        except KeyError:
            defs = cat[what] = []

        defs.append((values, self.current_comment))


    def get_categories(self):
        return self.categories


    def is_deprecated(self, cat):
        """returns true if given category is deprecated"""
        return cat.lower() == "deprecated"
    
    def __parse_iface(self):
        iface_f = open(self.filename, "r")
        
        line = iface_f.readline()

        while (line):
            str = line.rstrip()
            # empty line or unuseful comments:
            if self.parser.is_empty_comment(str):
                # resets the current useful comment
                self.current_comment = ""
                line = iface_f.readline()
                continue

            # useful comments:
            try:
                com = self.comment_parser.parse(str)
                if self.current_comment == "":
                    self.current_comment = com
                else:
                    self.current_comment += "\n%s" % com
                line = iface_f.readline()
                continue
            except NotMatchedError:
                pass

            # categories:
            try:
                self.set_category(self.category_parser.parse(str))
                line = iface_f.readline()
                continue
            except NotMatchedError:
                pass

            # XXX: change it to class
            for parser in self.parser.parsers:
                try:
                    self.add_to_category(parser.category, parser.parse(str))
                except NotMatchedError:
                    pass

            line = iface_f.readline()

#129