Commits

Travis Shirk committed 76cd68b Merge

merge stable

Comments (0)

Files changed (15)

dev-requirements.txt

File contents unchanged.
 PROJECT = u"eyeD3"
 VERSION = "0.7.2"
 
-LICENSE     = open("COPYING", "r").read().strip('\n')
+LICENSE = open("COPYING", "r").read().strip('\n')
 DESCRIPTION = "Python audio data toolkit (ID3 and MP3)"
 LONG_DESCRIPTION = """
 eyeD3 is a Python module and command line program for processing ID3 tags.
 play time, etc.) is also provided. The formats supported are ID3
 v1.0/v1.1 and v2.3/v2.4.
 """
-URL          = "http://eyeD3.nicfit.net"
-AUTHOR       = "Travis Shirk"
+URL = "http://eyeD3.nicfit.net"
+AUTHOR = "Travis Shirk"
 AUTHOR_EMAIL = "travis@pobox.com"
 SRC_DIST_TGZ = "%s-%s.tgz" % (PROJECT, VERSION)
 SRC_DIST_ZIP = "%s.zip" % os.path.splitext(SRC_DIST_TGZ)[0]
-DOC_DIST     = "%s_docs-%s.tgz" % (PROJECT, VERSION)
-MD5_DIST     = "%s.md5" % os.path.splitext(SRC_DIST_TGZ)[0]
-DOC_BUILD_D  = "docs/_build"
+DOC_DIST = "%s_docs-%s.tgz" % (PROJECT, VERSION)
+MD5_DIST = "%s.md5" % os.path.splitext(SRC_DIST_TGZ)[0]
+DOC_BUILD_D = "docs/_build"
 
 PACKAGE_DATA = paver.setuputils.find_package_data("src/eyed3",
                                                   package="eyed3",
         url=URL,
         download_url="%s/releases/%s" % (URL, SRC_DIST_TGZ),
         license="GPL",
-        package_dir={"": "src" },
+        package_dir={"": "src"},
         packages=setuptools.find_packages("src",
                                           exclude=["test", "test.*"]),
         zip_safe=False,
     ),
 
     cog=Bunch(
-       beginspec='{{{cog',
-       endspec='}}}',
-       endoutput='{{{end}}}',
-       includedir=path(__file__).abspath().dirname(),
+        beginspec='{{{cog',
+        endspec='}}}',
+        endoutput='{{{end}}}',
+        includedir=path(__file__).abspath().dirname(),
     ),
 
     test=Bunch(
-       pdb=False,
-       coverage=False,
+        pdb=False,
+        coverage=False,
     ),
 
     release=Bunch(
     ),
 )
 
+
 @task
 @no_help
 def eyed3_info():
         target_file.write(src_data)
         target_file.close()
 
+
 @task
 @needs("eyed3_info",
        "setuptools.command.build")
     '''Build the code'''
     pass
 
+
 @task
 @needs("test_clean")
 def clean():
     except ImportError:
         pass
 
+
 @task
 def docs_clean(options):
     '''Clean docs'''
     except ImportError:
         pass
 
+
 @task
 @needs("distclean", "docs_clean")
 def maintainer_clean():
     path("paver-minilib.zip").remove()
     path("setup.py").remove()
 
+
 @task
 @needs("clean")
 def distclean():
         f.remove()
     path("src/eyed3/info.py").remove()
 
+
 @task
 @needs("cog")
 def docs(options):
     print("Docs: file://%s/%s/%s/html/index.html" %
           (os.getcwd(), options.docroot, options.builddir))
 
