diff -Nru python-libguess-1.1/debian/changelog python-libguess-1.1/debian/changelog --- python-libguess-1.1/debian/changelog 2014-06-29 20:48:36.000000000 +0000 +++ python-libguess-1.1/debian/changelog 2019-10-13 15:36:05.000000000 +0000 @@ -1,3 +1,31 @@ +python-libguess (1.1-4) unstable; urgency=medium + + * No changes. + + -- Andrej Shadura Sun, 13 Oct 2019 17:36:05 +0200 + +python-libguess (1.1-3) unstable; urgency=medium + + * Add missing libguess1 dependency. + + -- Andrej Shadura Sun, 13 Oct 2019 17:09:51 +0200 + +python-libguess (1.1-2) unstable; urgency=medium + + [ Sandro Tosi ] + * Drop python2 support (Closes: #937887). + + [ Andrej Shadura ] + * Maintain in DPMT. + * Add Vcs-*. + * Bump debhelper from old 9 to 12. + * Run wrap-and-sort -bask. + * Use debhelper-compat instead of debian/compat. + * Update the Python 3 support patch. + * Run doctests on build. + + -- Andrej Shadura Tue, 08 Oct 2019 12:43:16 +0200 + python-libguess (1.1-1) unstable; urgency=medium * Initial release. diff -Nru python-libguess-1.1/debian/compat python-libguess-1.1/debian/compat --- python-libguess-1.1/debian/compat 2013-08-14 23:33:44.000000000 +0000 +++ python-libguess-1.1/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru python-libguess-1.1/debian/control python-libguess-1.1/debian/control --- python-libguess-1.1/debian/control 2014-06-29 20:38:07.000000000 +0000 +++ python-libguess-1.1/debian/control 2019-10-13 15:36:05.000000000 +0000 @@ -1,31 +1,26 @@ Source: python-libguess Priority: optional -Maintainer: Andrew Shadura +Maintainer: Debian Python Modules Team +Uploaders: + Andrej Shadura Build-Depends: - dh-python, - python-setuptools (>= 0.6.24), - python3-setuptools (>= 0.6.24), - python-all (>= 2.6.6-3), - python3-all, - debhelper (>= 9) + debhelper-compat (= 12), + dh-python, + libguess1, + python3-all, + python3-setuptools (>= 0.6.24) Standards-Version: 3.9.5 Section: python Homepage: https://bitbucket.org/barro/python-libguess/wiki/Home - -Package: python-libguess -Architecture: all -Depends: libguess1, ${misc:Depends}, ${python:Depends} -Provides: ${python:Provides} -Description: high-speed character set detection library (Python wrapper) - libguess employs discrete-finite automata to deduce the character set of the - input buffer. The advantage of this is that all character sets can be checked - in parallel, and quickly. - . - This package contains a Python wrapper for libguess. +Vcs-Browser: https://salsa.debian.org/debian/python-libguess +Vcs-Git: https://salsa.debian.org/debian/python-libguess.git Package: python3-libguess Architecture: all -Depends: libguess1, ${misc:Depends}, ${python3:Depends} +Depends: + libguess1, + ${misc:Depends}, + ${python3:Depends} Description: high-speed character set detection library (Python 3 wrapper) libguess employs discrete-finite automata to deduce the character set of the input buffer. The advantage of this is that all character sets can be checked diff -Nru python-libguess-1.1/debian/copyright python-libguess-1.1/debian/copyright --- python-libguess-1.1/debian/copyright 2014-06-29 20:41:12.000000000 +0000 +++ python-libguess-1.1/debian/copyright 2019-10-13 15:36:05.000000000 +0000 @@ -1,5 +1,5 @@ This package was initially debianized by Andrew Shadura -on Sub, 29 Jun 2014 22:38:41. It was downloaded from +on Sub, 29 Jun 2014 22:38:41. It was downloaded from https://pypi.python.org/pypi/python-libguess/ Upstream Authors: @@ -44,4 +44,3 @@ Copyright (C) 2014 Andrew Shadura and is licensed under the same license as the upstream project. - diff -Nru python-libguess-1.1/debian/patches/python3.diff python-libguess-1.1/debian/patches/python3.diff --- python-libguess-1.1/debian/patches/python3.diff 2014-06-29 20:45:50.000000000 +0000 +++ python-libguess-1.1/debian/patches/python3.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ ---- a/guess.py -+++ b/guess.py -@@ -75,10 +75,10 @@ - try: - _LIBRARY_NAME = "libguess.so.1" - _LIBRARY = ctypes.cdll.LoadLibrary(_LIBRARY_NAME) --except AttributeError, e: -+except AttributeError as e: - # TODO maybe support other other library types than .so? - raise RuntimeError("Could not find standard C library loader. This system is not supported.") --except OSError, e: -+except OSError as e: - raise RuntimeError("""Could not find %s. Make sure that you have libguess installed and that it is compiled as dynamic library.""" % _LIBRARY_NAME) - - -@@ -197,19 +197,19 @@ - else: - try: - fp = open(source_file, "rb") -- except IOError, e: -+ except IOError as e: - sys.stderr.write(str(e) + "\n") -- print '' -+ print('') - return 3 - - data = fp.read() - fp.close() - result = determine_encoding(data, region) - if result is None: -- print '' -+ print('') - return 4 - else: -- print result -+ print(result) - return 0 - - if __name__ == "__main__": diff -Nru python-libguess-1.1/debian/patches/python3.patch python-libguess-1.1/debian/patches/python3.patch --- python-libguess-1.1/debian/patches/python3.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-libguess-1.1/debian/patches/python3.patch 2019-10-13 15:36:05.000000000 +0000 @@ -0,0 +1,244 @@ +From: Jussi Judin +Date: 1304694368 -10800 +Subject: Python 2 and 3 compatibility. + +--- a/guess.py ++++ b/guess.py +@@ -55,32 +55,37 @@ + _VERSION = "1.1" + + # These region names are currently known while writing this wrapper library. +-_REGIONS = ( +- ('REGION_JP', "japanese"), +- ('REGION_TW', "taiwanese"), +- ('REGION_CN', "chinese"), +- ('REGION_KR', "korean"), +- ('REGION_RU', "russian"), +- ('REGION_AR', "arabic"), +- ('REGION_TR', "turkish"), +- ('REGION_GR', "greek"), +- ('REGION_HW', "hebrew"), +- ('REGION_PL', "polish"), +- ('REGION_BL', "baltic"), +- ) ++_REGIONS = map(lambda name_value: (name_value[0], name_value[1].encode()), ++ ( ++ ('REGION_JP', "japanese"), ++ ('REGION_TW', "taiwanese"), ++ ('REGION_CN', "chinese"), ++ ('REGION_KR', "korean"), ++ ('REGION_RU', "russian"), ++ ('REGION_AR', "arabic"), ++ ('REGION_TR', "turkish"), ++ ('REGION_GR', "greek"), ++ ('REGION_HW', "hebrew"), ++ ('REGION_PL', "polish"), ++ ('REGION_BL', "baltic"), ++ )) + _REGIONS_DICT = dict(_REGIONS) +-globals().update(_REGIONS) ++globals().update(_REGIONS_DICT) + + _LIBRARY_NAME = "NO-LIBRARY-USED" + try: + _LIBRARY_NAME = "libguess.so.1" + _LIBRARY = ctypes.cdll.LoadLibrary(_LIBRARY_NAME) +-except AttributeError, e: ++except AttributeError as e: + # TODO maybe support other other library types than .so? + raise RuntimeError("Could not find standard C library loader. This system is not supported.") +-except OSError, e: ++except OSError as e: + raise RuntimeError("""Could not find %s. Make sure that you have libguess installed and that it is compiled as dynamic library.""" % _LIBRARY_NAME) + ++# Python 3 ++try: unichr ++except NameError: ++ unichr = chr + + _determine_encoding = _LIBRARY.libguess_determine_encoding + _determine_encoding.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] +@@ -101,34 +106,38 @@ + text in 2 different encodings: + + >>> import guess +- >>> guess.determine_encoding(u'\u3042'.encode('euc-jp'), guess.REGION_JP) ++ >>> str(guess.determine_encoding(unichr(0x3042).encode('euc-jp'), guess.REGION_JP)) + 'EUC-JP' +- >>> guess.determine_encoding(u'\u3042'.encode('utf-8'), guess.REGION_JP) ++ >>> str(guess.determine_encoding(unichr(0x3042).encode('utf-8'), guess.REGION_JP)) + 'UTF-8' + + The output string of this function can be given directly + to iconv_open() C function and the resulting names should be + compatible with the encoding string of str.decode() function: + +- >>> encoded_value = u'\u3042'.encode('shift-jis') ++ >>> encoded_value = unichr(0x3042).encode('shift-jis') + >>> encoding = guess.determine_encoding(encoded_value, guess.REGION_JP) + >>> encoding + 'SJIS' +- >>> encoded_value.decode(encoding) +- u'\u3042' ++ >>> encoded_value.decode(encoding) == unichr(0x3042) ++ True + + In case the given region name is invalid or the underlying + libguess_determine_encoding() call fails for any other reason, + None value is returned: + +- >>> encoding = guess.determine_encoding("asdf", "UNKNOWN") ++ >>> encoding = guess.determine_encoding("asdf".encode(), "UNKNOWN".encode()) + >>> encoding is None + True + + Use REGION_* constants for region names. + """ +- str_in_string = str(in_string) +- return _determine_encoding(str_in_string, len(str_in_string), region) ++ assert(type(in_string) == bytes) ++ assert(type(region) == bytes) ++ encoding = _determine_encoding(in_string, len(in_string), region) ++ if encoding is None: ++ return None ++ return str(encoding.decode()) + + + _validate_utf8 = _LIBRARY.libguess_validate_utf8 +@@ -149,16 +158,72 @@ + for example functions in glib. + + >>> import guess +- >>> guess.validate_utf8(u'\u3042'.encode('EUC-JP')) ++ >>> guess.validate_utf8(unichr(0x3042).encode('EUC-JP')) + False +- >>> guess.validate_utf8(u'\u3042'.encode('UTF-8')) ++ >>> guess.validate_utf8(unichr(0x3042).encode('UTF-8')) + True + """ +- str_in_string = str(in_string) +- return bool(_validate_utf8(str_in_string, len(str_in_string))) ++ assert(type(in_string) == bytes) ++ return bool(_validate_utf8(in_string, len(in_string))) ++ + ++def _main(argv=sys.argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): ++ """ ++ First replace standard streams with our own factories. ++ ++ >>> try: ++ ... # Python 2 ++ ... import StringIO ++ ... ioread = StringIO.StringIO ++ ... iowrite = StringIO.StringIO ++ ... except ImportError: ++ ... # Python 3 ++ ... import io ++ ... ioread = io.BytesIO ++ ... iowrite = io.StringIO ++ ++ Use region code: ++ ++ >>> argv = ["guess", "REGION_JP"] ++ >>> stdin = ioread("asdf".encode()) ++ >>> stdout = iowrite() ++ >>> stderr = iowrite() ++ >>> _main(argv, stdin, stdout, stderr) ++ 0 ++ >>> stdout.getvalue() ++ 'UTF-8\\n' ++ ++ Use Region name: ++ ++ >>> argv = ["guess", "japanese"] ++ >>> stdin = ioread("asdf".encode()) ++ >>> stdout = iowrite() ++ >>> _main(argv, stdin, stdout, stderr) ++ 0 ++ >>> stdout.getvalue() ++ 'UTF-8\\n' ++ ++ Unknown region should result just a newline: ++ ++ >>> argv = ["guess", "UNKNOWN"] ++ >>> stdin = ioread("asdf".encode()) ++ >>> stdout = iowrite() ++ >>> _main(argv, stdin, stdout, stderr) ++ 4 ++ >>> stdout.getvalue() ++ '\\n' ++ ++ Forget to give a region name: ++ ++ >>> argv = ["guess"] ++ >>> stdin = ioread("asdf".encode()) ++ >>> stdout = iowrite() ++ >>> _main(argv, stdin, stdout, stderr) ++ Traceback (most recent call last): ++ ... ++ SystemExit: 2 ++ """ + +-def _main(argv=sys.argv): + usage = """python -m guess REGION [INPUT_FILE] + + If input file name is not given, this program reads from the standard input. +@@ -173,7 +238,7 @@ + 3 - file could not be opened. + 4 - invalid region name was given.""" + parser = optparse.OptionParser(usage=usage, +- version=(u'%%prog %s' % _VERSION)) ++ version=('%%prog %s' % _VERSION)) + args = parser.parse_args(argv[1:])[1] + + if len(args) < 1: +@@ -186,30 +251,41 @@ + + # Do not do any checks for region name validity, as underlying + # libguess might enable more regions that are not listed here. +- region = _REGIONS_DICT.get(args[0], args[0]) ++ region_str = args[0] ++ if region_str in _REGIONS_DICT: ++ region = _REGIONS_DICT[region_str] ++ else: ++ region = region_str.encode() + + source_file = "-" + if len(args) == 2: + source_file = args[1] + + if source_file == "-": +- fp = sys.stdin ++ fp = stdin + else: + try: + fp = open(source_file, "rb") +- except IOError, e: +- sys.stderr.write(str(e) + "\n") +- print '' ++ except IOError as e: ++ stderr.write(str(e) + "\n") ++ stdout.write('\n') + return 3 + +- data = fp.read() ++ # Read raw byte data. ++ if hasattr(fp, 'buffer'): ++ # Python 3 ++ data = fp.buffer.read() ++ else: ++ # Python 2 ++ data = fp.read() + fp.close() + result = determine_encoding(data, region) + if result is None: +- print '' ++ stdout.write('\n') + return 4 + else: +- print result ++ stdout.write(result) ++ stdout.write('\n') + return 0 + + if __name__ == "__main__": diff -Nru python-libguess-1.1/debian/patches/series python-libguess-1.1/debian/patches/series --- python-libguess-1.1/debian/patches/series 2014-06-29 20:45:55.000000000 +0000 +++ python-libguess-1.1/debian/patches/series 2019-10-13 15:36:05.000000000 +0000 @@ -1 +1 @@ -python3.diff +python3.patch diff -Nru python-libguess-1.1/debian/rules python-libguess-1.1/debian/rules --- python-libguess-1.1/debian/rules 2014-06-29 20:47:45.000000000 +0000 +++ python-libguess-1.1/debian/rules 2019-10-13 15:36:05.000000000 +0000 @@ -1,7 +1,10 @@ #!/usr/bin/make -f -export PYBUILD_DESTDIR_python2=debian/python-libguess/ export PYBUILD_DESTDIR_python3=debian/python3-libguess/ %: - dh $@ --with python2,python3 --buildsystem=pybuild + dh $@ --with python3 --buildsystem=pybuild + +override_dh_auto_test: + dh_auto_test + python3 -m doctest -v guess.py