[mythtv-commits] [MythTV/mythtv] db387c: Remove python2 imports, cleanup additional code

rcrdnalor noreply at github.com
Mon Dec 20 18:41:09 UTC 2021


  Branch: refs/heads/master
  Home:   https://github.com/MythTV/mythtv
  Commit: db387c5fa8e387046844c3e6f8aee7d68a5be9a8
      https://github.com/MythTV/mythtv/commit/db387c5fa8e387046844c3e6f8aee7d68a5be9a8
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/connections.py
    M mythtv/bindings/python/MythTV/dataheap.py
    M mythtv/bindings/python/MythTV/logging.py
    M mythtv/bindings/python/MythTV/methodheap.py
    M mythtv/bindings/python/MythTV/mythproto.py
    M mythtv/bindings/python/MythTV/utility/dequebuffer.py
    M mythtv/bindings/python/MythTV/utility/other.py

  Log Message:
  -----------
  Remove python2 imports, cleanup additional code

necessary that support python2 imports from MythTV's python bindings.

Starting from master (i.e.: v32_pre), MythTV's python bindings will
only support python3.6 and higher versions.

This commit removes code necessary to support python2.

Refs #422


  Commit: 772d982735ae792775adba6becd8991071261dd8
      https://github.com/MythTV/mythtv/commit/772d982735ae792775adba6becd8991071261dd8
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/utility/dt.py
    M mythtv/bindings/python/MythTV/utility/enum.py

  Log Message:
  -----------
  Use python3 syntax for metaclasses

and remove compatibility layer 'python-future'.
Not needed, because we do not support python2 anymore.

Refs #422


  Commit: 411f7a3be353cfbb9b5e8a21cce302e640f0e972
      https://github.com/MythTV/mythtv/commit/411f7a3be353cfbb9b5e8a21cce302e640f0e972
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    R mythtv/bindings/python/MythTV/_conn_oursql.py
    M mythtv/bindings/python/MythTV/connections.py

  Log Message:
  -----------
  Remove python oursql connector, not maintained anymore

In regard to oursql, there are still a view packages (1) for python3
and the documentation (2) states compatibility to python3.
The git location has a branch for python3:
https://github.com/python-oursql/oursql/tree/py3k,
which is not up to date (last change 2016).

Once, this project is active again, we can easily re-enable
the oursql connector.

(1) pypi:oursql3 https://pypi.org/project/oursql3/
    arch linux: python-oursql 0.9.5-1, last maintained 2018
    to fix python3.7 compatibility, based on a fork at
    https://github.com/cinatic/python-oursql

(2) https://pythonhosted.org/oursql/

Refs #422


  Commit: d4cf2273f514560e36bb79f34346c584e0f61b84
      https://github.com/MythTV/mythtv/commit/d4cf2273f514560e36bb79f34346c584e0f61b84
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/utility/dt.py

  Log Message:
  -----------
  Use datetime.timestamp from the parent class,

instead of providing an own implementation.

Note: Python3 supports datetime.timestamp out of the box.

Refs #422


  Commit: fb1f828a474bdac2b1943a8fac28a8b5f3b2ea82
      https://github.com/MythTV/mythtv/commit/fb1f828a474bdac2b1943a8fac28a8b5f3b2ea82
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/utility/enum.py

  Log Message:
  -----------
  Deprecate the classes 'Enum' and 'BitwiseEnum' from

Mythtv.utility.enum.py.

Since python3, these classes are fully compatible to the class
'IntEnum' from the module enum in python3.

Use this statement: 'from enum import IntEnum' instead.
See https://docs.python.org/3/library/enum.html for
various ways to initialize an enum as well.

After the release of MythTV v32, the whole file utility/enum.py will
be deleted.

Refs #422


  Commit: 0dec07dddee3998c1a12a445b9de6c9b88c92c94
      https://github.com/MythTV/mythtv/commit/0dec07dddee3998c1a12a445b9de6c9b88c92c94
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/utility/altdict.py

  Log Message:
  -----------
  Fix and deprecate the classes in Mythtv.utility.altdict.py

The classes 'DictInvert' and 'DictInvertCI' from this module will be
removed after MythTV v32 release, use the imports
'from MythTV.altdict import DictInvert, DictInvertCI.", instead.

The class 'OrdDict' from the module 'Mythtv.utility.altdict' will be
removed after MythTV v32 release, use the class 'OrderedDict' from
the module 'collections' provided by python3.

Note: MythTV provides the class 'OrdDict' already in the module
MythTV.altdict. There is no need to duplicate or shadow the same
functionality.

