本文整理汇总了Python中mopidy.frontends.mpd.translator.tracks_to_tag_cache_format函数的典型用法代码示例。如果您正苦于以下问题:Python tracks_to_tag_cache_format函数的具体用法?Python tracks_to_tag_cache_format怎么用?Python tracks_to_tag_cache_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tracks_to_tag_cache_format函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
options = parse_options()
log.setup_root_logger()
log.setup_console_logging(options.verbosity_level)
tracks = []
def store(data):
track = translator(data)
tracks.append(track)
logging.debug("Added %s", track.uri)
def debug(uri, error, debug):
logging.warning("Failed %s: %s", uri, error)
logging.debug("Debug info for %s: %s", uri, debug)
logging.info("Scanning %s", settings.LOCAL_MUSIC_PATH)
scanner = Scanner(settings.LOCAL_MUSIC_PATH, store, debug)
try:
scanner.start()
except KeyboardInterrupt:
scanner.stop()
logging.info("Done scanning; writing tag cache...")
for row in mpd_translator.tracks_to_tag_cache_format(tracks):
if len(row) == 1:
print("%s" % row).encode("utf-8")
else:
print("%s: %s" % row).encode("utf-8")
logging.info("Done writing tag cache")
开发者ID:rattboi,项目名称:mopidy,代码行数:34,代码来源:scanner.py
示例2: test_empty_tag_cache_has_song_list
def test_empty_tag_cache_has_song_list(self):
result = translator.tracks_to_tag_cache_format([])
result = self.consume_headers(result)
song_list, result = self.consume_song_list(result)
self.assertEqual(len(song_list), 0)
self.assertEqual(len(result), 0)
开发者ID:MechanisM,项目名称:mopidy,代码行数:7,代码来源:serializer_test.py
示例3: main
def main():
log.setup_root_logger()
log.setup_console_logging(2)
tracks = []
def store(data):
track = translator(data)
tracks.append(track)
logging.debug('Added %s', track.uri)
def debug(uri, error, debug):
logging.error('Failed %s: %s - %s', uri, error, debug)
logging.info('Scanning %s', settings.LOCAL_MUSIC_PATH)
scanner = Scanner(settings.LOCAL_MUSIC_PATH, store, debug)
try:
scanner.start()
except KeyboardInterrupt:
scanner.stop()
logging.info('Done')
for row in mpd_translator.tracks_to_tag_cache_format(tracks):
if len(row) == 1:
print ('%s' % row).encode('utf-8')
else:
print ('%s: %s' % row).encode('utf-8')
开发者ID:AndreaCrotti,项目名称:mopidy,代码行数:28,代码来源:scanner.py
示例4: test_tag_cache_has_song_list
def test_tag_cache_has_song_list(self):
track = Track(uri='file:///dir/subdir/song.mp3')
result = translator.tracks_to_tag_cache_format([track])
result = self.consume_headers(result)
song_list, result = self.consume_song_list(result)
self.assert_(song_list)
self.assertEqual(len(result), 0)
开发者ID:MechanisM,项目名称:mopidy,代码行数:8,代码来源:serializer_test.py
示例5: test_tag_cache_diretory_header_is_right
def test_tag_cache_diretory_header_is_right(self):
track = Track(uri='file:///dir/subdir/folder/sub/song.mp3')
result = translator.tracks_to_tag_cache_format([track])
result = self.consume_headers(result)
folder, result = self.consume_directory(result)
self.assertEqual(('directory', 'folder/sub'), folder[0])
self.assertEqual(('mtime', mtime('.')), folder[1])
self.assertEqual(('begin', 'sub'), folder[2])
开发者ID:MechanisM,项目名称:mopidy,代码行数:10,代码来源:serializer_test.py
示例6: test_tag_cache_has_formated_track_with_key_and_mtime
def test_tag_cache_has_formated_track_with_key_and_mtime(self):
track = Track(uri='file:///dir/subdir/song.mp3')
formated = self.translate(track)
result = translator.tracks_to_tag_cache_format([track])
result = self.consume_headers(result)
song_list, result = self.consume_song_list(result)
self.assertEqual(song_list, formated)
self.assertEqual(len(result), 0)
开发者ID:MechanisM,项目名称:mopidy,代码行数:10,代码来源:serializer_test.py
示例7: test_tag_cache_has_formated_track
def test_tag_cache_has_formated_track(self):
track = Track(uri='file:///dir/subdir/song.mp3')
formated = self.translate(track)
result = translator.tracks_to_tag_cache_format([track], self.media_dir)
result = self.consume_headers(result)
song_list, result = self.consume_song_list(result)
self.assertEqual(formated, song_list)
self.assertEqual(len(result), 0)
开发者ID:Halfnhav,项目名称:mopidy,代码行数:10,代码来源:translator_test.py
示例8: test_tag_cache_diretory_header_is_right
def test_tag_cache_diretory_header_is_right(self):
track = Track(uri="file:///dir/subdir/folder/sub/song.mp3")
result = translator.tracks_to_tag_cache_format([track], self.media_dir)
result = self.consume_headers(result)
dir_data, result = self.consume_directory(result)
self.assertEqual(("directory", "folder/sub"), dir_data[0])
self.assertEqual(("mtime", mtime(".")), dir_data[1])
self.assertEqual(("begin", "sub"), dir_data[2])
开发者ID:vorodev,项目名称:mopidy,代码行数:10,代码来源:translator_test.py
示例9: main
def main():
options = parse_options()
# TODO: support config files and overrides (shared from main?)
config_files = [b'/etc/mopidy/mopidy.conf',
b'$XDG_CONFIG_DIR/mopidy/mopidy.conf']
config_overrides = []
# TODO: decide if we want to avoid this boilerplate some how.
# Initial config without extensions to bootstrap logging.
logging_config, _ = config_lib.load(config_files, [], config_overrides)
log.setup_root_logger()
log.setup_console_logging(logging_config, options.verbosity_level)
extensions = ext.load_extensions()
config, errors = config_lib.load(
config_files, extensions, config_overrides)
log.setup_log_levels(config)
if not config['local']['media_dir']:
logging.warning('Config value local/media_dir is not set.')
return
# TODO: missing error checking and other default setup code.
tracks = []
def store(data):
track = translator(data)
tracks.append(track)
logging.debug('Added %s', track.uri)
def debug(uri, error, debug):
logging.warning('Failed %s: %s', uri, error)
logging.debug('Debug info for %s: %s', uri, debug)
logging.info('Scanning %s', config['local']['media_dir'])
scanner = Scanner(config['local']['media_dir'], store, debug)
try:
scanner.start()
except KeyboardInterrupt:
scanner.stop()
logging.info('Done scanning; writing tag cache...')
for row in mpd_translator.tracks_to_tag_cache_format(
tracks, config['local']['media_dir']):
if len(row) == 1:
print ('%s' % row).encode('utf-8')
else:
print ('%s: %s' % row).encode('utf-8')
logging.info('Done writing tag cache')
开发者ID:Halfnhav,项目名称:mopidy,代码行数:53,代码来源:scanner.py
示例10: test_tag_cache_suports_directories
def test_tag_cache_suports_directories(self):
track = Track(uri='file:///dir/subdir/folder/song.mp3')
formated = self.translate(track)
result = translator.tracks_to_tag_cache_format([track])
result = self.consume_headers(result)
folder, result = self.consume_directory(result)
song_list, result = self.consume_song_list(result)
self.assertEqual(len(song_list), 0)
self.assertEqual(len(result), 0)
song_list, result = self.consume_song_list(folder)
self.assertEqual(len(result), 0)
self.assertEqual(song_list, formated)
开发者ID:MechanisM,项目名称:mopidy,代码行数:14,代码来源:serializer_test.py
示例11: test_tag_cache_supports_multiple_tracks
def test_tag_cache_supports_multiple_tracks(self):
tracks = [Track(uri="file:///dir/subdir/song1.mp3"), Track(uri="file:///dir/subdir/song2.mp3")]
formated = []
formated.extend(self.translate(tracks[0]))
formated.extend(self.translate(tracks[1]))
result = translator.tracks_to_tag_cache_format(tracks, self.media_dir)
result = self.consume_headers(result)
song_list, result = self.consume_song_list(result)
self.assertEqual(formated, song_list)
self.assertEqual(len(result), 0)
开发者ID:vorodev,项目名称:mopidy,代码行数:14,代码来源:translator_test.py
示例12: test_tag_cache_supports_directories
def test_tag_cache_supports_directories(self):
track = Track(uri="file:///dir/subdir/folder/song.mp3")
formated = self.translate(track)
result = translator.tracks_to_tag_cache_format([track], self.media_dir)
result = self.consume_headers(result)
dir_data, result = self.consume_directory(result)
song_list, result = self.consume_song_list(result)
self.assertEqual(len(song_list), 0)
self.assertEqual(len(result), 0)
song_list, result = self.consume_song_list(dir_data)
self.assertEqual(len(result), 0)
self.assertEqual(formated, song_list)
开发者ID:vorodev,项目名称:mopidy,代码行数:14,代码来源:translator_test.py
示例13: commit
def commit(self):
directory, basename = os.path.split(self._tag_cache_file)
# TODO: cleanup directory/basename.* files.
tmp = tempfile.NamedTemporaryFile(
prefix=basename + '.', dir=directory, delete=False)
try:
for row in mpd_translator.tracks_to_tag_cache_format(
self._tracks.values(), self._media_dir):
if len(row) == 1:
tmp.write(('%s\n' % row).encode('utf-8'))
else:
tmp.write(('%s: %s\n' % row).encode('utf-8'))
os.rename(tmp.name, self._tag_cache_file)
finally:
if os.path.exists(tmp.name):
os.remove(tmp.name)
开发者ID:vorodev,项目名称:mopidy,代码行数:19,代码来源:library.py
示例14: test_tag_cache_supports_multiple_tracks_in_dirs
def test_tag_cache_supports_multiple_tracks_in_dirs(self):
tracks = [Track(uri="file:///dir/subdir/song1.mp3"), Track(uri="file:///dir/subdir/folder/song2.mp3")]
formated = []
formated.append(self.translate(tracks[0]))
formated.append(self.translate(tracks[1]))
result = translator.tracks_to_tag_cache_format(tracks, self.media_dir)
result = self.consume_headers(result)
dir_data, result = self.consume_directory(result)
song_list, song_result = self.consume_song_list(dir_data)
self.assertEqual(formated[1], song_list)
self.assertEqual(len(song_result), 0)
song_list, result = self.consume_song_list(result)
self.assertEqual(len(result), 0)
self.assertEqual(formated[0], song_list)
开发者ID:vorodev,项目名称:mopidy,代码行数:19,代码来源:translator_test.py
示例15: test_tag_cache_has_header
def test_tag_cache_has_header(self):
track = Track(uri='file:///dir/subdir/song.mp3')
result = translator.tracks_to_tag_cache_format([track])
result = self.consume_headers(result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:4,代码来源:serializer_test.py
示例16: test_empty_tag_cache_has_header
def test_empty_tag_cache_has_header(self):
result = translator.tracks_to_tag_cache_format([])
result = self.consume_headers(result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:3,代码来源:serializer_test.py
注:本文中的mopidy.frontends.mpd.translator.tracks_to_tag_cache_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论