Skip to content

Commit

Permalink
Remove dependency on the external meld3 package
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaberez committed Sep 6, 2019
1 parent dbff619 commit d09d843
Show file tree
Hide file tree
Showing 12 changed files with 3,197 additions and 24 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
4.0.5.dev0 (Next Release)
4.1.0.dev0 (Next Release)
-------------------------

- Fixed a Python 3.8 compatibility issue caused by the removal of
``cgi.escape()``. Patch by Mattia Procopio.

- The ``meld3`` package is no longer a dependency. A version of ``meld3``
is now included within the ``supervisor`` package itself.

4.0.4 (2019-07-15)
------------------

Expand Down
3 changes: 0 additions & 3 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ which is internet-connected:
- setuptools (latest) from `https://pypi.org/pypi/setuptools/
<https://pypi.org/pypi/setuptools/>`_.

- meld3 (latest) from `https://pypi.org/pypi/meld3/
<https://pypi.org/pypi/meld3/>`_.

Copy these files to removable media and put them on the target
machine. Install each onto the target machine as per its
instructions. This typically just means unpacking each file and
Expand Down
9 changes: 0 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
[easy_install]
zip_ok = false

[bdist_rpm]
;If you are building your own RPM of Supervisor, it is recommended that you
;also build your own RPM of meld3 (https://github.com/Supervisor/meld3) to
;ensure you have the most recent version. Your distribution may have a
;"python-meld3" package that you might be able substitute here, but it may
;not be compatible and may not have the most recent bug fixes.
requires =
meld3

[aliases]
dev = develop easy_install supervisor[testing]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
elif (3, 0) < py_version < (3, 4):
raise RuntimeError('On Python 3, Supervisor requires Python 3.4 or later')

requires = ['meld3 >= 1.0.0']
requires = []
tests_require = []
if py_version < (3, 3):
tests_require.append('mock')
Expand Down
47 changes: 43 additions & 4 deletions supervisor/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
long = long
raw_input = raw_input
unicode = unicode
unichr = unichr
basestring = basestring
def as_bytes(s): return s if isinstance(s, str) else s.encode('utf-8')
def as_string(s): return s if isinstance(s, unicode) else s.decode('utf-8')

def as_bytes(s, encoding='utf-8'):
if isinstance(s, str):
return s
else:
return s.encode(encoding)

def as_string(s, encoding='utf-8'):
if isinstance(s, unicode):
return s
else:
return s.decode(encoding)

def is_text_stream(stream):
try:
Expand All @@ -25,15 +36,28 @@ def is_text_stream(stream):
except ImportError:
import io
return isinstance(stream, io.TextIOWrapper)

else: # pragma: no cover
long = int
basestring = str
raw_input = input
unichr = chr

class unicode(str):
def __init__(self, string, encoding, errors):
str.__init__(self, string)
def as_bytes(s): return s if isinstance(s,bytes) else s.encode('utf8')
def as_string(s): return s if isinstance(s,str) else s.decode('utf8')

def as_bytes(s, encoding='utf8'):
if isinstance(s, bytes):
return s
else:
return s.encode(encoding)

def as_string(s, encoding='utf8'):
if isinstance(s, str):
return s
else:
return s.decode(encoding)

def is_text_stream(stream):
import _io
Expand Down Expand Up @@ -106,7 +130,22 @@ def is_text_stream(stream):
except ImportError: # pragma: no cover
import _thread as thread

try: # pragma: no cover
from types import StringTypes
except ImportError: # pragma: no cover
StringTypes = (str,)

try: # pragma: no cover
from html import escape
except ImportError: # pragma: no cover
from cgi import escape

try: # pragma: no cover
import html.entities as htmlentitydefs
except ImportError: # pragma: no cover
import htmlentitydefs

try: # pragma: no cover
from html.parser import HTMLParser
except ImportError: # pragma: no cover
from HTMLParser import HTMLParser
Loading

0 comments on commit d09d843

Please sign in to comment.