Commit 27d76c56 authored by Jérome Perrin's avatar Jérome Perrin

*: use zope.interface's implementer decorator

this will be compatible with python3
parent b2bf7ce9
Pipeline #28115 passed with stage
in 0 seconds
...@@ -32,17 +32,17 @@ import mimetypes ...@@ -32,17 +32,17 @@ import mimetypes
import tempfile import tempfile
from os.path import join, exists, curdir, abspath from os.path import join, exists, curdir, abspath
from os import listdir, remove, chdir from os import listdir, remove, chdir
from zope.interface import implements from zope.interface import implementer
from zipfile import ZipFile, is_zipfile from zipfile import ZipFile, is_zipfile
from shutil import rmtree from shutil import rmtree
from cloudooo.interfaces.file import IFile from cloudooo.interfaces.file import IFile
@implementer(IFile)
class File(object): class File(object):
"""File is used to manipulate one temporary file """File is used to manipulate one temporary file
stored into the filesystem. stored into the filesystem.
""" """
implements(IFile)
def __init__(self, base_folder_url, data, source_format): def __init__(self, base_folder_url, data, source_format):
"""Create an file into file system and store the URL. """Create an file into file system and store the URL.
......
...@@ -28,18 +28,17 @@ ...@@ -28,18 +28,17 @@
# #
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.handler import IHandler from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File from cloudooo.file import File
from cloudooo.util import logger from cloudooo.util import logger
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from tempfile import mktemp from tempfile import mktemp
@implementer(IHandler)
class Handler(object): class Handler(object):
"""FFMPEG Handler is used to handler inputed audio and video files""" """FFMPEG Handler is used to handler inputed audio and video files"""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw): def __init__(self, base_folder_url, data, source_format, **kw):
""" """
base_folder_url(string) base_folder_url(string)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
############################################################################## ##############################################################################
import re import re
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.handler import IHandler from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File from cloudooo.file import File
from cloudooo.util import logger from cloudooo.util import logger
...@@ -37,11 +37,10 @@ from subprocess import Popen, PIPE ...@@ -37,11 +37,10 @@ from subprocess import Popen, PIPE
from tempfile import mktemp from tempfile import mktemp
@implementer(IHandler)
class Handler(object): class Handler(object):
"""ImageMagic Handler is used to handler images.""" """ImageMagic Handler is used to handler images."""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw): def __init__(self, base_folder_url, data, source_format, **kw):
""" Load pdf document """ """ Load pdf document """
self.base_folder_url = base_folder_url self.base_folder_url = base_folder_url
......
...@@ -28,19 +28,18 @@ ...@@ -28,19 +28,18 @@
# #
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.application import IApplication from cloudooo.interfaces.application import IApplication
from cloudooo.util import logger from cloudooo.util import logger
from cloudooo.handler.ooo.util import waitStopDaemon from cloudooo.handler.ooo.util import waitStopDaemon
from psutil import pid_exists, Process, AccessDenied from psutil import pid_exists, Process, AccessDenied
@implementer(IApplication)
class Application(object): class Application(object):
"""Base object to create an object that is possible manipulation a """Base object to create an object that is possible manipulation a
process""" process"""
implements(IApplication)
name = "application" name = "application"
def start(self, init=True): def start(self, init=True):
......
...@@ -34,7 +34,7 @@ import subprocess ...@@ -34,7 +34,7 @@ import subprocess
from psutil import AccessDenied, NoSuchProcess from psutil import AccessDenied, NoSuchProcess
from os.path import exists, join from os.path import exists, join
from threading import Lock from threading import Lock
from zope.interface import implements from zope.interface import implementer
from application import Application from application import Application
from cloudooo.interfaces.lockable import ILockable from cloudooo.interfaces.lockable import ILockable
from cloudooo.util import logger from cloudooo.util import logger
...@@ -43,11 +43,10 @@ from cloudooo.handler.ooo.util import waitStartDaemon, \ ...@@ -43,11 +43,10 @@ from cloudooo.handler.ooo.util import waitStartDaemon, \
socketStatus socketStatus
@implementer(ILockable)
class OpenOffice(Application): class OpenOffice(Application):
"""Object to control one OOo Instance and all features instance.""" """Object to control one OOo Instance and all features instance."""
implements(ILockable)
name = "openoffice" name = "openoffice"
def __init__(self): def __init__(self):
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
# #
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implementer
from zipfile import ZipFile from zipfile import ZipFile
from StringIO import StringIO from StringIO import StringIO
from lxml import etree from lxml import etree
...@@ -40,11 +40,10 @@ class FileSystemDocument(File): ...@@ -40,11 +40,10 @@ class FileSystemDocument(File):
pass pass
@implementer(IOdfDocument)
class OdfDocument(object): class OdfDocument(object):
"""Manipulates odf documents in memory""" """Manipulates odf documents in memory"""
implements(IOdfDocument)
def __init__(self, data, source_format): def __init__(self, data, source_format):
"""Open the the file in memory. """Open the the file in memory.
......
...@@ -28,15 +28,14 @@ ...@@ -28,15 +28,14 @@
# #
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.filter import IFilter from cloudooo.interfaces.filter import IFilter
@implementer(IFilter)
class Filter(object): class Filter(object):
"""Filter of OOo.""" """Filter of OOo."""
implements(IFilter)
def __init__(self, extension, filter, mimetype, document_service, **kwargs): def __init__(self, extension, filter, mimetype, document_service, **kwargs):
"""Receives extension, filter and mimetype of filter and saves in object. """Receives extension, filter and mimetype of filter and saves in object.
""" """
......
...@@ -35,7 +35,7 @@ from base64 import decodestring, encodestring ...@@ -35,7 +35,7 @@ from base64 import decodestring, encodestring
from os import environ, path from os import environ, path
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from cloudooo.handler.ooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.handler import IHandler from cloudooo.interfaces.handler import IHandler
from cloudooo.handler.ooo.mimemapper import mimemapper from cloudooo.handler.ooo.mimemapper import mimemapper
from cloudooo.handler.ooo.document import FileSystemDocument from cloudooo.handler.ooo.document import FileSystemDocument
...@@ -45,13 +45,13 @@ from cloudooo.util import logger, parseContentType, loadMimetypeList ...@@ -45,13 +45,13 @@ from cloudooo.util import logger, parseContentType, loadMimetypeList
from psutil import pid_exists from psutil import pid_exists
@implementer(IHandler)
class Handler(object): class Handler(object):
"""OOO Handler is used to access the one Document and OpenOffice. """OOO Handler is used to access the one Document and OpenOffice.
For each Document inputed is created on instance of this class to manipulate For each Document inputed is created on instance of this class to manipulate
the document. This Document must be able to create and remove a temporary the document. This Document must be able to create and remove a temporary
document at FS, load and export. document at FS, load and export.
""" """
implements(IHandler)
enable_scripting = False enable_scripting = False
......
...@@ -32,7 +32,7 @@ import pkg_resources ...@@ -32,7 +32,7 @@ import pkg_resources
from re import findall from re import findall
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from subprocess import STDOUT from subprocess import STDOUT
from zope.interface import implements from zope.interface import implementer
from filter import Filter from filter import Filter
from os import environ, path from os import environ, path
from cloudooo.interfaces.mimemapper import IMimemapper from cloudooo.interfaces.mimemapper import IMimemapper
...@@ -40,11 +40,11 @@ from types import InstanceType ...@@ -40,11 +40,11 @@ from types import InstanceType
import json import json
@implementer(IMimemapper)
class MimeMapper(object): class MimeMapper(object):
"""Load all filters from OOo. You can get the filter you want or all """Load all filters from OOo. You can get the filter you want or all
filters of the specific extension. filters of the specific extension.
""" """
implements(IMimemapper)
def __init__(self): def __init__(self):
"""When it is instantiated, it creates a structure to store filters. """When it is instantiated, it creates a structure to store filters.
......
...@@ -28,15 +28,14 @@ ...@@ -28,15 +28,14 @@
# #
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.monitor import IMonitor from cloudooo.interfaces.monitor import IMonitor
@implementer(IMonitor)
class Monitor(object): class Monitor(object):
""" """ """ """
implements(IMonitor)
def __init__(self, openoffice, interval): def __init__(self, openoffice, interval):
"""Expects an openoffice object and the interval""" """Expects an openoffice object and the interval"""
self.status_flag = False self.status_flag = False
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
############################################################################## ##############################################################################
import io import io
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.handler import IHandler from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File from cloudooo.file import File
from cloudooo.util import logger, parseContentType from cloudooo.util import logger, parseContentType
...@@ -39,11 +39,10 @@ from tempfile import mktemp ...@@ -39,11 +39,10 @@ from tempfile import mktemp
from pyPdf import PdfFileWriter, PdfFileReader from pyPdf import PdfFileWriter, PdfFileReader
from pyPdf.generic import NameObject, createStringObject from pyPdf.generic import NameObject, createStringObject
@implementer(IHandler)
class Handler(object): class Handler(object):
"""PDF Handler is used to handler inputed pdf document.""" """PDF Handler is used to handler inputed pdf document."""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw): def __init__(self, base_folder_url, data, source_format, **kw):
""" Load pdf document """ """ Load pdf document """
self.base_folder_url = base_folder_url self.base_folder_url = base_folder_url
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.handler import IHandler from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File from cloudooo.file import File
from cloudooo.util import logger, parseContentType from cloudooo.util import logger, parseContentType
...@@ -39,11 +39,10 @@ from base64 import b64decode ...@@ -39,11 +39,10 @@ from base64 import b64decode
def keyNameToOption(key_name, prefix=""): def keyNameToOption(key_name, prefix=""):
return "--" + prefix + key_name.replace("_", "-") return "--" + prefix + key_name.replace("_", "-")
@implementer(IHandler)
class Handler(object): class Handler(object):
"""ImageMagic Handler is used to handler images.""" """ImageMagic Handler is used to handler images."""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw): def __init__(self, base_folder_url, data, source_format, **kw):
""" Load pdf document """ """ Load pdf document """
self.base_folder_url = base_folder_url self.base_folder_url = base_folder_url
......
...@@ -34,7 +34,7 @@ import json ...@@ -34,7 +34,7 @@ import json
import io import io
from mimetypes import guess_type from mimetypes import guess_type
from zope.interface import implements from zope.interface import implementer
from cloudooo.interfaces.handler import IHandler from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File from cloudooo.file import File
...@@ -156,14 +156,13 @@ yformat_map = { ...@@ -156,14 +156,13 @@ yformat_map = {
yformat_tuple = ("docy", "xlsy", "ppty") yformat_tuple = ("docy", "xlsy", "ppty")
@implementer(IHandler)
class Handler(object): class Handler(object):
""" """
X2T Handler is used to convert Microsoft Office 2007 documents to OnlyOffice X2T Handler is used to convert Microsoft Office 2007 documents to OnlyOffice
documents. documents.
""" """
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw): def __init__(self, base_folder_url, data, source_format, **kw):
""" """
base_folder_url(string) base_folder_url(string)
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
import mimetypes import mimetypes
from mimetypes import guess_type, guess_extension from mimetypes import guess_type, guess_extension
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
from zope.interface import implements from zope.interface import implementer
from interfaces.manager import IManager, IERP5Compatibility from interfaces.manager import IManager, IERP5Compatibility
from cloudooo.util import logger, parseContentType from cloudooo.util import logger, parseContentType
from cloudooo.interfaces.granulate import ITableGranulator from cloudooo.interfaces.granulate import ITableGranulator
...@@ -94,10 +94,10 @@ def BBB_guess_extension(mimetype, title=None): ...@@ -94,10 +94,10 @@ def BBB_guess_extension(mimetype, title=None):
"image/jpeg": ".jpg", "image/jpeg": ".jpg",
}.get(parseContentType(mimetype).gettype(), None) or guess_extension(mimetype) }.get(parseContentType(mimetype).gettype(), None) or guess_extension(mimetype)
@implementer(IManager, IERP5Compatibility, ITableGranulator, IImageGranulator,
ITextGranulator)
class Manager(object): class Manager(object):
"""Manipulates requisitons of client and temporary files in file system.""" """Manipulates requisitons of client and temporary files in file system."""
implements(IManager, IERP5Compatibility, ITableGranulator, IImageGranulator,
ITextGranulator)
def __init__(self, path_tmp_dir, **kw): def __init__(self, path_tmp_dir, **kw):
"""Need pass the path where the temporary document will be created.""" """Need pass the path where the temporary document will be created."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment