Exemplo n.º 1
0
    def read_configfile(self):
        if self.options.config:
            configpath = self.options.config
        elif os.environ.get('HOME'):
            configpath = '%s/.blockdiagrc' % os.environ.get('HOME')
        elif os.environ.get('USERPROFILE'):
            configpath = '%s/.blockdiagrc' % os.environ.get('USERPROFILE')
        else:
            configpath = ''

        appname = self.module.__name__
        if os.path.isfile(configpath):
            config = ConfigParser()
            config.read(configpath)

            if config.has_option(appname, 'fontpath'):
                fontpath = config.get(appname, 'fontpath')
                self.options.font.append(fontpath)

            if config.has_option(appname, 'fontmap'):
                if self.options.fontmap is None:
                    self.options.fontmap = config.get(appname, 'fontmap')

            if config.has_option(appname, 'antialias'):
                antialias = config.get(appname, 'antialias')
                if antialias.lower() == 'true':
                    self.options.antialias = True

            if self.options.fontmap is None:
                self.options.fontmap = configpath
Exemplo n.º 2
0
    def read_configfile(self):
        if self.options.config:
            configpath = self.options.config
        elif os.environ.get('HOME'):
            configpath = '%s/.blockdiagrc' % os.environ.get('HOME')
        elif os.environ.get('USERPROFILE'):
            configpath = '%s/.blockdiagrc' % os.environ.get('USERPROFILE')
        else:
            configpath = ''

        appname = self.module.__name__
        if os.path.isfile(configpath):
            config = ConfigParser()
            config.read(configpath)

            if config.has_option(appname, 'fontpath'):
                fontpath = config.get(appname, 'fontpath')
                self.options.font.append(fontpath)

            if config.has_option(appname, 'fontmap'):
                if self.options.fontmap is None:
                    self.options.fontmap = config.get(appname, 'fontmap')

            if config.has_option(appname, 'antialias'):
                antialias = config.get(appname, 'antialias')
                if antialias.lower() == 'true':
                    self.options.antialias = True

            if self.options.fontmap is None:
                self.options.fontmap = configpath
Exemplo n.º 3
0
    def _parse_config(self, conffile):
        config = ConfigParser()

        if hasattr(conffile, 'read'):
            config.read_file(conffile)
        elif os.path.isfile(conffile):
            config.read(conffile)
        else:
            msg = "fontmap file is not found: %s" % conffile
            raise RuntimeError(msg)

        if config.has_section('fontmap'):
            for name, path in config.items('fontmap'):
                self.append_font(name, path)

        if config.has_section('fontalias'):
            for name, family in config.items('fontalias'):
                self.aliases[name] = family
Exemplo n.º 4
0
    def _parse_config(self, conffile):
        config = ConfigParser()

        if hasattr(conffile, 'read'):
            config.readfp(conffile)
        elif os.path.isfile(conffile):
            config.read(conffile)
        else:
            msg = "fontmap file is not found: %s" % conffile
            raise RuntimeError(msg)

        if config.has_section('fontmap'):
            for name, path in config.items('fontmap'):
                self.append_font(name, path)

        if config.has_section('fontalias'):
            for name, family in config.items('fontalias'):
                self.aliases[name] = family