Browse Source

fix some typos...

fix getattr by checking the set attributes...

[git-p4: depot-paths = "//depot/": change = 1150]
replace/b43bf02ddeddd088c0e6b94974ca1a46562eb3db
John-Mark Gurney 17 years ago
parent
commit
c4eb909ecd
1 changed files with 22 additions and 15 deletions
  1. +22
    -15
      DIDLLite.py

+ 22
- 15
DIDLLite.py View File

@@ -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



Loading…
Cancel
Save