[Python-modules-commits] [logilab-common] 01/06: Import logilab-common_1.2.1.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Sat Jun 11 17:40:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository logilab-common.

commit c666ec192ac72b74fb0ddf9c9e4050ca3bd6fc71
Author: Sandro Tosi <morph at debian.org>
Date:   Sat Jun 11 18:34:45 2016 +0100

    Import logilab-common_1.2.1.orig.tar.gz
---
 PKG-INFO                         |  2 +-
 __pkginfo__.py                   | 13 ++++----
 logilab/common/changelog.py      | 65 +++++++++++++++++++++++-----------------
 logilab/common/date.py           |  2 +-
 logilab/common/registry.py       |  3 +-
 logilab_common.egg-info/PKG-INFO |  2 +-
 test/unittest_changelog.py       | 15 +++++-----
 test/unittest_date.py            |  7 ++++-
 8 files changed, 64 insertions(+), 45 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 3299e17..16aeabc 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: logilab-common
-Version: 1.2.0
+Version: 1.2.1
 Summary: collection of low-level Python packages and modules used by Logilab projects
 Home-page: http://www.logilab.org/project/logilab-common
 Author: Logilab
diff --git a/__pkginfo__.py b/__pkginfo__.py
index b91f0ac..5d8621c 100644
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -25,7 +25,7 @@ modname = 'common'
 subpackage_of = 'logilab'
 subpackage_master = True
 
-numversion = (1, 2, 0)
+numversion = (1, 2, 1)
 version = '.'.join([str(num) for num in numversion])
 
 license = 'LGPL' # 2.1 or later
@@ -41,10 +41,13 @@ scripts = [join('bin', 'pytest')]
 include_dirs = [join('test', 'data')]
 
 install_requires = [
-        'setuptools',
-        'six >= 1.4.0',
-        ]
-tests_require = ['pytz']
+    'setuptools',
+    'six >= 1.4.0',
+]
+tests_require = [
+    'pytz',
+    'egenix-mx-base',
+]
 
 if sys.version_info < (2, 7):
     install_requires.append('unittest2 >= 0.5.1')
diff --git a/logilab/common/changelog.py b/logilab/common/changelog.py
index 2fff2ed..3f62bd4 100644
--- a/logilab/common/changelog.py
+++ b/logilab/common/changelog.py
@@ -3,18 +3,18 @@
 #
 # This file is part of logilab-common.
 #
-# logilab-common is free software: you can redistribute it and/or modify it under
+# logilab-common is free software: you can redistribute it or modify it under
 # the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option) any
-# later version.
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
 #
 # logilab-common 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 Lesser General Public License for more
 # details.
 #
