|
|
@@ -13,23 +13,23 @@ class Resource(object): |
|
|
|
"""An object representing a resource.""" |
|
|
|
|
|
|
|
validattrs = { |
|
|
|
'protocolinfo' 'protocolInfo', |
|
|
|
'importuri' 'importUri', |
|
|
|
'size' 'size', |
|
|
|
'duration' 'duration', |
|
|
|
'prtection' 'protection, |
|
|
|
'bitrate' 'bitrate', |
|
|
|
'protocolinfo': 'protocolInfo', |
|
|
|
'importuri': 'importUri', |
|
|
|
'size': 'size', |
|
|
|
'duration': 'duration', |
|
|
|
'protection': 'protection', |
|
|
|
'bitrate': 'bitrate', |
|
|
|
'bitspersample': 'bitsPerSample', |
|
|
|
'samplefrequency': 'sampleFrequence', |
|
|
|
'nraudiochannels': 'nrAudioChannels', |
|
|
|
'resolution' 'resolution', |
|
|
|
'colordepth' 'colorDepth', |
|
|
|
'tspec' 'tspec', |
|
|
|
'alloweduse' 'allowedUse', |
|
|
|
'resolution': 'resolution', |
|
|
|
'colordepth': 'colorDepth', |
|
|
|
'tspec': 'tspec', |
|
|
|
'alloweduse': 'allowedUse', |
|
|
|
'validitystart': 'validityStart', |
|
|
|
'validityend' 'validityEnd', |
|
|
|
'validityend': 'validityEnd', |
|
|
|
'remainingtime': 'remainingTime', |
|
|
|
'usageinfo' 'usageInfo', |
|
|
|
'usageinfo': 'usageInfo', |
|
|
|
'rightsinfouri': 'rightsInfoURI', |
|
|
|
'contentinfouri': 'contentInfoURI', |
|
|
|
'recordquality': 'recordQuality', |
|
|
@@ -44,16 +44,23 @@ class Resource(object): |
|
|
|
|
|
|
|
self.protocolInfo = protocolInfo |
|
|
|
|
|
|
|
def __getattr__(self, key): |
|
|
|
try: |
|
|
|
return self.attrs[key.lower()] |
|
|
|
except KeyError: |
|
|
|
raise AttributeError, key |
|
|
|
|
|
|
|
def __setattr__(self, key, value): |
|
|
|
key = key.tolower() |
|
|
|
self.attrs[self.validattrs[key]] = value |
|
|
|
key = key.lower() |
|
|
|
assert key in self.validattrs |
|
|
|
self.attrs[key] = value |
|
|
|
|
|
|
|
def toElement(self): |
|
|
|
root = Element('res') |
|
|
|
root.text = self.data |
|
|
|
|
|
|
|
for i in self.attrs: |
|
|
|
root.attrib[i] = str(self.attrs[i]) |
|
|
|
root.attrib[self.validattrs[i]] = str(self.attrs[i]) |
|
|
|
|
|
|
|
return root |
|
|
|
|
|
|
|