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