mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-14 13:25:11 -05:00
0d9fbc1ad7
This version of SickBeard uses both TVDB and TVRage to search and gather it's series data from allowing you to now have access to and download shows that you couldn't before because of being locked into only what TheTVDB had to offer. Also this edition is based off the code we used in our XEM editon so it does come with scene numbering support as well as all the other features our XEM edition has to offer. Please before using this with your existing database (sickbeard.db) please make a backup copy of it and delete any other database files such as cache.db and failed.db if present, we HIGHLY recommend starting out with no database files at all to make this a fresh start but the choice is at your own risk! Enjoy!
53 lines
2.4 KiB
Python
53 lines
2.4 KiB
Python
"""A collection of modules for iterating through different kinds of
|
|
tree, generating tokens identical to those produced by the tokenizer
|
|
module.
|
|
|
|
To create a tree walker for a new type of tree, you need to do
|
|
implement a tree walker object (called TreeWalker by convention) that
|
|
implements a 'serialize' method taking a tree as sole argument and
|
|
returning an iterator generating tokens.
|
|
"""
|
|
|
|
treeWalkerCache = {}
|
|
|
|
def getTreeWalker(treeType, implementation=None, **kwargs):
|
|
"""Get a TreeWalker class for various types of tree with built-in support
|
|
|
|
treeType - the name of the tree type required (case-insensitive). Supported
|
|
values are "simpletree", "dom", "etree" and "beautifulsoup"
|
|
|
|
"simpletree" - a built-in DOM-ish tree type with support for some
|
|
more pythonic idioms.
|
|
"dom" - The xml.dom.minidom DOM implementation
|
|
"pulldom" - The xml.dom.pulldom event stream
|
|
"etree" - A generic walker for tree implementations exposing an
|
|
elementtree-like interface (known to work with
|
|
ElementTree, cElementTree and lxml.etree).
|
|
"lxml" - Optimized walker for lxml.etree
|
|
"beautifulsoup" - Beautiful soup (if installed)
|
|
"genshi" - a Genshi stream
|
|
|
|
implementation - (Currently applies to the "etree" tree type only). A module
|
|
implementing the tree type e.g. xml.etree.ElementTree or
|
|
cElementTree."""
|
|
|
|
treeType = treeType.lower()
|
|
if treeType not in treeWalkerCache:
|
|
if treeType in ("dom", "pulldom", "simpletree"):
|
|
mod = __import__(treeType, globals())
|
|
treeWalkerCache[treeType] = mod.TreeWalker
|
|
elif treeType == "genshi":
|
|
import genshistream
|
|
treeWalkerCache[treeType] = genshistream.TreeWalker
|
|
elif treeType == "beautifulsoup":
|
|
import soup
|
|
treeWalkerCache[treeType] = soup.TreeWalker
|
|
elif treeType == "lxml":
|
|
import lxmletree
|
|
treeWalkerCache[treeType] = lxmletree.TreeWalker
|
|
elif treeType == "etree":
|
|
import etree
|
|
# XXX: NEVER cache here, caching is done in the etree submodule
|
|
return etree.getETreeModule(implementation, **kwargs).TreeWalker
|
|
return treeWalkerCache.get(treeType)
|