diff --git a/FilterListManager.glyphsPlugin/Contents/Info.plist b/FilterListManager.glyphsPlugin/Contents/Info.plist index 16ddb15..c971cbb 100644 --- a/FilterListManager.glyphsPlugin/Contents/Info.plist +++ b/FilterListManager.glyphsPlugin/Contents/Info.plist @@ -3,9 +3,7 @@ CFBundleDevelopmentRegion - English - CFBundleDisplayName - Filter List Manager + en CFBundleExecutable plugin CFBundleIdentifier @@ -14,12 +12,10 @@ 6.0 CFBundleName FilterListManager - CFBundlePackageType - BNDL - CFBundleVersion - 50 CFBundleShortVersionString - 0.5.0 + 0.5.1 + CFBundleVersion + 51 UpdateFeedURL https://raw.githubusercontent.com/source-foundry/FilterListManager/master/FilterListManager.glyphsPlugin/Contents/Info.plist productPageURL @@ -30,9 +26,5 @@ Copyright 2018 Christopher Simpkins, Apache License 2.0 NSPrincipalClass FilterListManager - PyMainFileNames - - ../MacOS/main.py - diff --git a/FilterListManager.glyphsPlugin/Contents/MacOS/main.py b/FilterListManager.glyphsPlugin/Contents/MacOS/main.py deleted file mode 100644 index 028888c..0000000 --- a/FilterListManager.glyphsPlugin/Contents/MacOS/main.py +++ /dev/null @@ -1,16 +0,0 @@ -def _run(script): - global __file__ - import os, sys - sys.frozen = 'macosx_plugin' - base = os.environ['RESOURCEPATH'] - __file__ = path = os.path.join(base, script) - if sys.version_info[0] == 2: - with open(path, 'rU') as fp: - source = fp.read() + "\n" - else: - with open(path, 'r', encoding='utf-8') as fp: - source = fp.read() + '\n' - - exec(compile(source, path, 'exec'), globals(), globals()) - -_run('plugin.py') diff --git a/FilterListManager.glyphsPlugin/Contents/MacOS/plugin b/FilterListManager.glyphsPlugin/Contents/MacOS/plugin index b21f0e4..82bb118 100755 Binary files a/FilterListManager.glyphsPlugin/Contents/MacOS/plugin and b/FilterListManager.glyphsPlugin/Contents/MacOS/plugin differ diff --git a/FilterListManager.glyphsPlugin/Contents/PkgInfo b/FilterListManager.glyphsPlugin/Contents/PkgInfo deleted file mode 100644 index 19a9cf6..0000000 --- a/FilterListManager.glyphsPlugin/Contents/PkgInfo +++ /dev/null @@ -1 +0,0 @@ -BNDL???? \ No newline at end of file diff --git a/FilterListManager.glyphsPlugin/Contents/Resources/plugin.py b/FilterListManager.glyphsPlugin/Contents/Resources/plugin.py index be3e3dd..da46d7c 100755 --- a/FilterListManager.glyphsPlugin/Contents/Resources/plugin.py +++ b/FilterListManager.glyphsPlugin/Contents/Resources/plugin.py @@ -1,6 +1,7 @@ # encoding: utf-8 +from __future__ import division, print_function, unicode_literals -# ########################################################################################################## +########################################################################################################### # # # Filter List Manager @@ -9,7 +10,7 @@ # Apache License 2.0 # # -# ########################################################################################################## +########################################################################################################### import logging import objc @@ -17,8 +18,12 @@ import plistlib import shutil import subprocess -import urllib2 -import urlparse +try: + import urllib2 as urllibrequest + import urlparse as urllibparse +except: + import urllib.request as urllibrequest + import urllib.parse as urllibparse from GlyphsApp import * from GlyphsApp.plugins import * @@ -84,45 +89,43 @@ class FilterListManager(GeneralPlugin): + @objc.python_method def settings(self): self.update_name = Glyphs.localize( { - "en": u"Update Filter Lists", - "de": u"Filterlisten aktualisieren" + "en": "Update Filter Lists", + "de": "Filterlisten aktualisieren" } ) self.restoredefault_name = Glyphs.localize( { - "en": u"Restore Default Filter Lists", - "de": u"Standard-Filterlisten wiederherstellen", + "en": "Restore Default Filter Lists", + "de": "Standard-Filterlisten wiederherstellen", } ) self.opendir_name = Glyphs.localize( { - "en": u"Open GlyphsFilters Directory", - "de": u"Verzeichnis GlyphsFilters öffnen", + "en": "Open GlyphsFilters Directory", + "de": "Verzeichnis GlyphsFilters öffnen", } ) + @objc.python_method def start(self): try: # new API in Glyphs 2.3.1-910 - new_update_menu_item = NSMenuItem(self.update_name, self.update_filters) - new_restore_menu_item = NSMenuItem( - self.restoredefault_name, self.restore_filters - ) - new_opendir_menu_item = NSMenuItem( - self.opendir_name, self.open_glyphsfilters_directory - ) + new_update_menu_item = NSMenuItem(self.update_name, self.updateFilters_) + new_restore_menu_item = NSMenuItem(self.restoredefault_name, self.restoreFilters_) + new_opendir_menu_item = NSMenuItem(self.opendir_name, self.openGlyphsfiltersDirectory_) Glyphs.menu[EDIT_MENU].append(new_update_menu_item) Glyphs.menu[EDIT_MENU].append(new_restore_menu_item) Glyphs.menu[EDIT_MENU].append(new_opendir_menu_item) except Exception: main_menu = Glyphs.mainMenu() - update_selector = objc.selector(self.update_filters, signature="v@:@") - restore_selector = objc.selector(self.restore_filters, signature="v@:@") + update_selector = objc.selector(self.updateFilters_, signature="v@:@") + restore_selector = objc.selector(self.restoreFilters_, signature="v@:@") open_selector = objc.selector( - self.open_glyphsfilters_directory, signature="v@:@" + self.openGlyphsfiltersDirectory_, signature="v@:@" ) new_update_menu_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( self.update_name, update_selector, "" @@ -140,7 +143,7 @@ def start(self): new_open_menu_item.setTarget_(self) main_menu.itemWithTag_(5).submenu().addItem_(new_open_menu_item) - def update_filters(self, sender): + def updateFilters_(self, sender): """Perform the list filter update""" # Expected filter definitions directory test if not self.filter_directory_is_present(): @@ -311,7 +314,7 @@ def update_filters(self, sender): "The filter list updates were successful. Please quit and restart the Glyphs application to view the new filter lists." ) - def restore_filters(self, sender): + def restoreFilters_(self, sender): """Perform restore of default list filters""" # copy the default definitions to the Glyphs application try: @@ -335,7 +338,7 @@ def restore_filters(self, sender): "The default filter list restoration was successful. Please quit and restart the Glyphs application to view the filter lists." ) - def open_glyphsfilters_directory(self, sender): + def openGlyphsfiltersDirectory_(self, sender): """Called from a plugin Edit menu item and opens the ~/GlyphsFilters directory in the macOS Finder""" if not os.path.isdir(FLM_GLYPHSFILTERS_DIR): Glyphs.showNotification( @@ -351,6 +354,7 @@ def open_glyphsfilters_directory(self, sender): "The ~/GlyphsFilters directory was opened with the Edit menu item." ) + @objc.python_method def filter_directory_is_present(self): """Tests for presence of the ~/GlyphsFilters directory""" if not os.path.isdir(FLM_GLYPHSFILTERS_DIR): @@ -358,6 +362,7 @@ def filter_directory_is_present(self): else: return True + @objc.python_method def get_local_filter_definitions_list(self): """Reads and launches parsing of local definition files, returns a Python list of Filter objects that are created from the parse""" @@ -392,6 +397,7 @@ def get_local_filter_definitions_list(self): return local_definitions_list + @objc.python_method def get_remote_filter_definitions_list(self): """Pulls, reads, and launches parsing of remote definition files, returns a Python list of Filter objects that are created from the parse""" @@ -410,20 +416,21 @@ def get_remote_filter_definitions_list(self): else: # unquote URL defined in list to define file name # (in case the user pasted a urlencoded string) - decoded_url = urllib2.unquote(url) - parsed_url = urlparse.urlparse(decoded_url).path + decoded_url = urllibparse.unquote(url) + parsed_url = urllibparse.urlparse(decoded_url).path parsed_path = os.path.split(parsed_url) filter_defintion_filename = parsed_path[1] new_filter = Filter(filter_defintion_filename) # quote URL defined in list to make HTTP GET request - response = urllib2.urlopen(url) + response = urllibrequest.urlopen(url) text = response.read() new_filter.define_list_with_newline_delimited_text(text) remote_definitions_list.append(new_filter) return remote_definitions_list + @objc.python_method def __file__(self): """Glyphs plugin API specific method. Please leave this method unchanged""" return __file__