project: add Project._split_paragraph().
authorW. Trevor King <wking@tremily.us>
Thu, 25 Oct 2012 21:53:28 +0000 (17:53 -0400)
committerW. Trevor King <wking@tremily.us>
Wed, 2 Jan 2013 00:40:35 +0000 (19:40 -0500)
The python3 branch splits on double-newlines, but we need to stick to
single newlines here because Python 2.x's ConfigParser drops blank
lines.

update_copyright/project.py

index fc988d50a57a7a75934d649a1682464ab8222976..4a5ac04ea8fdedcc86018afc6bcd430e57586465 100644 (file)
@@ -99,17 +99,23 @@ class Project (object):
             else:
                 raise NotImplementedError('vcs: {}'.format(vcs))
 
             else:
                 raise NotImplementedError('vcs: {}'.format(vcs))
 
-    def _load_copyright_conf(self, parser):
+    def _load_copyright_conf(self, parser, encoding=None):
+        if encoding is None:
+            encoding = self._encoding or _utils.ENCODING
         try:
         try:
-            self._copyright = parser.get('copyright', 'long').splitlines()
+            self._copyright = self._split_paragraphs(
+                unicode(parser.get('copyright', 'long'), encoding))
         except _configparser.NoOptionError:
             pass
         try:
         except _configparser.NoOptionError:
             pass
         try:
-            self._short_copyright = parser.get(
-                'copyright', 'short').splitlines()
+            self._short_copyright = self._split_paragraphs(
+                unicode(parser.get('copyright', 'short'), encoding))
         except _configparser.NoOptionError:
             pass
 
         except _configparser.NoOptionError:
             pass
 
+    def _split_paragraphs(self, text):
+        return [p.strip() for p in text.split(u'\n')]
+
     def _load_files_conf(self, parser):
         try:
             self.with_authors = parser.getboolean('files', 'authors')
     def _load_files_conf(self, parser):
         try:
             self.with_authors = parser.getboolean('files', 'authors')