コード例 #1
0
ファイル: parser.py プロジェクト: sveetch/django-icomoon
 def get(self, webfont_name, webfont_settings):
     """
     Get a manifest file and parse it
     
     @webfont_name: Webfont key name
     @webfont_settings: Dict of webfont settings
     """
     try:
         webfont_settings = extend_webfont_settings(webfont_settings)
     except IcomoonSettingsError as e:
         self.errors[webfont_name] = "Invalid webfont settings for '{}': {}".format(webfont_name, e.value)
         return
         
     filepath = os.path.join(webfont_settings['fontdir_path'], self.manifest_filename)
     if os.path.exists(filepath):
         self.manifests[webfont_name] = self.parse_manifest(filepath)
     else:
         self.errors[webfont_name] = "Filepath for webfont <strong>{name}</strong> does not exists: <code>{filepath}</code>".format(name=webfont_name, filepath=filepath)
コード例 #2
0
    def handle(self, *args, **options):
        self.webfont_name = options['webfont_name']
        self.archive_path = options['archive_path']
        self.css_templatepath = options.get('css_template', settings.ICOMOON_CSS_TEMPLATE)
        self.requirements = options.get('requirements', settings.ICOMOON_ARCHIVE_REQUIREMENT)
        self.verbosity = int(options.get('verbosity'))

        self._info("* Using webfont name: {}", self.webfont_name)

        # Get the current manifest for given webfont name
        if self.webfont_name not in settings.ICOMOON_WEBFONTS:
            choices = "', '".join(settings.ICOMOON_WEBFONTS.keys())
            self._error("There is no defined webfont name '{name}' in your settings, choices are: '{choices}'", name=self.webfont_name, choices=choices)

        try:
            self.webfont_settings = extend_webfont_settings(settings.ICOMOON_WEBFONTS[self.webfont_name])
        except IcomoonSettingsError as e:
            self._error("Invalid webfont settings for '{}': {}", self.webfont_name, e.value)

        self._info("* Using webfont font dir: {}", self.webfont_settings['fontdir_path'])

        self.deploy()
        self._info("Finished !")