Skip to content

Commit

Permalink
Refactor: Add get_section to add common code for get section config
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jan 14, 2024
1 parent 4f7b95a commit c4077e0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions plextraktsync/config/PlexServerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ def asdict(self):

@property
def sync_config(self):
if self.config is None or "sync" not in self.config or self.config["sync"] is None:
return {}

return self.config["sync"]
return self.get_section("sync", {})

@property
def libraries(self):
if self.config is None or "libraries" not in self.config:
return None

return self.config["libraries"]
return self.get_section("libraries")

@property
def excluded_libraries(self):
if self.config is None or "excluded-libraries" not in self.config:
return None
return self.get_section("excluded-libraries")

def get_section(self, section: str, default=None):
if self.config is None:
return default

return self.config["excluded-libraries"]
return self.config.get(section, default)

0 comments on commit c4077e0

Please sign in to comment.