Skip to content

Commit

Permalink
Merge pull request #1731 from glensc/get-section
Browse files Browse the repository at this point in the history
Refactor: Add get_section to add common code for get section config
  • Loading branch information
glensc authored Jan 16, 2024
2 parents f361324 + c4077e0 commit 011c550
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 011c550

Please sign in to comment.