Skip to content

Commit

Permalink
fix pep8 + pyflaxes issues
Browse files Browse the repository at this point in the history
  • Loading branch information
toutpt committed Jan 21, 2013
1 parent 0d589f8 commit bc92fd7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion collective/gallery/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def cache_key(fun, self):
objectIds = ""
if hasattr(self.context.aq_inner.aq_explicit, 'objectIds'):
objectIds = str(len(self.context.aq_inner.aq_explicit.objectIds()))
return mod_date + one_hour + objectIds
return mod_date + one_hour + objectIds


def url_cache_key(fun, self):
Expand Down
5 changes: 3 additions & 2 deletions collective/gallery/i18n.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collective.gallery import messageFactory as _

gallery_view_title = _(u"Gallery view")
message_no_backend_for_link = _(u"message_no_backend_for_link",
default=u"Gallery ERROR: This link is not supported.")
message_no_backend_for_link = _(
u"message_no_backend_for_link",
default=u"Gallery ERROR: This link is not supported.")
10 changes: 5 additions & 5 deletions collective/gallery/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class IGallerySettings(interface.Interface):
#dependencies
try:
#plone4
from plone.app.folder.folder import IATUnifiedFolder as IFolder
from Products.ATContentTypes.interfaces.link import IATLink as ILink
from plone.app.folder.folder import IATUnifiedFolder as IFolder
from Products.ATContentTypes.interfaces.link import IATLink as ILink
from Products.ATContentTypes.interfaces.topic import IATTopic as ITopic
from Products.ATContentTypes.interfaces.image import IATImage as IImage
from Products.ZCatalog.interfaces import ICatalogBrain
Expand All @@ -88,9 +88,9 @@ class IGallerySettings(interface.Interface):
logger.info('BBB: switch to plone3 %s' % e)
#plone3
from Products.ATContentTypes.interface import IATFolder as IFolder
from Products.ATContentTypes.interface import IATLink as ILink
from Products.ATContentTypes.interface import IATTopic as ITopic
from Products.ATContentTypes.interface import IATImage as IImage
from Products.ATContentTypes.interface import IATLink as ILink
from Products.ATContentTypes.interface import IATTopic as ITopic
from Products.ATContentTypes.interface import IATImage as IImage

class ICatalogBrain(interface.Interface):
pass
12 changes: 5 additions & 7 deletions collective/gallery/link/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@

from plone.memoize import ram

from Products.CMFCore.utils import getToolByName

from collective.gallery import interfaces
from collective.gallery import i18n
from collective.gallery import cache
from collective.gallery import core
from collective.gallery.link.base import BaseResource
from Products.statusmessages.interfaces import IStatusMessage

from collective.gallery.link.facebook import check as check_facebook
from collective.gallery.link.flickr import check as check_flickr
from collective.gallery.link.facebook import check as check_facebook
from collective.gallery.link.flickr import check as check_flickr
from collective.gallery.link.picasaweb import check as check_picasaweb

from collective.gallery.link.facebook import Link as FacebookLink
from collective.gallery.link.flickr import Link as FlickrLink
from collective.gallery.link.facebook import Link as FacebookLink
from collective.gallery.link.flickr import Link as FlickrLink
from collective.gallery.link.picasaweb import Link as PicasawebLink


Expand Down Expand Up @@ -76,7 +74,7 @@ def addmessage(self, message, type=u"info"):
except TypeError:
pass

# @ram.cache(cache.cache_key)
@ram.cache(cache.cache_key)
def photos(self):
resource = self.resource
if resource is None:
Expand Down
9 changes: 5 additions & 4 deletions collective/gallery/link/flickr.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def extract_data(url):
except IndexError:
val = None
# special case: search on tags without user
if (val in ['searchtags', 'photos', 'sets']
and m in ['searchtags', 'photos', 'sets']):
if (
val in ['searchtags', 'photos', 'sets']
and m in ['searchtags', 'photos', 'sets']
):
continue
result[mapping.get(m, m)] = val
return result
Expand Down Expand Up @@ -119,8 +121,7 @@ def photos(self):
kw['user_id'] = self.user_info['user_id']
if metadatas['searchtags']:
kw['tags'] = metadatas['searchtags']
if (not 'user_id' in kw
and not 'tags' in kw):
if (not 'user_id' in kw and not 'tags' in kw):
raise Exception(
'invalid search, '
'at least user or tags is needed')
Expand Down
2 changes: 1 addition & 1 deletion collective/gallery/link/picasaweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger = logging.getLogger('collective.gallery')

SIZES = (32, 48, 64, 72, 104, 144, 150, 160, 94, 110, 128, 200, 220, 288, 320,
400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600)
400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600)


def check(url):
Expand Down
2 changes: 1 addition & 1 deletion collective/gallery/tests/test_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def testPhotos(self):
# testcase as integrational, inherited from PloneTestCase
try:
from Zope2.App.zcml import load_config
except ImportError, e:
except ImportError:
from Products.Five.zcml import load_config
import zope.component
import zope.annotation
Expand Down
23 changes: 13 additions & 10 deletions collective/gallery/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
except ImportError, e:
#plone3 bbb
def getAllowedSizes():
return {'large': (768, 768),
'preview': (400, 400),
'mini': (200, 200),
'thumb': (128, 128),
'tile': (64, 64),
'icon': (32, 32),
'listing': (16, 16),
}
return {
'large': (768, 768),
'preview': (400, 400),
'mini': (200, 200),
'thumb': (128, 128),
'tile': (64, 64),
'icon': (32, 32),
'listing': (16, 16),
}


def ImageScaleVocabulary(context):
allowed_sizes = getAllowedSizes()
items = [("%s(%s, %s)" % (key, value[0], value[1]), key)
for key, value in allowed_sizes.items() if allowed_sizes]
items = [
("%s(%s, %s)" % (key, value[0], value[1]), key)
for key, value in allowed_sizes.items() if allowed_sizes
]
return SimpleVocabulary.fromItems(items)

directlyProvides(ImageScaleVocabulary, IVocabularyFactory)

0 comments on commit bc92fd7

Please sign in to comment.