Update exception handling to use `except X as Y` syntax.
[update-copyright.git] / update_copyright / project.py
index f9a70e141359587a4c3be3c1e5973857caf6df81..2a2c33aad078e1e5ef55eedb75e2b0358b6d8794 100644 (file)
@@ -1,20 +1,19 @@
-# Copyright (C) 2012 W. Trevor King
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
 #
 # This file is part of update-copyright.
 #
 #
 # This file is part of update-copyright.
 #
-# update-copyright is free software: you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# update-copyright is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
 #
 #
-# update-copyright is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
+# update-copyright is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
 #
 #
-# You should have received a copy of the GNU General Public License
-# along with update-copyright.  If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License along with
+# update-copyright.  If not, see <http://www.gnu.org/licenses/>.
 
 """Project-specific configuration."""
 
 
 """Project-specific configuration."""
 
@@ -29,11 +28,11 @@ from . import utils as _utils
 from .vcs.git import GitBackend as _GitBackend
 try:
     from .vcs.bazaar import BazaarBackend as _BazaarBackend
 from .vcs.git import GitBackend as _GitBackend
 try:
     from .vcs.bazaar import BazaarBackend as _BazaarBackend
-except ImportError, _bazaar_import_error:
+except ImportError as _bazaar_import_error:
     _BazaarBackend = None
 try:
     from .vcs.mercurial import MercurialBackend as _MercurialBackend
     _BazaarBackend = None
 try:
     from .vcs.mercurial import MercurialBackend as _MercurialBackend
-except ImportError, _mercurial_import_error:
+except ImportError as _mercurial_import_error:
     _MercurialBackend = None
 
 
     _MercurialBackend = None
 
 
@@ -60,12 +59,13 @@ class Project (object):
 
     def load_config(self, stream):
         parser = _configparser.RawConfigParser()
 
     def load_config(self, stream):
         parser = _configparser.RawConfigParser()
+        parser.optionxform = str
         parser.readfp(stream)
         for section in parser.sections():
             clean_section = section.replace('-', '_')
             try:
                 loader = getattr(self, '_load_{}_conf'.format(clean_section))
         parser.readfp(stream)
         for section in parser.sections():
             clean_section = section.replace('-', '_')
             try:
                 loader = getattr(self, '_load_{}_conf'.format(clean_section))
-            except AttributeError, e:
+            except AttributeError as e:
                 _LOG.error('invalid {} section'.format(section))
                 raise
             loader(parser=parser)
                 _LOG.error('invalid {} section'.format(section))
                 raise
             loader(parser=parser)
@@ -124,7 +124,7 @@ class Project (object):
         except _configparser.NoOptionError:
             pass
         else:
         except _configparser.NoOptionError:
             pass
         else:
-            self._ignored_paths = [pth.strip() for pth in ignored.split(',')]
+            self._ignored_paths = [pth.strip() for pth in ignored.split('|')]
         try:
             pyfile = parser.get('files', 'pyfile')
         except _configparser.NoOptionError:
         try:
             pyfile = parser.get('files', 'pyfile')
         except _configparser.NoOptionError:
@@ -139,7 +139,7 @@ class Project (object):
         for path in parser.options('author-hacks'):
             authors = parser.get('author-hacks', path)
             author_hacks[tuple(path.split('/'))] = set(
         for path in parser.options('author-hacks'):
             authors = parser.get('author-hacks', path)
             author_hacks[tuple(path.split('/'))] = set(
-                unicode(a.strip(), encoding) for a in authors.split(','))
+                unicode(a.strip(), encoding) for a in authors.split('|'))
         self._author_hacks = author_hacks
         if self._vcs is not None:
             self._vcs._author_hacks = self._author_hacks
         self._author_hacks = author_hacks
         if self._vcs is not None:
             self._vcs._author_hacks = self._author_hacks
@@ -159,8 +159,9 @@ class Project (object):
         aliases = {}
         for author in parser.options('aliases'):
             _aliases = parser.get('aliases', author)
         aliases = {}
         for author in parser.options('aliases'):
             _aliases = parser.get('aliases', author)
+            author = unicode(author, encoding)
             aliases[author] = set(
             aliases[author] = set(
-                unicode(a.strip(), encoding) for a in _aliases.split(','))
+                unicode(a.strip(), encoding) for a in _aliases.split('|'))
         self._aliases = aliases
         if self._vcs is not None:
             self._vcs._aliases = self._aliases
         self._aliases = aliases
         if self._vcs is not None:
             self._vcs._aliases = self._aliases