Make the code Python 3 only

This commit is contained in:
Roman Miroshnychenko 2020-04-03 12:55:27 +03:00
parent b6b2c5e1eb
commit 04da3801c2
3 changed files with 6 additions and 19 deletions

2
.gitignore vendored
View File

@ -9,7 +9,9 @@ __pycache__/
# Distribution / packaging # Distribution / packaging
.Python .Python
.env
env/ env/
.venv/
venv/ venv/
venv2/ venv2/
build/ build/

View File

@ -4,8 +4,7 @@ version="2.4.0"
name="Example Kodi Video Plugin" name="Example Kodi Video Plugin"
provider-name="Roman_V_M"> provider-name="Roman_V_M">
<requires> <requires>
<import addon="xbmc.python" version="2.25.0"/> <import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.future" />
</requires> </requires>
<extension point="xbmc.python.pluginsource" library="main.py"> <extension point="xbmc.python.pluginsource" library="main.py">
<provides>video</provides> <provides>video</provides>

20
main.py
View File

@ -1,24 +1,10 @@
# -*- coding: utf-8 -*- # Module: main
# Module: default
# Author: Roman V. M. # Author: Roman V. M.
# Created on: 28.11.2014 # Created on: 28.11.2014
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html # License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
""" """
Example video plugin that is compatible with both Python 2 and 3 Example video plugin that is compatible with Kodi 19.x "Matrix" and above
Compatibility features are provided by ``script.module.future`` library addon.
""" """
# Enable unicode strings by default as in Python 3
from __future__ import unicode_literals
# Monkey-patch standard libary names to enable Python 3-like behavior
from future import standard_library
standard_library.install_aliases()
from future.utils import iterkeys
# The above strings provide compatibility layer for Python 2
# so the code can work in both versions.
# In Python 3 they do nothing and can be safely removed.
# Normal imports for your addon:
import sys import sys
from urllib.parse import urlencode, parse_qsl from urllib.parse import urlencode, parse_qsl
import xbmcgui import xbmcgui
@ -99,7 +85,7 @@ def get_categories():
:return: The list of video categories :return: The list of video categories
:rtype: types.GeneratorType :rtype: types.GeneratorType
""" """
return iterkeys(VIDEOS) return VIDEOS.keys()
def get_videos(category): def get_videos(category):