Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Side by Side Diff: third_party/logilab/common/changelog.py

Issue 719313003: Revert "pylint: upgrade to 1.3.1" (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/logilab/common/__pkginfo__.py ('k') | third_party/logilab/common/clcommands.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
54 BULLET = '*' 52 BULLET = '*'
55 SUBBULLET = '-' 53 SUBBULLET = '-'
56 INDENT = ' ' * 4 54 INDENT = ' ' * 4
57 55
58 class NoEntry(Exception): 56 class NoEntry(Exception):
59 """raised when we are unable to find an entry""" 57 """raised when we are unable to find an entry"""
60 58
61 class EntryNotFound(Exception): 59 class EntryNotFound(Exception):
62 """raised when we are unable to find a given entry""" 60 """raised when we are unable to find a given entry"""
63 61
64 class Version(tuple): 62 class Version(tuple):
65 """simple class to handle soft version number has a tuple while 63 """simple class to handle soft version number has a tuple while
66 correctly printing it as X.Y.Z 64 correctly printing it as X.Y.Z
67 """ 65 """
68 def __new__(cls, versionstr): 66 def __new__(cls, versionstr):
69 if isinstance(versionstr, string_types): 67 if isinstance(versionstr, basestring):
70 versionstr = versionstr.strip(' :') # XXX (syt) duh? 68 versionstr = versionstr.strip(' :') # XXX (syt) duh?
71 parsed = cls.parse(versionstr) 69 parsed = cls.parse(versionstr)
72 else: 70 else:
73 parsed = versionstr 71 parsed = versionstr
74 return tuple.__new__(cls, parsed) 72 return tuple.__new__(cls, parsed)
75 73
76 @classmethod 74 @classmethod
77 def parse(cls, versionstr): 75 def parse(cls, versionstr):
78 versionstr = versionstr.strip(' :') 76 versionstr = versionstr.strip(' :')
79 try: 77 try:
80 return [int(i) for i in versionstr.split('.')] 78 return [int(i) for i in versionstr.split('.')]
81 except ValueError as ex: 79 except ValueError, ex:
82 raise ValueError("invalid literal for version '%s' (%s)"%(versionstr , ex)) 80 raise ValueError("invalid literal for version '%s' (%s)"%(versionstr , ex))
83 81
84 def __str__(self): 82 def __str__(self):
85 return '.'.join([str(i) for i in self]) 83 return '.'.join([str(i) for i in self])
86 84
87 # upstream change log ######################################################### 85 # upstream change log #########################################################
88 86
89 class ChangeLogEntry(object): 87 class ChangeLogEntry(object):
90 """a change log entry, i.e. a set of messages associated to a version and 88 """a change log entry, i.e. a set of messages associated to a version and
91 its release date 89 its release date
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 from logilab.common.fileutils import ensure_fs_mode 227 from logilab.common.fileutils import ensure_fs_mode
230 ensure_fs_mode(self.file, S_IWRITE) 228 ensure_fs_mode(self.file, S_IWRITE)
231 self.write(open(self.file, 'w')) 229 self.write(open(self.file, 'w'))
232 230
233 def write(self, stream=sys.stdout): 231 def write(self, stream=sys.stdout):
234 """write changelog to stream""" 232 """write changelog to stream"""
235 stream.write(self.format_title()) 233 stream.write(self.format_title())
236 for entry in self.entries: 234 for entry in self.entries:
237 entry.write(stream) 235 entry.write(stream)
238 236
OLDNEW
« no previous file with comments | « third_party/logilab/common/__pkginfo__.py ('k') | third_party/logilab/common/clcommands.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698