Refs #422


  Commit: 9f10ea066e8fe55feb2d16ec527b7e58d2cc301b
      https://github.com/MythTV/mythtv/commit/9f10ea066e8fe55feb2d16ec527b7e58d2cc301b
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/database.py
    M mythtv/bindings/python/MythTV/dataheap.py
    M mythtv/bindings/python/MythTV/system.py

  Log Message:
  -----------
  Replace deprecated 'lxml' methods

The python module 'lxml' lists the deprecated methods in
https://lxml.de/api/deprecated-index.html

Replace all occurences of
 - 'node.getchildren()' with 'list(node)'
 - 'node.getiterator(x)' with 'list(node.iter(x))'

Refs #422


  Commit: 9a956a55f0cdf70a44b14ffef7d89ee49f99e55f
      https://github.com/MythTV/mythtv/commit/9a956a55f0cdf70a44b14ffef7d89ee49f99e55f
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/altdict.py
    M mythtv/bindings/python/MythTV/database.py

  Log Message:
  -----------
  Modernize class OrdDict from MythTV.altdict.py

Dictionaries are ordered since Python 3.6 and PEP 468 (Preserving
the order of **kwargs in a function.) is in place.
This means, that there is no need to service the accompanying list
called '_field_order' in a special way. I is simmply the list(keys()).

Note: This commit follows the python3 habit, that dict.keys(),
dict.values() and dict.items() are view objects:
View objects are dynamic and reflect dict change.
To make these view objects static, one have to convert this view objects
to a list, like 'list(dict.values())'.

Changed view objects to list objects accordingly in the MythTV module.

Legacy implementations for iterkeys(), itervalues(), iteritems() are
provided.

Refs #422


  Commit: b9ba89da2d98e16de34516cec3a9114a0e3f0721
      https://github.com/MythTV/mythtv/commit/b9ba89da2d98e16de34516cec3a9114a0e3f0721
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/utility/altdict.py

  Log Message:
  -----------
  Harmonize classes altdict.py with utility.altdict.py

Albeit the classes provided by MythTV.utility.altdict are marked as
deprecated, they must follow the changes done in MythTV.altdict.
Otherwise, we have two implementations of the same class with different
meanings.

Refs #422


  Commit: 4c50f593b452f2063ad9d072cdfa56ddcc04eb50
      https://github.com/MythTV/mythtv/commit/4c50f593b452f2063ad9d072cdfa56ddcc04eb50
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/altdict.py
    M mythtv/bindings/python/MythTV/database.py

  Log Message:
  -----------
  Use python3 methods to iterate over dictionary

Replace 'self.iteritems()' with 'iter(self.items()' on classes derived
from 'OrdDict'.

The former method, like 'itervalues()' and 'iterkeys()' are legacy
implementations.

Refs #422


  Commit: d24ae4a921a6c029bcc909773844ebe16f7a543a
      https://github.com/MythTV/mythtv/commit/d24ae4a921a6c029bcc909773844ebe16f7a543a
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/database.py
    M mythtv/bindings/python/MythTV/dataheap.py
    M mythtv/bindings/python/MythTV/mythproto.py
    M mythtv/bindings/python/MythTV/system.py
    M mythtv/bindings/python/MythTV/utility/__init__.py
    M mythtv/bindings/python/MythTV/utility/other.py

  Log Message:
  -----------
  Simplify 'str' and 'repr' methods for python3

Remove 'py23_repr(x)', because it returns 'x' for python3.
Rename method 'py23_str' to 'py3_str' and remove support for python2.

Refs #422


  Commit: 3e17c842b7d81bbeeaccfc848896fc0c72bea29f
      https://github.com/MythTV/mythtv/commit/3e17c842b7d81bbeeaccfc848896fc0c72bea29f
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/ttvdb/tvdbXslt.py
    M mythtv/bindings/python/MythTV/ttvdb/tvdb_api.py
    M mythtv/programs/scripts/metadata/Television/ttvdb.py

  Log Message:
  -----------
  TV Grabber ttvdb.py: remove python2 support

Changed shebang of executeable, removed code for python2.

Refs #422


  Commit: e43361f8053238959a71a5f9a625d4f9f90a7ddc
      https://github.com/MythTV/mythtv/commit/e43361f8053238959a71a5f9a625d4f9f90a7ddc
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/tvmaze/artwork.py
    M mythtv/bindings/python/tvmaze/embed.py
    M mythtv/bindings/python/tvmaze/endpoints.py
    M mythtv/bindings/python/tvmaze/episode.py
    M mythtv/bindings/python/tvmaze/locales.py
    M mythtv/bindings/python/tvmaze/person.py
    M mythtv/bindings/python/tvmaze/season.py
    M mythtv/bindings/python/tvmaze/show.py
    M mythtv/bindings/python/tvmaze/tvmaze_api.py
    M mythtv/bindings/python/tvmaze/utils.py
    M mythtv/programs/scripts/metadata/Television/tvmaze.py

  Log Message:
  -----------
  TV Grabber tvmaze.py: remove python2 support

