| OLD | NEW |
| 1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. | 1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
| 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
| 3 # | 3 # |
| 4 # This file is part of logilab-common. | 4 # This file is part of logilab-common. |
| 5 # | 5 # |
| 6 # logilab-common is free software: you can redistribute it and/or modify it unde
r | 6 # logilab-common is free software: you can redistribute it and/or modify it unde
r |
| 7 # the terms of the GNU Lesser General Public License as published by the Free | 7 # the terms of the GNU Lesser General Public License as published by the Free |
| 8 # Software Foundation, either version 2.1 of the License, or (at your option) an
y | 8 # Software Foundation, either version 2.1 of the License, or (at your option) an
y |
| 9 # later version. | 9 # later version. |
| 10 # | 10 # |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 release. | 42 release. |
| 43 All the non empty lines before the first entry are considered as the change | 43 All the non empty lines before the first entry are considered as the change |
| 44 log title. | 44 log title. |
| 45 """ | 45 """ |
| 46 | 46 |
| 47 __docformat__ = "restructuredtext en" | 47 __docformat__ = "restructuredtext en" |
| 48 | 48 |
| 49 import sys | 49 import sys |
| 50 from stat import S_IWRITE | 50 from stat import S_IWRITE |
| 51 | 51 |
| 52 from six import string_types |
| 53 |
| 52 BULLET = '*' | 54 BULLET = '*' |
| 53 SUBBULLET = '-' | 55 SUBBULLET = '-' |
| 54 INDENT = ' ' * 4 | 56 INDENT = ' ' * 4 |
| 55 | 57 |
| 56 class NoEntry(Exception): | 58 class NoEntry(Exception): |
| 57 """raised when we are unable to find an entry""" | 59 """raised when we are unable to find an entry""" |
| 58 | 60 |
| 59 class EntryNotFound(Exception): | 61 class EntryNotFound(Exception): |
| 60 """raised when we are unable to find a given entry""" | 62 """raised when we are unable to find a given entry""" |
| 61 | 63 |
| 62 class Version(tuple): | 64 class Version(tuple): |
| 63 """simple class to handle soft version number has a tuple while | 65 """simple class to handle soft version number has a tuple while |
| 64 correctly printing it as X.Y.Z | 66 correctly printing it as X.Y.Z |
| 65 """ | 67 """ |
| 66 def __new__(cls, versionstr): | 68 def __new__(cls, versionstr): |
| 67 if isinstance(versionstr, basestring): | 69 if isinstance(versionstr, string_types): |
| 68 versionstr = versionstr.strip(' :') # XXX (syt) duh? | 70 versionstr = versionstr.strip(' :') # XXX (syt) duh? |
| 69 parsed = cls.parse(versionstr) | 71 parsed = cls.parse(versionstr) |
| 70 else: | 72 else: |
| 71 parsed = versionstr | 73 parsed = versionstr |
| 72 return tuple.__new__(cls, parsed) | 74 return tuple.__new__(cls, parsed) |
| 73 | 75 |
| 74 @classmethod | 76 @classmethod |
| 75 def parse(cls, versionstr): | 77 def parse(cls, versionstr): |
| 76 versionstr = versionstr.strip(' :') | 78 versionstr = versionstr.strip(' :') |
| 77 try: | 79 try: |
| 78 return [int(i) for i in versionstr.split('.')] | 80 return [int(i) for i in versionstr.split('.')] |
| 79 except ValueError, ex: | 81 except ValueError as ex: |
| 80 raise ValueError("invalid literal for version '%s' (%s)"%(versionstr
, ex)) | 82 raise ValueError("invalid literal for version '%s' (%s)"%(versionstr
, ex)) |
| 81 | 83 |
| 82 def __str__(self): | 84 def __str__(self): |
| 83 return '.'.join([str(i) for i in self]) | 85 return '.'.join([str(i) for i in self]) |
| 84 | 86 |
| 85 # upstream change log ######################################################### | 87 # upstream change log ######################################################### |
| 86 | 88 |
| 87 class ChangeLogEntry(object): | 89 class ChangeLogEntry(object): |
| 88 """a change log entry, i.e. a set of messages associated to a version and | 90 """a change log entry, i.e. a set of messages associated to a version and |
| 89 its release date | 91 its release date |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 from logilab.common.fileutils import ensure_fs_mode | 229 from logilab.common.fileutils import ensure_fs_mode |
| 228 ensure_fs_mode(self.file, S_IWRITE) | 230 ensure_fs_mode(self.file, S_IWRITE) |
| 229 self.write(open(self.file, 'w')) | 231 self.write(open(self.file, 'w')) |
| 230 | 232 |
| 231 def write(self, stream=sys.stdout): | 233 def write(self, stream=sys.stdout): |
| 232 """write changelog to stream""" | 234 """write changelog to stream""" |
| 233 stream.write(self.format_title()) | 235 stream.write(self.format_title()) |
| 234 for entry in self.entries: | 236 for entry in self.entries: |
| 235 entry.write(stream) | 237 entry.write(stream) |
| 236 | 238 |
| OLD | NEW |