Beispiel #1
0
    def _validate(self, theme_name):
        path = ""

        try:
            if theme_name in self.data:
                raise Exception("Duplicate theme. Is it already added?")

            path = "%s/theme.json" % theme_name

            options = "".join(utils.file_read(path))
            blob = utils.is_json(options)
            theme_name = Theme(name=theme_name, data=blob)

            return theme_name

        except IOError:
            raise Exception(
                "Could not read \"%s%s\" - Themes file not found." %
                (self.base, path))

        except ValueError as ex:
            raise Exception("Could not parse \"%s\" - Contents not json: %s" %
                            (path, str(ex)))

        except Exception as ex:
            raise Exception(str(ex))
Beispiel #2
0
    def validate_dir(self, dir):
        try:
            if dir in self.themes:
                raise Exception('Duplicate theme. Is it already added?')

            path = '%s/%s/theme.json' % (self.theme_dir, dir)

            options = ''.join(utils.file_read(path))
            blob = utils.is_json(options)

            theme = Theme(data=blob)
            self.themes[theme['theme_name']] = theme.options

        except IOError:
            raise Exception("Could not read \"%s%s\" - Themes file not found." % (self.theme_dir, path))

        except ValueError as ex:
            raise Exception("Could not parse \"%s\" - Contents not json: %s" % (path, str(ex)))

        except Exception as ex:
            raise Exception(str(ex))
Beispiel #3
0
    def _validate(self, theme_name):
        path = ""

        try:
            if theme_name in self.data:
                raise Exception("Duplicate theme. Is it already added?")

            path = "%s/theme.json" % theme_name

            options = "".join(utils.file_read(path))
            blob = utils.is_json(options)
            theme_name = Theme(name=theme_name, data=blob)

            return theme_name

        except IOError:
            raise Exception('Could not read "%s%s" - Themes file not found.' % (self.base, path))

        except ValueError as ex:
            raise Exception('Could not parse "%s" - Contents not json: %s' % (path, str(ex)))

        except Exception as ex:
            raise Exception(str(ex))
Beispiel #4
0
    def validate_dir(self, dir):
        try:
            if dir in self.themes:
                raise Exception('Duplicate theme. Is it already added?')

            path = '%s%s/theme.json' % (self.theme_dir, dir)

            options = ''.join(utils.file_read(path))
            blob = utils.is_json(options)

            theme = Theme(data=blob)
            self.themes[theme['theme_name']] = theme.options

        except IOError:
            raise Exception(
                "Could not read \"%s%s\" - Themes file not found." %
                (self.theme_dir, path))

        except ValueError as ex:
            raise Exception("Could not parse \"%s\" - Contents not json: %s" %
                            (path, str(ex)))

        except Exception as ex:
            raise Exception(str(ex))