From 6ae2590f50cf14f790e903e761f36fd9cbf1ee65 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 28 Sep 2024 08:14:49 +0200 Subject: [PATCH] Python3 fixes: constraint, media, system --- loops/constraint/base.py | 28 ++++------------------------ loops/constraint/testsetup.py | 9 ++++----- loops/media/README.txt | 2 -- loops/media/asset.py | 28 +++++----------------------- loops/system/README.txt | 8 +++----- loops/system/job.py | 31 +++++-------------------------- loops/system/setup.py | 24 ++---------------------- loops/system/site/link.py | 28 ++++------------------------ loops/system/sync/browser.py | 29 +++++------------------------ 9 files changed, 32 insertions(+), 155 deletions(-) diff --git a/loops/constraint/base.py b/loops/constraint/base.py index 39bd458..e4fd131 100644 --- a/loops/constraint/base.py +++ b/loops/constraint/base.py @@ -1,30 +1,11 @@ -# -# Copyright (c) 2008 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# loops.constraint.base -""" -Constraint definitions for restricting concepts and predicates available +""" Constraint definitions for restricting concepts and predicates available for assignment as children or as concepts to resources. - -$Id$ """ from zope.cachedescriptors.property import Lazy -from zope.interface import implements +from zope.interface import implementer from zope.traversing.api import getName from loops.common import AdapterBase, adapterAttributes, contextAttributes @@ -40,13 +21,12 @@ hasConstraint = 'hasconstraint' hasChildConstraint = 'haschildconstraint' +@implementer(IStaticConstraint) class StaticConstraint(AdapterBase): _contextAttributes = contextAttributes(AdapterBase, 'relationType', 'cardinality') _adapterAttributes = adapterAttributes(AdapterBase, 'predicates', 'types') - implements(IStaticConstraint) - def getPredicates(self): return self.context.getChildren([isPredicate]) def setPredicates(self, value): diff --git a/loops/constraint/testsetup.py b/loops/constraint/testsetup.py index 9a283f0..18d19c3 100644 --- a/loops/constraint/testsetup.py +++ b/loops/constraint/testsetup.py @@ -1,13 +1,12 @@ -""" -Set up a loops site for testing. +# loops.constraint.testsetup -$Id$ +""" Set up a loops site for testing. """ import os from zope import component -from zope.app.catalog.interfaces import ICatalog -from zope.app.catalog.field import FieldIndex +from zope.catalog.interfaces import ICatalog +from zope.catalog.field import FieldIndex from loops import util from loops.concept import Concept diff --git a/loops/media/README.txt b/loops/media/README.txt index 6f8efcd..abf12c8 100644 --- a/loops/media/README.txt +++ b/loops/media/README.txt @@ -2,8 +2,6 @@ loops - Linked Objects for Organization and Processing Services =============================================================== - ($Id$) - Media Asset Management ====================== diff --git a/loops/media/asset.py b/loops/media/asset.py index 140acf0..5ef484b 100644 --- a/loops/media/asset.py +++ b/loops/media/asset.py @@ -1,23 +1,6 @@ -# -# Copyright (c) 2014 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# loops.media.asset -""" -Media asset file adapter. +""" Media asset file adapter. Original authors: Johann Schimpf, Erich Seifert. """ @@ -28,7 +11,7 @@ import os from zope import component from zope.cachedescriptors.property import Lazy -from zope.interface import implements +from zope.interface import implementer from cybertools.media.asset import MediaAssetFile from cybertools.storage.interfaces import IExternalStorage @@ -44,13 +27,12 @@ transformPrefix = 'asset_transform.' TypeInterfaceSourceList.typeInterfaces += (IMediaAsset,) +@implementer(IMediaAsset) class MediaAsset(MediaAssetFile, ExternalFileAdapter): """ Concept adapter for extracting metadata from assets and for creating transformation variants. """ - implements(IMediaAsset) - _adapterAttributes = ExternalFileAdapter._adapterAttributes + ('modified',) _contextAttributes = list(IMediaAsset) @@ -109,7 +91,7 @@ class MediaAsset(MediaAssetFile, ExternalFileAdapter): pass try: return datetime.fromtimestamp(os.path.getmtime(dp)) - except Exception, e: + except Exception as e: getLogger('loops.media.asset.MediaAsset').warn(e) return None diff --git a/loops/system/README.txt b/loops/system/README.txt index e1ea5d0..82ff15d 100644 --- a/loops/system/README.txt +++ b/loops/system/README.txt @@ -4,8 +4,6 @@ loops - Linked Objects for Organization and Processing Services loops System Management. - ($Id$) - Setting up a loops Site and Utilities ===================================== @@ -39,11 +37,11 @@ In addition to the application site we need a loops system management site. >>> systemRoot = site['loops.system'] >>> sorted(sysConcepts) - [u'domain', u'file', u'hasType', u'job', u'note', u'predicate', - u'standard', u'textdocument', u'type'] + ['domain', 'file', 'hasType', 'job', 'note', 'predicate', + 'standard', 'textdocument', 'type'] >>> list(systemRoot.getRecordManager().keys()) - [u'jobs'] + ['jobs'] Portal Links diff --git a/loops/system/job.py b/loops/system/job.py index 57ff7a5..e8b7fdf 100644 --- a/loops/system/job.py +++ b/loops/system/job.py @@ -1,28 +1,9 @@ -# -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# loops.system.job -""" -Recording changes to loops objects. - -$Id$ +""" Recording changes to loops objects. """ -from zope.interface import implements +from zope.interface import implementer from zope.cachedescriptors.property import Lazy from zope.component import adapter @@ -33,10 +14,9 @@ from loops.system.interfaces import IJobRecord, IJobRecords from loops import util +@implementer(IJobRecords) class JobRecords(BaseRecordManager): - implements(IJobRecords) - storageName = 'jobs' def __init__(self, context): @@ -56,9 +36,8 @@ class JobRecords(BaseRecordManager): return None +@implementer(IJobRecord) class JobRecord(Track): - implements(IJobRecord) - typeName = 'JobRecord' diff --git a/loops/system/setup.py b/loops/system/setup.py index 8518157..e64a172 100644 --- a/loops/system/setup.py +++ b/loops/system/setup.py @@ -1,29 +1,9 @@ -# -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# loops.system.setup -""" -Automatic setup of a loops site for the system package. - -$Id$ +""" Automatic setup of a loops site for the system package. """ from zope.component import adapts -from zope.interface import implements, Interface from cybertools.tracking.btree import TrackingStorage from loops.concept import Concept diff --git a/loops/system/site/link.py b/loops/system/site/link.py index d6bf988..0264c27 100644 --- a/loops/system/site/link.py +++ b/loops/system/site/link.py @@ -1,28 +1,9 @@ -# -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# loops.system.site.link -""" -Interfaces for linking to other pages on a portal page. - -$Id$ +""" Interfaces for linking to other pages on a portal page. """ -from zope.interface import implements +from zope.interface import implementer from zope import interface, component, schema from loops.common import AdapterBase @@ -34,8 +15,7 @@ from loops.util import _ TypeInterfaceSourceList.typeInterfaces += (ILink,) +@implementer(ILink) class Link(AdapterBase): - implements(ILink) - _contextAttributes = list(ILink) diff --git a/loops/system/sync/browser.py b/loops/system/sync/browser.py index b43524d..265843a 100644 --- a/loops/system/sync/browser.py +++ b/loops/system/sync/browser.py @@ -1,34 +1,15 @@ -# -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# loops.system.sync.browser -""" -view class(es) for import/export. - -$Id$ +""" view class(es) for import/export. """ -from cStringIO import StringIO +from io import StringIO from logging import getLogger import os import time -from urllib import urlopen, urlencode +from urllib.parse import urlencode +from urllib.request import urlopen from zope import component -from zope.interface import Interface, implements from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from zope.cachedescriptors.property import Lazy from zope.traversing.api import getName, getPath