cc-4105: cleaned up pure.py

This commit is contained in:
Rudi Grinberg 2012-08-14 15:40:10 -04:00
parent 26afdd8851
commit d3e6c57372
2 changed files with 39 additions and 41 deletions

View File

@ -23,21 +23,21 @@ list of supported easy tags in mutagen version 1.20
"""
airtime2mutagen = {
"MDATA_KEY_TITLE": "title",
"MDATA_KEY_CREATOR": "artist",
"MDATA_KEY_SOURCE": "album",
"MDATA_KEY_GENRE": "genre",
"MDATA_KEY_MOOD": "mood",
"MDATA_KEY_TRACKNUMBER": "tracknumber",
"MDATA_KEY_BPM": "bpm",
"MDATA_KEY_LABEL": "organization",
"MDATA_KEY_COMPOSER": "composer",
"MDATA_KEY_ENCODER": "encodedby",
"MDATA_KEY_CONDUCTOR": "conductor",
"MDATA_KEY_YEAR": "date",
"MDATA_KEY_URL": "website",
"MDATA_KEY_ISRC": "isrc",
"MDATA_KEY_COPYRIGHT": "copyright",
"MDATA_KEY_TITLE" : "title",
"MDATA_KEY_CREATOR" : "artist",
"MDATA_KEY_SOURCE" : "album",
"MDATA_KEY_GENRE" : "genre",
"MDATA_KEY_MOOD" : "mood",
"MDATA_KEY_TRACKNUMBER" : "tracknumber",
"MDATA_KEY_BPM" : "bpm",
"MDATA_KEY_LABEL" : "organization",
"MDATA_KEY_COMPOSER" : "composer",
"MDATA_KEY_ENCODER" : "encodedby",
"MDATA_KEY_CONDUCTOR" : "conductor",
"MDATA_KEY_YEAR" : "date",
"MDATA_KEY_URL" : "website",
"MDATA_KEY_ISRC" : "isrc",
"MDATA_KEY_COPYRIGHT" : "copyright",
}
# Some airtime attributes are special because they must use the mutagen object

View File

@ -221,8 +221,6 @@ def normalized_metadata(md, original_path):
# byproduct of formatting the track number to 2 digits.
'MDATA_KEY_TRACKNUMBER' : parse_int,
'MDATA_KEY_BITRATE' : lambda x: str(int(x) / 1000) + "kbps",
# note: you don't actually need the lambda here. It's only used for
# clarity
'MDATA_KEY_FILEPATH' : lambda x: os.path.normpath(x),
'MDATA_KEY_MIME' : lambda x: x.replace('-','/'),
'MDATA_KEY_BPM' : lambda x: x[0:8],
@ -294,7 +292,7 @@ def organized_path(old_path, root_path, normal_md):
def file_md5(path,max_length=100):
"""
Get md5 of file path (if it exists). Use only max_length characters to save
time and memory
time and memory. Pass max_length=-1 to read the whole file (like in mm1)
"""
if os.path.exists(path):
with open(path, 'rb') as f:
@ -389,8 +387,8 @@ def create_dir(path):
if it fails at this task.
"""
if not os.path.exists(path):
try: os.makedirs(path)
except Exception as e: raise FailedToCreateDir(path, e)
try : os.makedirs(path)
except Exception as e : raise FailedToCreateDir(path, e)
else: # if no error occurs we still need to check that dir exists
if not os.path.exists: raise FailedToCreateDir(path)