Removed import of unicode_literals and code for python2.

Refs #422


  Commit: 0654387e92de10c52aac04493c7d32cd709eb93a
      https://github.com/MythTV/mythtv/commit/0654387e92de10c52aac04493c7d32cd709eb93a
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/ttvdbv4/utils.py
    M mythtv/programs/scripts/metadata/Television/ttvdb4.py

  Log Message:
  -----------
  TV Grabber ttvdb4.py: remove python2 support

Removed imports and additional code for python2.

Refs #422


  Commit: 3757cfe0eff074b6448c8891fd07d368d10831c6
      https://github.com/MythTV/mythtv/commit/3757cfe0eff074b6448c8891fd07d368d10831c6
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/tmdb3/tmdb3/__init__.py
    M mythtv/bindings/python/tmdb3/tmdb3/cache_engine.py
    M mythtv/bindings/python/tmdb3/tmdb3/lookup.py
    M mythtv/bindings/python/tmdb3/tmdb3/pager.py
    M mythtv/bindings/python/tmdb3/tmdb3/request.py
    M mythtv/bindings/python/tmdb3/tmdb3/tmdb_api.py
    M mythtv/bindings/python/tmdb3/tmdb3/util.py
    M mythtv/programs/scripts/metadata/Movie/tmdb3.py
    M mythtv/programs/scripts/metadata/Television/tmdb3tv.py

  Log Message:
  -----------
  Movie/TV Grabber tmdb3.py: remove python2 support

Cleanup imports and additional code for python2.
Removed python2/3 compatibility layer for metaclasses.
Removed 'tmdb3_repr(x)', because it returns 'x' for python3.
Set shebang to python3 on executeble scripts

Refs #422


  Commit: 61d2e5d84e181b921a2e1daba982c62a2b518101
      https://github.com/MythTV/mythtv/commit/61d2e5d84e181b921a2e1daba982c62a2b518101
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/services_api/utilities.py

  Log Message:
  -----------
  Python Bindings: services_api: remove python2 support

Cleanup imports and additional code for python2.

Refs #422


  Commit: d81f1c25d40385391116ccd957f903a6844e4854
      https://github.com/MythTV/mythtv/commit/d81f1c25d40385391116ccd957f903a6844e4854
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/programs/scripts/metadata/Music/lyrics/common/utilities.py
    M mythtv/programs/scripts/metadata/Music/lyrics/darklyrics.py
    M mythtv/programs/scripts/metadata/Music/lyrics/embedlrc.py
    M mythtv/programs/scripts/metadata/Music/lyrics/filelyrics.py
    M mythtv/programs/scripts/metadata/Music/lyrics/genius.py
    M mythtv/programs/scripts/metadata/Music/lyrics/lyricscom.py
    M mythtv/programs/scripts/metadata/Music/lyrics/lyricswiki.py
    M mythtv/programs/scripts/metadata/Music/lyrics/ttplayer.py
    M mythtv/programs/scripts/metadata/Music/mbutils.py

  Log Message:
  -----------
  MythMusic python grabbers: Remove python3 support

Cleanup imports and additional code for python2.
Fixed lyrics script 'darklyrics.py':
http request: provide required headers and cookie

Please note, that only a subset of the lyrics scripts are functional:
See #427 for details.

Refs #422


  Commit: 14f66a5cc5a42d787d91e521b367ffab25f5ffe7
      https://github.com/MythTV/mythtv/commit/14f66a5cc5a42d787d91e521b367ffab25f5ffe7
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/ttvdb/tvdbXslt.py
    M mythtv/programs/scripts/metadata/Music/lyrics/darklyrics.py
    M mythtv/programs/scripts/metadata/Music/lyrics/genius.py
    M mythtv/programs/scripts/metadata/Music/lyrics/gomaudio.py
    M mythtv/programs/scripts/metadata/Music/lyrics/lyricsmode.py
    M mythtv/programs/scripts/metadata/Music/lyrics/ttplayer.py
    M mythtv/programs/scripts/metadata/Television/ttvdb.py

  Log Message:
  -----------
  Fix DeprecationWarning: invalid escape sequence

on regex strings

