From c684552792775a5917735466a0f46c0c414967ce Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Sat, 21 Jan 2017 23:06:55 -0500 Subject: [PATCH] Started work on better documentation --- .gitignore | 18 ++++++++---------- LICENSE.txt | 2 +- docs/index.rst | 20 +++++++------------- docs/introduction.rst | 4 ++-- docs/modules.rst | 1 - docs/toc.rst | 3 ++- plexapi/compat.py | 8 +++++++- plexapi/myplex.py | 29 +++++++++-------------------- plexapi/utils.py | 1 - 9 files changed, 36 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 1f595f53..fdbcabd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,19 @@ syntax: glob *.db +*.egg-info *.log *.pyc -*.swp *.sublime-* +*.swp *__pycache__* -dist -build -*.egg-info -.idea/ -lib/ -bin/ -include/ .cache/ +.idea/ .Python +bin/ +build +dist docs/_build/ - +include/ +lib/ pip-selfcheck.json - pyvenv.cfg diff --git a/LICENSE.txt b/LICENSE.txt index ac7d518a..5b6bfae0 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -9,7 +9,7 @@ are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name conky-pkmeter nor the names of its contributors + * Neither the name python-plexapi nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/docs/index.rst b/docs/index.rst index 10ff00bd..8edd761f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,16 +1,10 @@ - -Welcome to Python PlexAPI's documentation! -========================================== - +Python PlexAPI +============== .. include:: toc.rst - .. automodule:: myplex - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` +Usage & Contributions +--------------------- +* Source is available on the `Github Project Page `_. +* Contributors to python-plexapi own their own contributions and may distribute that code under + the `BSD license `_. diff --git a/docs/introduction.rst b/docs/introduction.rst index 37fbb4d5..f5f02443 100644 --- a/docs/introduction.rst +++ b/docs/introduction.rst @@ -1,5 +1,5 @@ -PlexAPI Introduction -==================== +Introduction +============ .. |br| raw:: html diff --git a/docs/modules.rst b/docs/modules.rst index 40a0a186..f666319e 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -47,7 +47,6 @@ MyPlex (plexapi.myplex) ----------------------- .. automodule:: plexapi.myplex :members: - :undoc-members: :show-inheritance: Photo (plexapi.photo) diff --git a/docs/toc.rst b/docs/toc.rst index aa7b0455..d239ae02 100644 --- a/docs/toc.rst +++ b/docs/toc.rst @@ -1,6 +1,7 @@ .. toctree:: - :maxdepth: 1 + :maxdepth: 2 :caption: Table of Contents + self introduction modules diff --git a/plexapi/compat.py b/plexapi/compat.py index 04bb46d6..b4ac4458 100644 --- a/plexapi/compat.py +++ b/plexapi/compat.py @@ -4,6 +4,7 @@ Python 2/3 compatability Always try Py3 first """ +import sys try: from urllib.parse import urlencode @@ -20,8 +21,13 @@ try: except ImportError: from urllib import unquote - try: from configparser import ConfigParser except ImportError: from ConfigParser import ConfigParser + +try: + from xml.etree import cElementTree as ElementTree +except ImportError: + from xml.etree import ElementTree + \ No newline at end of file diff --git a/plexapi/myplex.py b/plexapi/myplex.py index 155dc3e7..61c0b3d2 100644 --- a/plexapi/myplex.py +++ b/plexapi/myplex.py @@ -1,23 +1,11 @@ # -*- coding: utf-8 -*- -import sys - -if sys.version_info <= (3, 3): - try: - from xml.etree import cElementTree as ElementTree - except ImportError: - from xml.etree import ElementTree -else: - # py 3.3 and above selects the fastest automatically - from xml.etree import ElementTree - -from requests.status_codes import _codes as codes - -import plexapi -import requests +import plexapi, requests from plexapi import TIMEOUT, log, utils from plexapi.exceptions import BadRequest, NotFound, Unauthorized from plexapi.client import PlexClient +from plexapi.compat import ElementTree from plexapi.server import PlexServer +from requests.status_codes import _codes as codes class MyPlexAccount(object): @@ -90,17 +78,18 @@ class MyPlexAccount(object): def __repr__(self): return '<%s:%s:%s>' % (self.__class__.__name__, self.id, self.username.encode('utf8')) - def devices(self): - """ Returns a list of all :class:`~myplex.MyPlexDevice` objects connected to the server. """ - return _listItems(MyPlexDevice.BASEURL, self.authenticationToken, MyPlexDevice) - def device(self, name): """ Returns the :class:`~myplex.MyPlexDevice` that matched the name specified. - * **name**: (str) Name to match against. + Attributes: + name (str): Name to match against. """ return _findItem(self.devices(), name) + def devices(self): + """ Returns a list of all :class:`~myplex.MyPlexDevice` objects connected to the server. """ + return _listItems(MyPlexDevice.BASEURL, self.authenticationToken, MyPlexDevice) + def resources(self): """Resources. diff --git a/plexapi/utils.py b/plexapi/utils.py index 8ca3ef15..684816f7 100644 --- a/plexapi/utils.py +++ b/plexapi/utils.py @@ -5,7 +5,6 @@ from datetime import datetime from plexapi.compat import quote, urlencode from plexapi.exceptions import NotFound, UnknownType, Unsupported from threading import Thread -from plexapi import log # Search Types - Plex uses these to filter specific media types when searching. SEARCHTYPES = {'movie': 1, 'show': 2, 'season': 3,