Skip to content

Commit

Permalink
Merge pull request #279 from MoojMidge/patch-workflows-and-pylint
Browse files Browse the repository at this point in the history
Update workflows and fix pylint complaints
  • Loading branch information
MoojMidge authored Sep 2, 2022
2 parents 529503b + d856351 commit dcd6ce2
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
run: coverage run -a resources/lib/service_entry.py &
if: always()
- name: Upload code coverage to CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
continue-on-error: true
- name: Analyze with SonarCloud
uses: SonarSource/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ disable=
too-many-return-statements,
too-many-statements,
useless-super-delegation,
consider-using-f-string,
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
git+git://github.com/ruuk/script.module.addon.signals.git@master#egg=AddonSignals
git+https://github.com/ruuk/script.module.addon.signals.git@master#egg=AddonSignals
codecov
kodi-addon-checker; python_version >= '3.5'
polib
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def notification_time(self, total_time=None):

def get_now_playing(self):
# Seems to work too fast loop whilst waiting for it to become active
result = dict()
result = {}
while not result.get('result'):
result = jsonrpc(method='Player.GetActivePlayers')
self.log('Got active player %s' % result, 2)
Expand Down
2 changes: 1 addition & 1 deletion tests/xbmcaddon.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def openSettings():
def setSetting(self, key, value):
''' A stub implementation for the xbmcaddon Addon class setSetting() method '''
if not ADDON_SETTINGS.get(self.id):
ADDON_SETTINGS[self.id] = dict()
ADDON_SETTINGS[self.id] = {}
ADDON_SETTINGS[self.id][key] = value
# NOTE: Disable actual writing as it is no longer needed for testing
# with open('tests/userdata/addon_settings.json', 'w') as fd:
Expand Down
5 changes: 3 additions & 2 deletions tests/xbmcextra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# pylint: disable=invalid-name

from __future__ import absolute_import, division, print_function, unicode_literals
import io
import os
import xml.etree.ElementTree as ET
import polib
Expand Down Expand Up @@ -74,7 +75,7 @@ def global_settings():
''' Use the global_settings file '''
import json
try:
with open('tests/userdata/global_settings.json') as f:
with io.open('tests/userdata/global_settings.json', mode='r', encoding='utf-8') as f:
settings = json.load(f)
except OSError as e:
print("Error: Cannot use 'tests/userdata/global_settings.json' : %s" % e)
Expand Down Expand Up @@ -104,7 +105,7 @@ def addon_settings():
''' Use the addon_settings file '''
import json
try:
with open('tests/userdata/addon_settings.json') as f:
with io.open('tests/userdata/addon_settings.json', mode='r', encoding='utf-8') as f:
settings = json.load(f)
except OSError as e:
print("Error: Cannot use 'tests/userdata/addon_settings.json' : %s" % e)
Expand Down
47 changes: 45 additions & 2 deletions tests/xbmcvfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,55 @@
# pylint: disable=invalid-name

from __future__ import absolute_import, division, print_function, unicode_literals
import io
import os


def File(path, flags='r'):
class File:
''' A reimplementation of the xbmcvfs File() function '''
return open(path, flags) # pylint: disable=consider-using-with
def __init__(self, path, mode=None):
if mode == 'w':
mode = 'r+b'
else:
mode = 'rb'

self._file = io.open(path, mode=mode, encoding='utf-8') # pylint: disable=consider-using-with

def __enter__(self):
return self

def __exit__(self, exc_type, exc_value, traceback):
self._file.close()

def close(self):
self._file.close()

def read(self, numbytes=None):
bytestring = self._file.read(numbytes)
return bytestring.decode('utf-8', 'ignore')

def readBytes(self, numbytes=None):
return self._file.read(numbytes)

def seek(self, seekBytes, iWhence=os.SEEK_SET):
return self._file.seek(seekBytes, iWhence)

def size(self):
current_position = self.tell()
self.seek(0, os.SEEK_END)
size = self.tell()
self.seek(current_position)
return size

def tell(self):
return self._file.tell()

def write(self, data):
try:
self._file.write(data)
return True
except (IOError, OSError, TypeError, ValueError):
return False


def Stat(path):
Expand Down

0 comments on commit dcd6ce2

Please sign in to comment.