-# You should have received a copy of the GNU Lesser General Public License along
-# with logilab-common.  If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with logilab-common.  If not, see <http://www.gnu.org/licenses/>.
 """Manipulation of upstream change log files.
 
 The upstream change log files format handled is simpler than the one
@@ -48,6 +48,7 @@ __docformat__ = "restructuredtext en"
 
 import sys
 from stat import S_IWRITE
+import codecs
 
 from six import string_types
 
@@ -55,19 +56,22 @@ BULLET = '*'
 SUBBULLET = '-'
 INDENT = ' ' * 4
 
+
 class NoEntry(Exception):
     """raised when we are unable to find an entry"""
 
+
 class EntryNotFound(Exception):
     """raised when we are unable to find a given entry"""
 
+
 class Version(tuple):
     """simple class to handle soft version number has a tuple while
     correctly printing it as X.Y.Z
     """
     def __new__(cls, versionstr):
         if isinstance(versionstr, string_types):
-            versionstr = versionstr.strip(' :') # XXX (syt) duh?
+            versionstr = versionstr.strip(' :')  # XXX (syt) duh?
             parsed = cls.parse(versionstr)
         else:
             parsed = versionstr
@@ -79,11 +83,13 @@ class Version(tuple):
         try:
             return [int(i) for i in versionstr.split('.')]
         except ValueError as ex:
-            raise ValueError("invalid literal for version '%s' (%s)"%(versionstr, ex))
+            raise ValueError("invalid literal for version '%s' (%s)" %
+                             (versionstr, ex))
 
     def __str__(self):
         return '.'.join([str(i) for i in self])
 
+
 # upstream change log #########################################################
 
 class ChangeLogEntry(object):
@@ -109,44 +115,50 @@ class ChangeLogEntry(object):
         """complete the latest added message
         """
         if not self.messages:
-            raise ValueError('unable to complete last message as there is no previous message)')
-        if self.messages[-1][1]: # sub messages
+            raise ValueError('unable to complete last message as '
+                             'there is no previous message)')
+        if self.messages[-1][1]:  # sub messages
             self.messages[-1][1][-1].append(msg_suite)
-        else: # message
+        else:  # message
             self.messages[-1][0].append(msg_suite)
 
     def add_sub_message(self, sub_msg, key=None):
         if not self.messages:
-            raise ValueError('unable to complete last message as there is no previous message)')
+            raise ValueError('unable to complete last message as '
+                             'there is no previous message)')
         if key is None:
             self.messages[-1][1].append([sub_msg])
         else:
-            raise NotImplementedError("sub message to specific key are not implemented yet")
+            raise NotImplementedError('sub message to specific key '
+                                      'are not implemented yet')
 
     def write(self, stream=sys.stdout):
         """write the entry to file """
-        stream.write('%s  --  %s\n' % (self.date or '', self.version or ''))
+        stream.write(u'%s  --  %s\n' % (self.date or '', self.version or ''))
         for msg, sub_msgs in self.messages:
-            stream.write('%s%s %s\n' % (INDENT, BULLET, msg[0]))
-            stream.write(''.join(msg[1:]))
+            stream.write(u'%s%s %s\n' % (INDENT, BULLET, msg[0]))
+            stream.write(u''.join(msg[1:]))
             if sub_msgs:
-                stream.write('\n')
+                stream.write(u'\n')
             for sub_msg in sub_msgs:
-                stream.write('%s%s %s\n' % (INDENT * 2, SUBBULLET, sub_msg[0]))
-                stream.write(''.join(sub_msg[1:]))
-            stream.write('\n')
+                stream.write(u'%s%s %s\n' %
+                             (INDENT * 2, SUBBULLET, sub_msg[0]))
+                stream.write(u''.join(sub_msg[1:]))
+            stream.write(u'\n')
+
+        stream.write(u'\n\n')
 
-        stream.write('\n\n')
 
 class ChangeLog(object):
     """object representation of a whole ChangeLog file"""
 
     entry_class = ChangeLogEntry
 
-    def __init__(self, changelog_file, title=''):
+    def __init__(self, changelog_file, title=u''):
         self.file = changelog_file
+        assert isinstance(title, type(u'')), 'title must be a unicode object'
         self.title = title
-        self.additional_content = ''
+        self.additional_content = u''
         self.entries = []
         self.load()
 
@@ -184,12 +196,12 @@ class ChangeLog(object):
     def load(self):
         """ read a logilab's ChangeLog from file """
         try:
-            stream = open(self.file)
+            stream = codecs.open(self.file, encoding='utf-8')
         except IOError:
             return
         last = None
         expect_sub = False
-        for line in stream.readlines():
+        for line in stream:
             sline = line.strip()
             words = sline.split()
             # if new entry
@@ -221,18 +233,17 @@ class ChangeLog(object):
         stream.close()
 
     def format_title(self):
-        return '%s\n\n' % self.title.strip()
+        return u'%s\n\n' % self.title.strip()
 
     def save(self):
         """write back change log"""
         # filetutils isn't importable in appengine, so import locally
         from logilab.common.fileutils import ensure_fs_mode
         ensure_fs_mode(self.file, S_IWRITE)
-        self.write(open(self.file, 'w'))
+        self.write(codecs.open(self.file, 'w', encoding='utf-8'))
 
     def write(self, stream=sys.stdout):
         """write changelog to stream"""
         stream.write(self.format_title())
         for entry in self.entries:
             entry.write(stream)
