/usr/lib/pypy/dist-packages/mutagen/_tools/mutagen_pony.py is in pypy-mutagen 1.36-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | # -*- coding: utf-8 -*-
# Copyright 2005 Joe Wreschnig, Michael Urman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
import os
import sys
import traceback
from mutagen._senf import print_, argv
from ._util import SignalHandler
class Report(object):
def __init__(self, pathname):
self.name = pathname
self.files = 0
self.unsync = 0
self.missings = 0
self.errors = []
self.exceptions = {}
self.versions = {}
def missing(self, filename):
self.missings += 1
self.files += 1
def error(self, filename):
Ex, value, trace = sys.exc_info()
self.exceptions.setdefault(Ex, 0)
self.exceptions[Ex] += 1
self.errors.append((filename, Ex, value, trace))
self.files += 1
def success(self, id3):
self.versions.setdefault(id3.version, 0)
self.versions[id3.version] += 1
self.files += 1
if id3.f_unsynch:
self.unsync += 1
def __str__(self):
strings = ["-- Report for %s --" % self.name]
if self.files == 0:
return strings[0] + "\n" + "No MP3 files found.\n"
good = self.files - len(self.errors)
strings.append("Loaded %d/%d files (%d%%)" % (
good, self.files, (float(good) / self.files) * 100))
strings.append("%d files with unsynchronized frames." % self.unsync)
strings.append("%d files without tags." % self.missings)
strings.append("\nID3 Versions:")
items = list(self.versions.items())
items.sort()
for v, i in items:
strings.append(" %s\t%d" % (".".join(map(str, v)), i))
if self.exceptions:
strings.append("\nExceptions:")
items = list(self.exceptions.items())
items.sort()
for Ex, i in items:
strings.append(" %-20s\t%d" % (Ex.__name__, i))
if self.errors:
strings.append("\nERRORS:\n")
for filename, Ex, value, trace in self.errors:
strings.append("\nReading %s:" % filename)
strings.append(
"".join(traceback.format_exception(Ex, value, trace)[1:]))
else:
strings.append("\nNo errors!")
return("\n".join(strings))
def check_dir(path):
from mutagen.mp3 import MP3
rep = Report(path)
print_(u"Scanning", path)
for path, dirs, files in os.walk(path):
files.sort()
for fn in files:
if not fn.lower().endswith('.mp3'):
continue
ffn = os.path.join(path, fn)
try:
mp3 = MP3(ffn)
except Exception:
rep.error(ffn)
else:
if mp3.tags is None:
rep.missing(ffn)
else:
rep.success(mp3.tags)
print_(str(rep))
def main(argv):
if len(argv) == 1:
print_(u"Usage:", argv[0], u"directory ...")
else:
for path in argv[1:]:
check_dir(path)
def entry_point():
SignalHandler().init()
return main(argv)
|