phatch-dev team mailing list archive
-
phatch-dev team
-
Mailing list archive
-
Message #01153
[Merge] lp:~andreambu/phatch/pep8 into lp:phatch
Andrea Ambu has proposed merging lp:~andreambu/phatch/pep8 into lp:phatch.
Requested reviews:
stani (stani)
--
https://code.launchpad.net/~andreambu/phatch/pep8/+merge/20413
Your team Phatch Developers is subscribed to branch lp:phatch.
=== modified file 'phatch/linux/__init__.py'
--- phatch/linux/__init__.py 2008-01-28 15:21:33 +0000
+++ phatch/linux/__init__.py 2010-03-01 23:28:14 +0000
@@ -10,9 +10,8 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/
#
# Phatch recommends SPE (http://pythonide.stani.be) for editing python files.
-
=== modified file 'phatch/linux/droplet.py'
--- phatch/linux/droplet.py 2010-02-24 21:00:07 +0000
+++ phatch/linux/droplet.py 2010-03-01 23:28:14 +0000
@@ -14,7 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/
-import new, os
+# Follows PEP8
+
+import new
+import os
import wx
from core import ct
from lib.reverse_translation import _t
@@ -27,170 +30,199 @@
try:
from thunar import thunar_exists, create_thunar_action
except ImportError:
+
def thunar_exists():
return False
try:
- from lib.linux.nautilusExtension import nautilus_exists, create_nautilus_extension
+ from lib.linux.nautilusExtension import nautilus_exists, \
+ create_nautilus_extension
except ImportError:
+
def nautilus_exists():
return False
-WX_ENCODING = wx.GetDefaultPyEncoding()
+WX_ENCODING = wx.GetDefaultPyEncoding()
#---general
-def menu_action(self,program,comment,method,*args,**keyw):
+def menu_action(self, program, comment, method, *args, **keyw):
try:
- success = method(*args,**keyw)
+ success = method(*args, **keyw)
self.show_info(_('If you restart %s, '
- 'the action will appear in the context menu.')%program + comment)
+ 'the action will appear in the context menu.') % program + comment)
except Exception, details:
- reason = exception_to_unicode(details,WX_ENCODING)
+ reason = exception_to_unicode(details, WX_ENCODING)
self.show_error(_('Phatch could not install the action in %s:')\
% program + '\n\n' + reason)
#---droplet
-def create_phatch_droplet(actionlist, folder, icon = 'phatch'):
- """"""
- create_droplet(
- name = system.filename_to_title(actionlist),
- command = ct.COMMAND['DROP']%actionlist,
- folder = folder,
- icon = icon,
- )
-
-def create_phatch_recent_droplet(folder, icon = 'phatch'):
- """"""
- create_droplet(
- name = ct.LABEL_PHATCH_RECENT,
- command = ct.COMMAND['RECENT'],
- folder = folder,
- icon = icon,
- )
-
-def create_phatch_inspector_droplet(folder, icon = 'phatch'):
- """"""
- create_droplet(
- name = ct.LABEL_PHATCH_INSPECTOR,
- command = ct.COMMAND['INSPECTOR'],
- folder = folder,
- icon = icon,
- )
-
-def on_menu_file_export_droplet_actionlist(self,event):
- if self.is_save_not_ok(): return
- self.menu_file_export_droplet(create_phatch_droplet,self.filename)
-
-def on_menu_file_export_droplet_recent(self,event):
+
+
+def create_phatch_droplet(actionlist, folder, icon='phatch'):
+ """"""
+ create_droplet(
+ name=system.filename_to_title(actionlist),
+ command=ct.COMMAND['DROP'] % actionlist,
+ folder=folder,
+ icon=icon,
+ )
+
+
+def create_phatch_recent_droplet(folder, icon='phatch'):
+ """"""
+ create_droplet(
+ name=ct.LABEL_PHATCH_RECENT,
+ command=ct.COMMAND['RECENT'],
+ folder=folder,
+ icon=icon,
+ )
+
+
+def create_phatch_inspector_droplet(folder, icon='phatch'):
+ """"""
+ create_droplet(
+ name=ct.LABEL_PHATCH_INSPECTOR,
+ command=ct.COMMAND['INSPECTOR'],
+ folder=folder,
+ icon=icon,
+ )
+
+
+def on_menu_file_export_droplet_actionlist(self, event):
+ if self.is_save_not_ok():
+ return
+ self.menu_file_export_droplet(create_phatch_droplet, self.filename)
+
+
+def on_menu_file_export_droplet_recent(self, event):
self.menu_file_export_droplet(create_phatch_recent_droplet)
-def on_menu_file_export_droplet_inspector(self,event):
+
+def on_menu_file_export_droplet_inspector(self, event):
self.menu_file_export_droplet(create_phatch_inspector_droplet)
#---thunar
-def create_phatch_thunar_action(actionlist, description='', icon = 'phatch'):
- """"""
- return create_thunar_action(
- name = ct.LABEL_PHATCH_ACTIONLIST%system.filename_to_title(actionlist),
- description = description,
- command = ct.COMMAND['DROP']%actionlist,
- icon = icon,
- types = '<directories/><image-files/>',
- )
-
-def create_phatch_recent_thunar_action(icon = 'phatch'):
- """"""
- return create_thunar_action(
- name = ct.LABEL_PHATCH_RECENT + '...',
- description = ct.DESCRIPTION_RECENT,
- command = ct.COMMAND['RECENT'],
- icon = icon,
- types = '<directories/><image-files/>',
- )
-
-def create_phatch_inspect_thunar_action(icon = 'phatch'):
- """"""
- return create_thunar_action(
- name = ct.INFO['name'] + ' ' + ct.LABEL_PHATCH_INSPECTOR + '...',
- description = ct.DESCRIPTION_INSPECTOR,
- command = ct.COMMAND['INSPECTOR'],
- icon = icon,
- types = '<image-files/>',
- )
-
-def on_menu_file_export_thunar_actionlist(self,event):
- if self.is_save_not_ok(): return
- menu_action(self,'Thunar','',create_phatch_thunar_action,self.filename,
+
+
+def create_phatch_thunar_action(actionlist, description='', icon='phatch'):
+ """"""
+ return create_thunar_action(
+ name=ct.LABEL_PHATCH_ACTIONLIST % system.filename_to_title(actionlist),
+ description=description,
+ command=ct.COMMAND['DROP'] % actionlist,
+ icon=icon,
+ types='<directories/><image-files/>',
+ )
+
+
+def create_phatch_recent_thunar_action(icon='phatch'):
+ """"""
+ return create_thunar_action(
+ name=ct.LABEL_PHATCH_RECENT + '...',
+ description=ct.DESCRIPTION_RECENT,
+ command=ct.COMMAND['RECENT'],
+ icon=icon,
+ types='<directories/><image-files/>',
+ )
+
+
+def create_phatch_inspect_thunar_action(icon='phatch'):
+ """"""
+ return create_thunar_action(
+ name=ct.INFO['name'] + ' ' + ct.LABEL_PHATCH_INSPECTOR + '...',
+ description=ct.DESCRIPTION_INSPECTOR,
+ command=ct.COMMAND['INSPECTOR'],
+ icon=icon,
+ types='<image-files/>',
+ )
+
+
+def on_menu_file_export_thunar_actionlist(self, event):
+ if self.is_save_not_ok():
+ return
+ menu_action(self, 'Thunar', '', create_phatch_thunar_action, self.filename,
description='')
-def on_menu_file_export_thunar_recent(self,event):
- menu_action(self,'Thunar','',create_phatch_recent_thunar_action)
-
-def on_menu_file_export_thunar_inspector(self,event):
- menu_action(self,'Thunar','',create_phatch_inspect_thunar_action)
+
+def on_menu_file_export_thunar_recent(self, event):
+ menu_action(self, 'Thunar', '', create_phatch_recent_thunar_action)
+
+
+def on_menu_file_export_thunar_inspector(self, event):
+ menu_action(self, 'Thunar', '', create_phatch_inspect_thunar_action)
#---nautilus
-REQUIRES_PYTHON_NAUTILUS = '\n\n(%s)'%\
+REQUIRES_PYTHON_NAUTILUS = '\n\n(%s)' % \
_('This requires also that the python-nautilus package is installed.')
-TOOLTIP = '_("%s")'%_t('Batch process images with Phatch')
-PRELOAD = """
+TOOLTIP = '_("%s")' % _t('Batch process images with Phatch')
+PRELOAD = """
from phatch.core.config import load_locale_only
load_locale_only()"""
+
def create_phatch_nautilus_action(actionlist):
- name = os.path.splitext(os.path.basename(actionlist))[0]
- title = system.title(name)
+ name = os.path.splitext(os.path.basename(actionlist))[0]
+ title = system.title(name)
create_nautilus_extension(
- name = 'phatch_actionlist_' + \
- name.encode('ascii','ignore'),
- label = '_("%s") + "..."'%_t('Phatch with %s')%title,
- command = 'phatch -d "%s" %%s &'%actionlist,
- mimetypes = IMAGE_READ_MIMETYPES,
- tooltip = TOOLTIP,
- preload = PRELOAD,
+ name='phatch_actionlist_' + \
+ name.encode('ascii', 'ignore'),
+ label='_("%s") + "..."' % _t('Phatch with %s') % title,
+ command='phatch -d "%s" %%s &' % actionlist,
+ mimetypes=IMAGE_READ_MIMETYPES,
+ tooltip=TOOLTIP,
+ preload=PRELOAD,
)
+
def create_phatch_recent_nautilus_action():
create_nautilus_extension(
- name = 'phatch_recent',
- label = '_("%s") + "..."'%\
+ name='phatch_recent',
+ label='_("%s") + "..."' % \
_t('Process with recent Phatch action list'),
- command = 'phatch -d recent %s &',
- mimetypes = IMAGE_READ_MIMETYPES,
- tooltip = TOOLTIP,
- preload = PRELOAD,
+ command='phatch -d recent %s &',
+ mimetypes=IMAGE_READ_MIMETYPES,
+ tooltip=TOOLTIP,
+ preload=PRELOAD,
)
+
def create_phatch_inspect_nautilus_action():
create_nautilus_extension(
- name = 'phatch_image_inspector',
- label = '_("%s") + "..."'%\
+ name='phatch_image_inspector',
+ label='_("%s") + "..."' % \
_t('Inspect with Phatch'),
- command = 'phatch -n %s &',
- mimetypes = IMAGE_READ_MIMETYPES,
- tooltip = '_("%s")'%_t('Inspect EXIF & IPTC tags'),
- preload = PRELOAD,
+ command='phatch -n %s &',
+ mimetypes=IMAGE_READ_MIMETYPES,
+ tooltip='_("%s")' % _t('Inspect EXIF & IPTC tags'),
+ preload=PRELOAD,
)
-def on_menu_file_export_nautilus_actionlist(self,event):
- if self.is_save_not_ok(): return
- menu_action(self,'Nautilus',REQUIRES_PYTHON_NAUTILUS,
- create_phatch_nautilus_action,self.filename)
-
-def on_menu_file_export_nautilus_recent(self,event):
- menu_action(self,'Nautilus',REQUIRES_PYTHON_NAUTILUS,
+
+def on_menu_file_export_nautilus_actionlist(self, event):
+ if self.is_save_not_ok():
+ return
+ menu_action(self, 'Nautilus', REQUIRES_PYTHON_NAUTILUS,
+ create_phatch_nautilus_action, self.filename)
+
+
+def on_menu_file_export_nautilus_recent(self, event):
+ menu_action(self, 'Nautilus', REQUIRES_PYTHON_NAUTILUS,
create_phatch_recent_nautilus_action)
-def on_menu_file_export_nautilus_inspector(self,event):
- menu_action(self,'Nautilus',REQUIRES_PYTHON_NAUTILUS,
+
+def on_menu_file_export_nautilus_inspector(self, event):
+ menu_action(self, 'Nautilus', REQUIRES_PYTHON_NAUTILUS,
create_phatch_inspect_nautilus_action)
#---install
-def install_menu_item(self,menu,name,label,tooltip="",
+
+
+def install_menu_item(self, menu, name, label, tooltip="",
style=wx.ITEM_NORMAL):
- method = globals()['on_' + name]
- return self.install_menu_item(menu,name,label,method,tooltip,style)
+ method = globals()['on_' + name]
+ return self.install_menu_item(menu, name, label, method, tooltip, style)
+
def install(self):
#install menu items in reverse order
@@ -198,17 +230,17 @@
#thunar
if thunar_exists():
install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_thunar_inspector',
- label = ct.INTEGRATE_PHATCH_INSPECTOR%"Thuna&r",
+ name='menu_file_export_thunar_inspector',
+ label=ct.INTEGRATE_PHATCH_INSPECTOR % "Thuna&r",
)
install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_thunar_recent',
- label = ct.INTEGRATE_PHATCH_RECENT%"T&hunar",
+ name='menu_file_export_thunar_recent',
+ label=ct.INTEGRATE_PHATCH_RECENT % "T&hunar",
)
self.menu_item.append((self.menu_file_export,
[install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_thunar_actionlist',
- label = ct.INTEGRATE_PHATCH_ACTIONLIST%"&Thunar",
+ name='menu_file_export_thunar_actionlist',
+ label=ct.INTEGRATE_PHATCH_ACTIONLIST % "&Thunar",
)]))
self.menu_file_export.InsertSeparator(3)
@@ -216,44 +248,44 @@
if nautilus_exists():
if not SYSTEM_INSTALL:
install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_nautilus_inspector',
- label = ct.INTEGRATE_PHATCH_INSPECTOR%"Nautil&us",
+ name='menu_file_export_nautilus_inspector',
+ label=ct.INTEGRATE_PHATCH_INSPECTOR % "Nautil&us",
)
install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_nautilus_recent',
- label = ct.INTEGRATE_PHATCH_RECENT%"Nauti&lus",
+ name='menu_file_export_nautilus_recent',
+ label=ct.INTEGRATE_PHATCH_RECENT % "Nauti&lus",
)
self.menu_item.append((self.menu_file_export,
[install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_nautilus_actionlist',
- label = ct.INTEGRATE_PHATCH_ACTIONLIST%"Nautilu&s",
+ name='menu_file_export_nautilus_actionlist',
+ label=ct.INTEGRATE_PHATCH_ACTIONLIST % "Nautilu&s",
)]))
if SYSTEM_INSTALL:
- separator = 1
+ separator = 1
else:
- separator = 3
+ separator = 3
self.menu_file_export.InsertSeparator(separator)
#droplet
install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_droplet_inspector',
- label = ct.DROPLET_PHATCH_INSPECTOR,
+ name='menu_file_export_droplet_inspector',
+ label=ct.DROPLET_PHATCH_INSPECTOR,
)
install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_droplet_recent',
- label = ct.DROPLET_PHATCH_RECENT,
+ name='menu_file_export_droplet_recent',
+ label=ct.DROPLET_PHATCH_RECENT,
)
self.menu_item.append((self.menu_file_export,
[install_menu_item(self, self.menu_file_export,
- name = 'menu_file_export_droplet_actionlist',
- label = ct.DROPLET_PHATCH_ACTIONLIST,
+ name='menu_file_export_droplet_actionlist',
+ label=ct.DROPLET_PHATCH_ACTIONLIST,
)]))
self.menu_file_export.InsertSeparator(3)
if __name__ == '__main__':
create_phatch_droplet(
- actionlist = '/home/stani/sync/python/phatch/action lists/tutorials/thumb round 3d reflect.phatch',
- folder = '/home/stani/sync/Desktop',
+ actionlist=''.join('/home/stani/sync/python/phatch/action ',
+ 'lists/tutorials/thumb round 3d reflect.phatch'),
+ folder='/home/stani/sync/Desktop',
)
-
Follow ups