-
diff --git a/logilab/common/date.py b/logilab/common/date.py
index 37e371b..1d13a77 100644
--- a/logilab/common/date.py
+++ b/logilab/common/date.py
@@ -237,7 +237,7 @@ def todatetime(somedate):
     return datetime(somedate.year, somedate.month, somedate.day)
 
 def datetime2ticks(somedate):
-    return timegm(somedate.timetuple()) * 1000 + int(somedate.microsecond / 1000)
+    return timegm(somedate.timetuple()) * 1000 + int(getattr(somedate, 'microsecond', 0) / 1000)
 
 def ticks2datetime(ticks):
     miliseconds, microseconds = divmod(ticks, 1000)
diff --git a/logilab/common/registry.py b/logilab/common/registry.py
index 86a85f9..f337efe 100644
--- a/logilab/common/registry.py
+++ b/logilab/common/registry.py
@@ -720,7 +720,6 @@ class RegistryStore(dict):
 
     def load_file(self, filepath, modname):
         """ load registrable objects (if any) from a python file """
-        from logilab.common.modutils import load_module_from_name
         if modname in self._loadedmods:
             return
         self._loadedmods[modname] = {}
@@ -735,7 +734,7 @@ class RegistryStore(dict):
         # module
         self._lastmodifs[filepath] = mdate
         # load the module
-        module = load_module_from_name(modname)
+        module = __import__(modname, fromlist=modname.split('.')[:-1])
         self.load_module(module)
 
     def load_module(self, module):
diff --git a/logilab_common.egg-info/PKG-INFO b/logilab_common.egg-info/PKG-INFO
index 3299e17..16aeabc 100644
--- a/logilab_common.egg-info/PKG-INFO
+++ b/logilab_common.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: logilab-common
-Version: 1.2.0
+Version: 1.2.1
 Summary: collection of low-level Python packages and modules used by Logilab projects
 Home-page: http://www.logilab.org/project/logilab-common
 Author: Logilab
diff --git a/test/unittest_changelog.py b/test/unittest_changelog.py
index 6f60ead..c2572d7 100644
--- a/test/unittest_changelog.py
+++ b/test/unittest_changelog.py
@@ -1,28 +1,29 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact at logilab.fr
 #
 # This file is part of logilab-common.
 #
-# logilab-common is free software: you can redistribute it and/or modify it under
+# logilab-common is free software: you can redistribute it or modify it under
 # the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option) any
-# later version.
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
 #
 # logilab-common 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 Lesser General Public License for more
 # details.
 #
-# You should have received a copy of the GNU Lesser General Public License along
-# with logilab-common.  If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with logilab-common.  If not, see <http://www.gnu.org/licenses/>.
 
 from os.path import join, dirname
 
-from logilab.common.compat import StringIO
+from io import StringIO
 from logilab.common.testlib import TestCase, unittest_main
 
 from logilab.common.changelog import ChangeLog
 
+
 class ChangeLogTC(TestCase):
     cl_class = ChangeLog
     cl_file = join(dirname(__file__), 'data', 'ChangeLog')
diff --git a/test/unittest_date.py b/test/unittest_date.py
index 22302b0..9ae444b 100644
--- a/test/unittest_date.py
+++ b/test/unittest_date.py
@@ -149,7 +149,7 @@ class DateTC(TestCase):
 
     def test_utcdatetime(self):
         if self.datetimecls is mxDateTime:
-            raise self.skipTest('standard datetime only test')
+            return
         d = self.datetimecls(2014, 11, 26, 12, 0, 0, 57, tzinfo=pytz.utc)
         d = utcdatetime(d)
         self.assertEqual(d, self.datetimecls(2014, 11, 26, 12, 0, 0, 57))
@@ -174,6 +174,11 @@ class DateTC(TestCase):
         d = d.replace(microsecond=123456)
         self.assertEqual(datetime2ticks(d), timestamp * 1000 + 123)
 
+    def test_datetime2ticks_date_argument(self):
+        d = date(2014, 11, 26)
+        timestamp = timegm(d.timetuple())
+        self.assertEqual(datetime2ticks(d), timestamp * 1000)
+
 
 class MxDateTC(DateTC):
     datecls = mxDate

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/logilab-common.git



More information about the Python-modules-commits mailing list