MCPcopy
hub / github.com/iBaa/PlexConnect / getKey

Method getKey

XMLConverter.py:652–693  ·  view source on GitHub ↗
(self, src, srcXML, param)

Source from the content-addressed store, hash-verified

650 return [param, leftover]
651
652 def getKey(self, src, srcXML, param):
653 attrib, leftover = self.getParam(src, param)
654 default, leftover = self.getParam(src, leftover)
655
656 el, srcXML, attrib = self.getBase(src, srcXML, attrib)
657
658 # walk the path if neccessary
659 while '/' in attrib and el!=None:
660 parts = attrib.split('/',1)
661 if parts[0].startswith('#') and attrib[1:] in self.variables: # internal variable in path
662 el = el.find(self.variables[parts[0][1:]])
663 elif parts[0].startswith('$'): # setting
664 el = el.find(g_ATVSettings.getSetting(self.ATV_udid, parts[0][1:]))
665 elif parts[0].startswith('%'): # PMS property
666 el = el.find(PlexAPI.getPMSProperty(self.ATV_udid, self.PMS_uuid, parts[0][1:]))
667 else:
668 el = el.find(parts[0])
669 attrib = parts[1]
670
671 # check element and get attribute
672 if attrib.startswith('#') and attrib[1:] in self.variables: # internal variable
673 res = self.variables[attrib[1:]]
674 dfltd = False
675 elif attrib.startswith('$'): # setting
676 res = g_ATVSettings.getSetting(self.ATV_udid, attrib[1:])
677 dfltd = False
678 elif attrib.startswith('%'): # PMS property
679 res = PlexAPI.getPMSProperty(self.ATV_udid, self.PMS_uuid, attrib[1:])
680 dfltd = False
681 elif attrib.startswith('^') and attrib[1:] in self.options: # aTV property, http request options
682 res = self.options[attrib[1:]]
683 dfltd = False
684 elif el!=None and attrib in el.attrib:
685 res = el.get(attrib)
686 dfltd = False
687
688 else: # path/attribute not found
689 res = default
690 dfltd = True
691
692 dprint(__name__, 2, "CCmds_getKey: {0},{1},{2}", res, leftover,dfltd)
693 return [res,leftover,dfltd]
694
695 def getElement(self, src, srcXML, param):
696 tag, leftover = self.getParam(src, param)

Callers 15

TREE_COPYMethod · 0.80
TREE_COPY_PLAYLISTMethod · 0.80
TREE_CUTMethod · 0.80
TREE_ADDXMLMethod · 0.80
TREE_VARMethod · 0.80
TREE_MEDIABADGESMethod · 0.80
ATTRIB_VALMethod · 0.80
ATTRIB_VAL_QUOTEDMethod · 0.80
ATTRIB_ADDPATHMethod · 0.80
ATTRIB_IMAGEURLMethod · 0.80
ATTRIB_MUSICURLMethod · 0.80
ATTRIB_URLMethod · 0.80

Calls 4

getParamMethod · 0.95
getBaseMethod · 0.95
dprintFunction · 0.85
getSettingMethod · 0.45

Tested by

no test coverage detected