>From python 3.7+ docs: (*)
Regular expressions use the backslash character ('\') to indicate
special forms or to allow special characters to be used without
invoking their special meaning. This collides with Python’s usage
of the same character for the same purpose in string literals; for
example, to match a literal backslash, one might have to write '\\\\'
as the pattern string, because the regular expression must be \\,
and each backslash must be expressed as \\ inside a regular Python
string literal. Also, please note that any invalid escape sequences
in Python’s usage of the backslash in string literals now generate a
DeprecationWarning and in the future this will become a SyntaxError.
This behaviour will happen even if it is a valid escape sequence for
a regular expression.

The solution is to use Python’s raw string notation for regular
expression patterns; backslashes are not handled in any special
way in a string literal prefixed with 'r'.
So r"\n" is a two-character string containing '\' and 'n', while "\n"
is a one-character string containing a newline. Usually patterns
will be expressed in Python code using this raw string notation.

Conclusion:
Mark regex strings as 'raw' where necessary.
Note: The 'ru' or 'ur' prefix for strings is not allowed in python3.

(*) https://docs.python.org/dev/library/re.html

Refs #422


  Commit: 37ce0f457735ebc741442ddf86230b1b80055a6e
      https://github.com/MythTV/mythtv/commit/37ce0f457735ebc741442ddf86230b1b80055a6e
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/services_api/send.py
    M mythtv/programs/scripts/metadata/Television/ttvdb.py

  Log Message:
  -----------
  Python: Remove imports from '__future__'

where necessary or possible.

For now, python3 does not use any features from 'future'.
This was only needed for python2 compatibility.

Refs #422


  Commit: 5bc71a41b2ba37466677dad0d2c7331402e7182d
      https://github.com/MythTV/mythtv/commit/5bc71a41b2ba37466677dad0d2c7331402e7182d
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/connections.py
    M mythtv/bindings/python/MythTV/database.py
    M mythtv/bindings/python/MythTV/dataheap.py
    M mythtv/bindings/python/MythTV/mythproto.py
    M mythtv/bindings/python/MythTV/ttvdb/tvdbXslt.py
    M mythtv/bindings/python/MythTV/ttvdb/tvdb_api.py
    M mythtv/bindings/python/MythTV/wikiscripts/wikiscripts.py

  Log Message:
  -----------
  Python3: Remove usage of prefix 'u' for strings

from the MythTV bindings folder.

In python3, the prefix 'u' for strings does nothing.
And, Byte-Strings must be marked with a 'b' prefix explicitely.
This commit removes this 'u' prefix and removes remnants of
'unicode' and 'unichr' from python2.

Refs #422


  Commit: a50b81f9f2c1cc460a996fc8647e2ac5abc57be0
      https://github.com/MythTV/mythtv/commit/a50b81f9f2c1cc460a996fc8647e2ac5abc57be0
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/tmdb3/scripts/populate_locale.py
    M mythtv/bindings/python/tmdb3/tmdb3/locales.py
    M mythtv/bindings/python/tmdb3/tmdb3/lookup.py
    M mythtv/bindings/python/tmdb3/tmdb3/tmdb_api.py
    M mythtv/bindings/python/tmdb3/tmdb3/util.py
    M mythtv/programs/scripts/metadata/Movie/tmdb3.py

  Log Message:
  -----------
  Python3: Remove usage of prefix 'u' for strings in tmdb3

In python3, the prefix 'u' for strings does nothing.
And, Byte-Strings must be marked with a 'b' prefix explicitely.
This commit removes this 'u' prefix and removes remnants of
'tmdb3_repr' which is not needed anymore.

Refs #422


  Commit: 79731f88a3cc9dc01283e286e26c0c10c77c1939
      https://github.com/MythTV/mythtv/commit/79731f88a3cc9dc01283e286e26c0c10c77c1939
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/bindings/python/MythTV/utility/altdict.py
    M mythtv/bindings/python/MythTV/utility/enum.py

  Log Message:
  -----------
  Python Bindings: Only show python deprecation warnings

when asked for

The switch '-Wall' will display the deprecation warnins in MythTV's python
bindings.

Refs #422


  Commit: 7adccffebf74729c5b34718d11928110d222fbf3
      https://github.com/MythTV/mythtv/commit/7adccffebf74729c5b34718d11928110d222fbf3
  Author: Roland Ernst <rcrernst at gmail.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M mythtv/programs/scripts/metadata/Music/musicbrainzngs/musicbrainz.py
    M mythtv/programs/scripts/metadata/Music/musicbrainzngs/util.py
    M mythtv/programs/scripts/metadata/Television/ttvdb.py

  Log Message:
  -----------
  Python Bindings: convert tab to spaces

on files with mixed content.

Refs #422


Compare: https://github.com/MythTV/mythtv/compare/f40464cc4089...7adccffebf74


More information about the mythtv-commits mailing list