Skip to content

Commit 3e296b7

Browse files
author
Nicklas Tegner
authored
Removed deprecated code (#257)
* Removed deprecated code
1 parent 28f7a3f commit 3e296b7

File tree

5 files changed

+3
-75
lines changed

5 files changed

+3
-75
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ output = pypandoc.convert_text(
148148
'md', format='html',
149149
extra_args=['--atx-headers'])
150150
# output == '# Primary Heading\r\n'
151-
output = pypandoc.convert(
151+
output = pypandoc.convert_text(
152152
'# Primary Heading',
153153
'html', format='md',
154154
extra_args=['--base-header-level=2'])
@@ -174,9 +174,6 @@ Please pass any filters in as a list and not as a string.
174174
Please refer to `pandoc -h` and the
175175
[official documentation](https://pandoc.org/MANUAL.html) for further details.
176176

177-
> Note: the old way of using `convert(input, output)` is deprecated as in some cases it wasn't
178-
possible to determine whether the input should be used as a filename or as text.
179-
180177
## Dealing with Formatting Arguments
181178

182179
Pandoc supports custom formatting though `-V` parameter. In order to use it through

examples/services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def generate(self, html, **kwargs):
4343
'-o', self.file_object.name
4444
)
4545
# generate it using pandoc
46-
self.service.convert(html, to_format, format=from_format, extra_args=extra_args)
46+
self.service.convert_text(html, to_format, format=from_format, extra_args=extra_args)
4747
# return the file which is now populated with the docx forms
4848
return self.file_object
4949

@@ -64,6 +64,6 @@ def generate(self, html, **kwargs):
6464
'-o', self.file_object.name
6565
)
6666
# generate it using pandoc
67-
self.service.convert(html, to_format, format=from_format, extra_args=extra_args)
67+
self.service.convert_text(html, to_format, format=from_format, extra_args=extra_args)
6868
# return the file which is now populated with the docx forms
6969
return self.file_object

pypandoc/__init__.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sys
99
import tempfile
1010
import textwrap
11-
import warnings
1211

1312
from .handler import _check_log_handler
1413
from .pandoc_download import DEFAULT_TARGET_FOLDER, download_pandoc
@@ -24,56 +23,6 @@
2423
# Set up the module level logger
2524
logger = logging.getLogger(__name__)
2625

27-
28-
def convert(source, to, format=None, extra_args=(), encoding='utf-8',
29-
outputfile=None, filters=None, cworkdir=None):
30-
"""Converts given `source` from `format` to `to` (deprecated).
31-
32-
:param str source: Unicode string or bytes or a file path (see encoding)
33-
34-
:param str to: format into which the input should be converted; can be one of
35-
`pypandoc.get_pandoc_formats()[1]`
36-
37-
:param str format: the format of the inputs; will be inferred if input is a file with an
38-
known filename extension; can be one of `pypandoc.get_pandoc_formats()[1]`
39-
(Default value = None)
40-
41-
:param list extra_args: extra arguments (list of strings) to be passed to pandoc
42-
(Default value = ())
43-
44-
:param str encoding: the encoding of the file or the input bytes (Default value = 'utf-8')
45-
46-
:param str outputfile: output will be written to outfilename or the converted content
47-
returned if None (Default value = None)
48-
49-
:param list filters: pandoc filters e.g. filters=['pandoc-citeproc']
50-
51-
:returns: converted string (unicode) or an empty string if an outputfile was given
52-
:rtype: unicode
53-
54-
:raises RuntimeError: if any of the inputs are not valid of if pandoc fails with an error
55-
:raises OSError: if pandoc is not found; make sure it has been installed and is available at
56-
path.
57-
"""
58-
msg = ("Due to possible ambiguity, 'convert()' is deprecated and will be removed in pypandoc 1.8. "
59-
"Use 'convert_file()' or 'convert_text()'.")
60-
warnings.warn(msg, DeprecationWarning, stacklevel=2)
61-
62-
path = _identify_path(source)
63-
if path:
64-
format = _identify_format_from_path(source, format)
65-
input_type = 'path'
66-
else:
67-
source = _as_unicode(source, encoding)
68-
input_type = 'string'
69-
if not format:
70-
raise RuntimeError("Format missing, but need one (identified source as text as no "
71-
"file with that name was found).")
72-
return _convert_input(source, format, input_type, to, extra_args=extra_args,
73-
outputfile=outputfile, filters=filters,
74-
cworkdir=cworkdir)
75-
76-
7726
def convert_text(source, to, format, extra_args=(), encoding='utf-8',
7827
outputfile=None, filters=None, verify_format=True,
7928
sandbox=True, cworkdir=None):
@@ -690,7 +639,6 @@ def _ensure_pandoc_path():
690639
def ensure_pandoc_installed(url=None,
691640
targetfolder=None,
692641
version="latest",
693-
quiet=None,
694642
delete_installer=False):
695643
"""Try to install pandoc if it isn't installed.
696644
@@ -699,11 +647,6 @@ def ensure_pandoc_installed(url=None,
699647
:raises OSError: if pandoc cannot be installed
700648
"""
701649

702-
if quiet is not None:
703-
msg = ("The quiet flag in PyPandoc has been deprecated in favour of "
704-
"logging. See README.md for more information.")
705-
warnings.warn(msg, DeprecationWarning, stacklevel=2)
706-
707650
# Append targetfolder to the PATH environment variable so it is found by subprocesses
708651
if targetfolder is not None:
709652
os.environ["PATH"] = os.environ.get("PATH", "") + os.pathsep + os.path.abspath(os.path.expanduser(targetfolder))

pypandoc/pandoc_download.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import subprocess
1010
import sys
1111
import tempfile
12-
import warnings
1312

1413
try:
1514
from urllib.request import urlopen
@@ -193,7 +192,6 @@ def _handle_win32(filename, targetfolder):
193192
def download_pandoc(url=None,
194193
targetfolder=None,
195194
version="latest",
196-
quiet=None,
197195
delete_installer=False,
198196
download_folder=None):
199197
"""Download and unpack pandoc
@@ -214,11 +212,6 @@ def download_pandoc(url=None,
214212
to the target folder. If no `download_folder` is given, uses the current directory. example: `/tmp/`, `/tmp`
215213
"""
216214

217-
if quiet is not None:
218-
msg = ("The quiet flag in PyPandoc has been deprecated in favour of "
219-
"logging. See README.md for more information.")
220-
warnings.warn(msg, DeprecationWarning, stacklevel=2)
221-
222215
_check_log_handler()
223216

224217
pf = sys.platform

tests.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,6 @@ def test_convert_text_with_existing_file(self):
468468
received = pypandoc.convert_file(file_name, 'rst', format='md')
469469
self.assertTrue("title" in received)
470470

471-
def test_depreaction_warnings(self):
472-
# convert itself is deprecated...
473-
with assert_produces_warning(DeprecationWarning):
474-
pypandoc.convert('# some title\n', to='rst', format='md')
475-
476471
def create_sample_lua(self):
477472
args = [pypandoc.get_pandoc_path(), '--print-default-data-file', 'sample.lua']
478473
p = subprocess.Popen(args, stdout=subprocess.PIPE)

0 commit comments

Comments
 (0)