From 76c0cb55a1d2e34a548e14291617670b480b2a94 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Wed, 8 Feb 2017 23:08:25 -0500 Subject: [PATCH] Rename variable to kwargs --- plexapi/audio.py | 12 ++++++------ plexapi/base.py | 14 +++++++------- plexapi/library.py | 8 ++++---- plexapi/photo.py | 4 ++-- plexapi/video.py | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/plexapi/audio.py b/plexapi/audio.py index 2e5ae5cb..5245bcd8 100644 --- a/plexapi/audio.py +++ b/plexapi/audio.py @@ -103,10 +103,10 @@ class Artist(Audio): key = '%s/children' % self.key return self.fetchItem(key, title=title) - def albums(self, **attrs): + def albums(self, **kwargs): """ Returns a list of :class:`~plexapi.audio.Album` objects by this artist. """ key = '%s/children' % self.key - return self.fetchItems(key, **attrs) + return self.fetchItems(key, **kwargs) def track(self, title): """ Returns the :class:`~plexapi.audio.Track` that matches the specified title. @@ -117,10 +117,10 @@ class Artist(Audio): key = '%s/allLeaves' % self.key return self.fetchItem(key, title=title) - def tracks(self, **attrs): + def tracks(self, **kwargs): """ Returns a list of :class:`~plexapi.audio.Track` objects by this artist. """ key = '%s/allLeaves' % self.key - return self.fetchItems(key, **attrs) + return self.fetchItems(key, **kwargs) def get(self, title): """ Alias of :func:`~plexapi.audio.Artist.track`. """ @@ -192,10 +192,10 @@ class Album(Audio): key = '%s/children' % self.key return self.fetchItem(key, title=title) - def tracks(self, **attrs): + def tracks(self, **kwargs): """ Returns a list of :class:`~plexapi.audio.Track` objects in this album. """ key = '%s/children' % self.key - return self.fetchItems(key, **attrs) + return self.fetchItems(key, **kwargs) def get(self, title): """ Alias of :func:`~plexapi.audio.Album.track`. """ diff --git a/plexapi/base.py b/plexapi/base.py index 27c7ee4c..1e674a1a 100644 --- a/plexapi/base.py +++ b/plexapi/base.py @@ -73,31 +73,31 @@ class PlexObject(object): items.append(self._buildItemOrNone(elem, cls, initpath, bytag)) return [item for item in items if item] - def fetchItem(self, key, cls=None, bytag=False, tag=None, **attrs): + def fetchItem(self, key, cls=None, bytag=False, tag=None, **kwargs): """ Load the specified key to find and build the first item with the specified tag and attrs. If no tag or attrs are specified then the first item in the result set is returned. """ for elem in self._root._query(key): - if tag and elem.tag != tag or not self._checkAttrs(elem, **attrs): + if tag and elem.tag != tag or not self._checkAttrs(elem, **kwargs): continue return self._buildItem(elem, cls, key, bytag) - raise NotFound('Unable to find elem: tag=%s, attrs=%s' % (tag, attrs)) + raise NotFound('Unable to find elem: tag=%s, attrs=%s' % (tag, kwargs)) - def fetchItems(self, key, cls=None, bytag=False, tag=None, **attrs): + def fetchItems(self, key, cls=None, bytag=False, tag=None, **kwargs): """ Load the specified key to find and build all items with the specified tag and attrs. """ items = [] for elem in self._root._query(key): - if tag and elem.tag != tag or not self._checkAttrs(elem, **attrs): + if tag and elem.tag != tag or not self._checkAttrs(elem, **kwargs): continue items.append(self._buildItemOrNone(elem, cls, key, bytag)) return [item for item in items if item] - def _checkAttrs(self, elem, **attrs): + def _checkAttrs(self, elem, **kwargs): # TODO: Implement opterations - if not all(elem.attrib.get(a,'').lower() == str(v).lower() for a,v in attrs.items()): + if not all(elem.attrib.get(a,'').lower() == str(v).lower() for a,v in kwargs.items()): return False return True diff --git a/plexapi/library.py b/plexapi/library.py index 867bf318..6827adbf 100644 --- a/plexapi/library.py +++ b/plexapi/library.py @@ -72,11 +72,11 @@ class Library(PlexObject): self.sections() return self._sectionsByID[sectionID] - def all(self, **attrs): + def all(self, **kwargs): """ Returns a list of all media from all library sections. This may be a very large dataset to retrieve. """ - return [item for section in self.sections() for item in section.all(**attrs)] + return [item for section in self.sections() for item in section.all(**kwargs)] def onDeck(self): """ Returns a list of all media items on deck. """ @@ -197,10 +197,10 @@ class LibrarySection(PlexObject): key = '/library/sections/%s/all' % self.key return self.fetchItem(key, title=title) - def all(self, **attrs): + def all(self, **kwargs): """ Returns a list of media from this library section. """ key = '/library/sections/%s/all' % self.key - return self.fetchItems(key, **attrs) + return self.fetchItems(key, **kwargs) def onDeck(self): """ Returns a list of media items on deck from this library section. """ diff --git a/plexapi/photo.py b/plexapi/photo.py index 0be83ff8..ad04eddb 100644 --- a/plexapi/photo.py +++ b/plexapi/photo.py @@ -48,10 +48,10 @@ class Photoalbum(PlexPartialObject): self.type = data.attrib.get('type') self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) - def photos(self, **attrs): + def photos(self, **kwargs): """ Returns a list of :class:`~plexapi.photo.Photo` objects in this album. """ key = '/library/metadata/%s/children' % self.ratingKey - return self.fetchItems(key, **attrs) + return self.fetchItems(key, **kwargs) def photo(self, title): """ Returns the :class:`~plexapi.photo.Photo` that matches the specified title. """ diff --git a/plexapi/video.py b/plexapi/video.py index 75c913b7..29ac21c2 100644 --- a/plexapi/video.py +++ b/plexapi/video.py @@ -175,10 +175,10 @@ class Show(Video): def isWatched(self): return bool(self.viewedLeafCount == self.leafCount) - def seasons(self, **attrs): + def seasons(self, **kwargs): """Returns a list of Season.""" key = '/library/metadata/%s/children' % self.ratingKey - return self.fetchItems(key, type=Season.TYPE, **attrs) + return self.fetchItems(key, type=Season.TYPE, **kwargs) def season(self, title=None): """ Returns the season with the specified title or number. @@ -191,10 +191,10 @@ class Show(Video): key = '/library/metadata/%s/children' % self.ratingKey return self.fetchItem(key, tag='Directory', title=title) - def episodes(self, **attrs): + def episodes(self, **kwargs): """ Returs a list of Episode """ key = '/library/metadata/%s/allLeaves' % self.ratingKey - return self.fetchItems(key, **attrs) + return self.fetchItems(key, **kwargs) def episode(self, title=None, season=None, episode=None): """Find a episode using a title or season and episode. @@ -300,10 +300,10 @@ class Season(Video): """Returns season number.""" return self.index - def episodes(self, **attrs): + def episodes(self, **kwargs): """ Returs a list of Episode. """ key = '/library/metadata/%s/children' % self.ratingKey - return self.fetchItems(key, type=Episode.TYPE, **attrs) + return self.fetchItems(key, type=Episode.TYPE, **kwargs) def episode(self, title=None, num=None): """ Returns the episode with the given title or number.