Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions watson_developer_cloud/document_conversion_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
The v1 Document Conversion service
(https://www.ibm.com/watson/developercloud/document-conversion.html)
"""
from .utils import deprecated
from .watson_service import WatsonService
import os
import json

DEPRECATION_MESSAGE = "Since Document Conversion Service was retired in October 2017, we have continued to improve document conversion capabilities within Watson Discovery. If you are a Document Conversion user, get started with Discovery today. Refer to the migration guide: https://console.bluemix.net/docs/services/discovery/migrate-dcs-rr.html"

class DocumentConversionV1(WatsonService):
DEFAULT_URL = 'https://gateway.watsonplatform.net/document-conversion/api'
Expand All @@ -28,10 +29,12 @@ class DocumentConversionV1(WatsonService):
NORMALIZED_TEXT = 'normalized_text'
latest_version = '2016-02-10'

@deprecated(DEPRECATION_MESSAGE)
def __init__(self, version, url=DEFAULT_URL, **kwargs):
WatsonService.__init__(self, 'document_conversion', url, **kwargs)
self.version = version

@deprecated(DEPRECATION_MESSAGE)
def convert_document(self, document, config, media_type=None):
params = {'version': self.version}
filename = os.path.basename(document.name)
Expand All @@ -45,7 +48,7 @@ def convert_document(self, document, config, media_type=None):
return self.request(method='POST', url='/v1/convert_document',
files=files, params=params,
accept_json=accept_json)

@deprecated(DEPRECATION_MESSAGE)
def index_document(self, config, document=None, metadata=None,
media_type=None):
if document is None and metadata is None:
Expand Down
12 changes: 12 additions & 0 deletions watson_developer_cloud/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import warnings

def deprecated(message):
def deprecated_decorator(func):
def deprecated_func(*args, **kwargs):
warnings.warn("{} is a deprecated function. {}".format(func.__name__, message),
category=DeprecationWarning,
stacklevel=2)
warnings.simplefilter('default', DeprecationWarning)
return func(*args, **kwargs)
return deprecated_func
return deprecated_decorator