Skip to content

Commit

Permalink
pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mips2648 committed Apr 25, 2024
1 parent 2493b67 commit b8c7aa1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
15 changes: 15 additions & 0 deletions jeedomdaemon/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,47 @@ def __init__(self):
self.add_argument("--pid", help="daemon pid", type=str)

def add_argument(self, *args, **kwargs):
"""Add a, argurment to parse.
e.g. from your child class:
self.add_argument("--clientId", type=str)
self.add_argument("--intValue", type=int)
"""
return self.__parser.add_argument(*args, **kwargs)

def parse(self, args: Sequence[str] | None = None):
"""Actually parse de config, it will be done for you at daemon start."""
if self._args is None:
self._args = self.__parser.parse_args(args)

@property
def callback_url(self):
"""Return the callback url to Jeedom."""
return str(self._args.callback)

@property
def socket_host(self):
"""Return the daemon socket host."""
return str(self._args.sockethost)

@property
def socket_port(self):
"""Return the daemon socket port."""
return int(self._args.socketport)

@property
def log_level(self):
"""Return the log level."""
return str(self._args.loglevel)

@property
def api_key(self):
"""Return the api key."""
return str(self._args.apikey)

@property
def pid_filename(self):
"""Return the pid."""
return str(self._args.pid)
4 changes: 2 additions & 2 deletions jeedomdaemon/base_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def __init__(self,
Utils.init_logger(self._config.log_level)
logging.getLogger('asyncio').setLevel(logging.WARNING)

def setLoggerLoglevel(self, loggerName: str):
logging.getLogger(loggerName).setLevel(self.log_level)
def set_logger_log_level(self, logger_name: str):
logging.getLogger(logger_name).setLevel(self.log_level)

@property
def log_level(self):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# Needed for dependencies
install_requires=['aiohttp'],
# *strongly* suggested for sharing
version='0.6',
version='0.7',
# The license can be anything you like
license='MIT',
description='A base to implement Jeedom daemon in python',
# We will also need a readme eventually (there will be a warning)
# long_description=open('README.txt').read(),
)
)
16 changes: 7 additions & 9 deletions tests/base_config_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
"""Test class for base config."""

import sys
import os
import unittest

sys.path.append(os.path.realpath(os.path.dirname(__file__) + '/..'))

# now we can import the module in the parent
# directory.

import unittest

from jeedomdaemon.base_config import BaseConfig
from jeedomdaemon.base_config import BaseConfig # pylint: disable=wrong-import-position

class TestBaseConfig(unittest.TestCase):
def test_base_config_creation(self):
Expand Down Expand Up @@ -39,15 +37,15 @@ def test_custom_config_parse(self):
class TestConfig(BaseConfig):
def __init__(self):
super().__init__()
self.add_argument("--clientId", help="my client Id", type=str)
self.add_argument("--clientId", type=str)

@property
def clientId(self):
def client_id(self):
return str(self._args.clientId)

config = TestConfig()
config.parse(['--clientId', 'hfldhfsd'])
self.assertEqual(config.clientId, "hfldhfsd")
self.assertEqual(config.client_id, "hfldhfsd")



Expand Down

0 comments on commit b8c7aa1

Please sign in to comment.