+
 @task
 @needs("distclean",
        "eyed3_info",
         print("Coverage Report: file://%s/build/test/coverage/index.html" %
               os.getcwd())
 
+
 @task
 def test_clean():
     '''Clean tests'''
     path("built/test/html").rmtree()
     path(".coverage").remove()
 
+
 @task
 @needs("sdist")
 def test_dist():
 
     pass
 
+
 @task
 def checklist():
     '''Show release procedure'''
 - ebuild
 """ % globals())
 
+
 @task
 @cmdopts([("test", "",
            u"Run in a mode where commits, pushes, etc. are performed"),
     resp = raw_input()
     return True if resp in ["y", "yes"] else False
 
+
 def cog_pluginHelp(name):
     from string import Template
     import argparse
     return template.substitute(substs)
 __builtins__["cog_pluginHelp"] = cog_pluginHelp
 
+
 # XXX: modified from paver.doctools._runcog to add includers
 def _runcog(options, uncog=False):
     """Common function for the cog and runcog tasks."""
         dry("cog %s" % f, c.processOneFile, f)
 
 from paver.doctools import Includer, _cogsh
+
+
 class CliExample(Includer):
     def __call__(self, fn, section=None, lang="bash"):
         # Resetting self.cog to get a string back from Includer.__call__
         raw = Includer.__call__(self, fn, section=section)
         self.cog = cog
 
-        commands = []
-
         self.cog.gen.out(u"\n.. code-block:: %s\n\n" % lang)
         for line in raw.splitlines(True):
             if line.strip() == "":
                 if output:
                     self.cog.gen.out("\n")
 
+
 @task
 def cog(options):
     '''Run cog on all docs'''

src/eyed3/id3/tag.py

             else:
                 if f.id in DATE_FIDS:
                     date_frames[f.id] = f
-        
+
         if date_frames:
             if version == ID3_V2_4:
                 if "TORY" in date_frames or "XDOR" in date_frames:
                 # Work around the local encoding not matching that of a mounted
                 # filesystem
                 log.warning(u"Mismatched file system encoding for file '%s'" %
-                            file_name)
+                            repr(file_name))
                 self.name = file_name
 
         self.tag_size = 0  # This includes the padding byte count.

src/eyed3/main.py

 import exceptions
 import os.path
 import textwrap
-import eyed3, eyed3.utils, eyed3.utils.cli, eyed3.plugins, eyed3.info
+import eyed3
+import eyed3.utils
+import eyed3.utils.cli
+import eyed3.plugins
+import eyed3.info
 
 
 DEFAULT_PLUGIN = "classic"
 
 
 def _listPlugins(config):
-    from eyed3.utils.cli import GREEN, GREY, boldText, colorText
+    from eyed3.utils.cli import GREEN, GREY, boldText
 
     print("")
 
     '''This is the main function for profiling
     http://code.google.com/appengine/kb/commontasks.html#profiling
     '''
-    import cProfile, pstats, StringIO
+    import cProfile
+    import pstats
+    import StringIO
 
     eyed3.log.debug("driver profileMain")
     prof = cProfile.Profile()
                        help="Do not load the default user config '%s'. "
                             "The -c/--config options are still honored if "
                             "present." % DEFAULT_CONFIG)
+        p.add_argument("--no-color", action="store_true", dest="no_color",
+                       help="Do not load the default user config '%s'. "
+                            "Suppress color codes in console output.")
 
         # Debugging options
         group = p.debug_arg_group
         args, _, config = parseCommandLine()
 
         for fp in [sys.stdout, sys.stderr]:
-            eyed3.utils.cli.enableColorOutput(fp, os.isatty(fp.fileno()))
+            color = not args.no_color and os.isatty(fp.fileno())
+            eyed3.utils.cli.enableColorOutput(fp, color)
 
         mainFunc = main if args.debug_profile is False else profileMain
         retval = mainFunc(args, config)

src/eyed3/plugins/__init__.py

         _PLUGINS = {}
 
     def _isValidModule(f, d):
-        '''Determin if file ``f`` is a valid module file name.'''
+        '''Determine if file ``f`` is a valid module file name.'''
         # 1) tis a file
         # 2) does not start with '_', or '.'
         # 3) avoid the .pyc dup
                     continue
 
                 mod_name = os.path.splitext(f)[0]
-                mod = __import__(mod_name, globals=globals(),
-                                 locals=locals())
+                try:
+                    mod = __import__(mod_name, globals=globals(),
+                                     locals=locals())
+                except ImportError as ex:
+                    log.warning("Plugin '%s' requires packages that are not "
+                                "installed: %s" % ((f, d), ex))
+                    continue
+                except exceptions.Exception as ex:
+                    log.exception("Bad plugin '%s'", (f, d))
+                    continue
 
                 for attr in [getattr(mod, a) for a in dir(mod)]:
                     if (type(attr) == types.TypeType and
                         PluginClass = attr
                         if (PluginClass not in list(_PLUGINS.values()) and
                                 len(PluginClass.NAMES)):
-                            log.debug("loading plugin '%s' fron '%s%s%s'",
+                            log.debug("loading plugin '%s' from '%s%s%s'",
                                       mod, d, os.path.sep, f)
                             # Setting the main name outside the loop to ensure
                             # there is at least one, otherwise a KeyError is
                             if name and name in PluginClass.NAMES:
                                 return PluginClass
 
-        except ImportError as ex:
-            log.warning("Plugin '%s' requires packages that are not "
-                        "installed: %s" % ((f, d), ex))
-            continue
-        except exceptions.Exception as ex:
-            log.exception("Bad plugin '%s'", (f, d))
-            continue
-
         finally:
             if d in sys.path:
                 sys.path.remove(d)

src/eyed3/plugins/classic.py

                 raise ValueError("too few parts")
 
             path, type_str = args[:2]
-            desc = args[2] if len(args) > 2 else u""
+            desc = unicode(args[2], LOCAL_ENCODING) if len(args) > 2 else u""
             mt = None
             try:
                 type_id = id3.frames.ImageFrame.stringToPicType(type_str)

src/eyed3/utils/__init__.py

 import os
 import re
 
+ID3_MIME_TYPE = "application/x-id3"
+ID3_MIME_TYPE_EXTENSIONS = (".id3", ".tag")
+
 import StringIO
 import mimetypes
 _mime_types = mimetypes.MimeTypes()
-_mime_types.readfp(StringIO.StringIO("application/x-id3 id3 tag"))
+_mime_types.readfp(StringIO.StringIO("%s %s" %
+                   (ID3_MIME_TYPE,
+                    " ".join((e[1:] for e in ID3_MIME_TYPE_EXTENSIONS)))))
 del mimetypes
 del StringIO
 
     mime = None
 
     if magic_func:
-        mime = magic_func(filename)
-        if mime:
-            mime = mime.split(";")[0]
+        if (os.path.splitext(filename)[1] in ID3_MIME_TYPE_EXTENSIONS):
+            # Need to check custom types manually if not using _mime_types
+            mime = ID3_MIME_TYPE
+        else:
+            mime = magic_func(filename)
+            if mime:
+                mime = mime.split(";")[0]
 
     if not mime:
         mime, enc = _mime_types.guess_type(filename, strict=False)

src/test/__init__.py

             if not s.isatty():
                 s.seek(self._seek_offset)
         sys.stdout, sys.stderr = self._orig_stdout, self._orig_stderr
+
+#if sys.version_info[1] == 6:
+

src/test/id3/test_frames.py

                        UTF_16BE_ENCODING)
 from eyed3.id3 import ID3_V1_0, ID3_V1_1, ID3_V2_2, ID3_V2_3, ID3_V2_4
 from eyed3.id3.frames import *
+from ..compat import *
+
 
 class FrameTest(unittest.TestCase):
     def testCtor(self):

src/test/id3/test_headers.py

 from eyed3.utils.binfuncs import dec2bin, bin2bytes, bin2synchsafe
 from eyed3.id3.headers import *
 from eyed3.id3 import ID3_DEFAULT_VERSION, TagException
+from ..compat import *
+
 
 class TestTagHeader(unittest.TestCase):
     def testCtor(self):

src/test/id3/test_tag.py

 from eyed3.core import Date
 from eyed3.id3 import Tag, ID3_DEFAULT_VERSION, ID3_V2_3, ID3_V2_4
 from eyed3.id3 import frames
+from ..compat import *
+
 
 def testTagImport():
     import eyed3.id3, eyed3.id3.tag

src/test/mp3/test_mp3.py

 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 ################################################################################
-import os, StringIO, unittest
+import sys
+if sys.version_info[:2] == (2, 6):
+    import unittest2 as unittest
+else:
+    import unittest
+import os
+import StringIO
 from nose.tools import *
 from .. import DATA_D
 

src/test/test__init__.py

 ################################################################################
 from nose.tools import *
 import eyed3
+from .compat import *
+
 
 def testLocale():
     assert_true(eyed3.LOCAL_ENCODING)

src/test/test_classic_plugin.py

 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 ################################################################################
-import unittest
+import sys
+if sys.version_info[:2] == (2, 6):
+    import unittest2 as unittest
+else:
+    import unittest
 import os, shutil
 from nose.tools import *
 import eyed3
 from eyed3 import main, id3, core
 from . import DATA_D, RedirectStdStreams
+from .compat import *
 
 def testPluginOption():
     for arg in ["--help", "-h"]:

src/test/test_plugins.py

 from nose.tools import *
 from eyed3.plugins import *
 from eyed3.plugins import examples, classic
+from .compat import *
+
 
 def test_load():
     plugins = load()