cc-4105: added docstrings, formatted code
This commit is contained in:
parent
1f422a9609
commit
e9114b3468
|
@ -8,8 +8,7 @@ import media.monitor.pure as mmp
|
|||
|
||||
class MMConfig(object):
|
||||
def __init__(self, path):
|
||||
if not os.path.exists(path):
|
||||
raise NoConfigFile(path)
|
||||
if not os.path.exists(path): raise NoConfigFile(path)
|
||||
self.cfg = ConfigObj(path)
|
||||
|
||||
def __getitem__(self, key):
|
||||
|
@ -29,6 +28,10 @@ class MMConfig(object):
|
|||
def save(self): self.cfg.write()
|
||||
|
||||
def last_ran(self):
|
||||
"""
|
||||
Returns the last time media monitor was ran by looking at the time when
|
||||
the file at 'index_path' was modified
|
||||
"""
|
||||
return mmp.last_modified(self.cfg['index_path'])
|
||||
|
||||
# Remove this after debugging...
|
||||
|
|
|
@ -110,8 +110,7 @@ class Metadata(Loggable):
|
|||
"""
|
||||
Writes 'md' metadata into 'path' through mutagen
|
||||
"""
|
||||
if not os.path.exists(path):
|
||||
raise BadSongFile(path)
|
||||
if not os.path.exists(path): raise BadSongFile(path)
|
||||
song_file = mutagen.File(path, easy=True)
|
||||
for airtime_k, airtime_v in md.iteritems():
|
||||
if airtime_k in airtime2mutagen:
|
||||
|
@ -120,7 +119,6 @@ class Metadata(Loggable):
|
|||
song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v)
|
||||
song_file.save()
|
||||
|
||||
|
||||
def __init__(self, fpath):
|
||||
# Forcing the unicode through
|
||||
try: fpath = fpath.decode("utf-8")
|
||||
|
|
|
@ -17,6 +17,9 @@ supported_extensions = [u"mp3", u"ogg", u"oga"]
|
|||
#supported_extensions = [u"mp3", u"ogg", u"oga", u"flac", u"aac", u"bwf"]
|
||||
unicode_unknown = u'unknown'
|
||||
|
||||
path_md = ['MDATA_KEY_TITLE', 'MDATA_KEY_CREATOR', 'MDATA_KEY_SOURCE',
|
||||
'MDATA_KEY_TRACKNUMBER', 'MDATA_KEY_BITRATE']
|
||||
|
||||
class LazyProperty(object):
|
||||
"""
|
||||
meant to be used for lazy evaluation of an object attribute.
|
||||
|
@ -223,8 +226,6 @@ def normalized_metadata(md, original_path):
|
|||
'MDATA_KEY_MIME' : lambda x: x.replace('-','/'),
|
||||
'MDATA_KEY_BPM' : lambda x: x[0:8],
|
||||
}
|
||||
path_md = ['MDATA_KEY_TITLE', 'MDATA_KEY_CREATOR', 'MDATA_KEY_SOURCE',
|
||||
'MDATA_KEY_TRACKNUMBER', 'MDATA_KEY_BITRATE']
|
||||
# note that we could have saved a bit of code by rewriting new_md using
|
||||
# defaultdict(lambda x: "unknown"). But it seems to be too implicit and
|
||||
# could possibly lead to subtle bugs down the road. Plus the following
|
||||
|
|
|
@ -122,6 +122,8 @@ def main(global_config, api_client_config, log_config,
|
|||
|
||||
# Launch the toucher that updates the last time when the script was
|
||||
# ran every n seconds.
|
||||
# TODO : verify that this does not interfere with bootstrapping because the
|
||||
# toucher thread might update the last_ran variable too fast
|
||||
tt = ToucherThread(path=config['index_path'],
|
||||
interval=int(config['touch_interval']))
|
||||
|
||||
|
|
Loading…
Reference in New Issue