Change factory.config to property
MODIFY
plextraktsync/cli.py
plextraktsync/cli.py
from plextraktsync.commands.self_update import enable_self_update
from plextraktsync.factory import factory
-CONFIG = factory.config()
+CONFIG = factory.config
def command():

MODIFY
plextraktsync/commands/bug_report.py
plextraktsync/commands/bug_report.py
@@ -9,7 +9,7 @@ def bug_url():
from plextraktsync.factory import factory
from plextraktsync.util.versions import (pts_version, py_platform,
py_version)
- config = factory.config()
+ config = factory.config
q = urlencode({
'os': py_platform(),

MODIFY
plextraktsync/commands/config.py
plextraktsync/commands/config.py
def config(print=print):
from plextraktsync.factory import factory
- config = factory.config()
+ config = factory.config
print(f"# Config File: {config.config_yml}")
config.dump(print=print)

MODIFY
plextraktsync/commands/info.py
plextraktsync/commands/info.py
@@ -20,7 +20,7 @@ def info(print=logger.info):
print(f"Config Dir: {config_dir}")
print(f"Log Dir: {log_dir}")
- config = factory.config()
+ config = factory.config
print(f"Log File: {config.log_file}")
print(f"Cache File: {config.cache_path}.sqlite")
print(f"Config File: {config.config_yml}")

MODIFY
plextraktsync/commands/plex_login.py
plextraktsync/commands/plex_login.py
"If you have 2 Factor Authentication enabled on Plex "
"you can append the code to your password below (eg. passwordCODE)"
)
-CONFIG = factory.config()
+CONFIG = factory.config
style = get_style(

MODIFY
plextraktsync/commands/trakt_login.py
plextraktsync/commands/trakt_login.py
@@ -44,7 +44,7 @@ def has_trakt_token():
if not exists(pytrakt_file):
return False
- CONFIG = factory.config()
+ CONFIG = factory.config
return CONFIG["TRAKT_USERNAME"] is not None
@@ -64,7 +64,7 @@ def login():
trakt_authenticate(api)
user = api.me.username
- CONFIG = factory.config()
+ CONFIG = factory.config
CONFIG["TRAKT_USERNAME"] = user
CONFIG.save()

MODIFY
plextraktsync/config/ServerConfig.py
plextraktsync/config/ServerConfig.py
@@ -38,7 +38,7 @@ def load(self):
def migrate(self):
from plextraktsync.factory import factory
- config = factory.config()
+ config = factory.config
self.add_server(
name="default",
urls=[

MODIFY
plextraktsync/factory.py
plextraktsync/factory.py
@@ -46,7 +46,7 @@ def plex_server(self):
def server_config(self):
from plextraktsync.config.ServerConfig import ServerConfig
- config = self.config()
+ config = self.config
run_config = self.run_config
server_config = ServerConfig()
server_name = run_config.server
@@ -62,7 +62,7 @@ def server_config(self):
def session(self):
from requests_cache import CachedSession
- config = self.config()
+ config = self.config
session = CachedSession(config.cache_path)
return session
@@ -71,7 +71,7 @@ def session(self):
def sync(self):
from plextraktsync.sync import Sync
- config = self.config()
+ config = self.config
plex = self.plex_api
trakt = self.trakt_api
@@ -144,7 +144,7 @@ def watch_state_updater(self):
plex=self.plex_api,
trakt=self.trakt_api,
mf=self.media_factory,
- config=self.config(),
+ config=self.config,
)
@cached_property
@@ -153,7 +153,7 @@ def logging(self):
from plextraktsync.logging import initialize
- config = self.config()
+ config = self.config
initialize(config)
return logging
@@ -161,7 +161,7 @@ def logging(self):
@cached_property
def logger(self):
logger = self.logging.getLogger("PlexTraktSync")
- config = self.config()
+ config = self.config
from plextraktsync.logger.filter import LoggerFilter
logger.addFilter(LoggerFilter(config["logging"]["filter"], logger))
@@ -175,7 +175,7 @@ def console_logger(self):
from plextraktsync.console import console
from plextraktsync.rich_addons import RichHighlighter
- config = self.config()
+ config = self.config
handler = RichHandler(
console=console,
show_time=config.log_console_time,
@@ -186,7 +186,7 @@ def console_logger(self):
return handler
- @memoize
+ @cached_property
def config(self):
from plextraktsync.config import Config

MODIFY
plextraktsync/plex_api.py
plextraktsync/plex_api.py
@@ -43,10 +43,10 @@ def provider(self):
x = x.replace("themoviedb", "tmdb")
x = x.replace("thetvdb", "tvdb")
if x == "xbmcnfo":
- CONFIG = factory.config()
+ CONFIG = factory.config
x = CONFIG["xbmc-providers"][self.media_type]
if x == "xbmcnfotv":
- CONFIG = factory.config()
+ CONFIG = factory.config
x = CONFIG["xbmc-providers"]["shows"]
return x
@@ -580,7 +580,7 @@ def updated_at(self):
@nocache
@flatten_dict
def library_sections(self) -> Dict[int, PlexLibrarySection]:
- CONFIG = factory.config()
+ CONFIG = factory.config
for section in self.plex.library.sections():
if section.title in CONFIG["excluded-libraries"]:
continue
@@ -693,7 +693,7 @@ def get_sessions(self):
@nocache
def _plex_account(self):
- CONFIG = factory.config()
+ CONFIG = factory.config
plex_owner_token = CONFIG.get("PLEX_OWNER_TOKEN")
plex_account_token = CONFIG.get("PLEX_ACCOUNT_TOKEN")
plex_username = CONFIG.get("PLEX_USERNAME")

MODIFY
plextraktsync/plex_server.py
plextraktsync/plex_server.py
@@ -21,7 +21,7 @@ def timeout(self):
@property
def config(self):
- return self.factory.config()
+ return self.factory.config
@property
def session(self):

MODIFY
tests/conftest.py
tests/conftest.py
factory = Factory()
# Patch config to use separate config for tests
-config = factory.config()
+config = factory.config
config.config_file = join_path(TESTS_DIR, "config.json")
config.env_file = join_path(TESTS_DIR, ".env")

MODIFY
tests/test_config.py
tests/test_config.py
def test_config_merge():
- config = factory.config()
+ config = factory.config
override = {"root": {"key1": "value1"}}
config.merge(override, config)
@@ -38,7 +38,7 @@ def test_sync_config():
def test_config():
- config = factory.config()
+ config = factory.config
config.save()
config.initialized = False

Change factory.config to property