| 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 # |
| 11 # logilab-common is distributed in the hope that it will be useful, but WITHOUT | 11 # logilab-common is distributed in the hope that it will be useful, but WITHOUT |
| 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | 13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 14 # details. | 14 # details. |
| 15 # | 15 # |
| 16 # You should have received a copy of the GNU Lesser General Public License along | 16 # You should have received a copy of the GNU Lesser General Public License along |
| 17 # with logilab-common. If not, see <http://www.gnu.org/licenses/>. | 17 # with logilab-common. If not, see <http://www.gnu.org/licenses/>. |
| 18 """Logilab common library (aka Logilab's extension to the standard library). | 18 """Logilab common library (aka Logilab's extension to the standard library). |
| 19 | 19 |
| 20 :type STD_BLACKLIST: tuple | 20 :type STD_BLACKLIST: tuple |
| 21 :var STD_BLACKLIST: directories ignored by default by the functions in | 21 :var STD_BLACKLIST: directories ignored by default by the functions in |
| 22 this package which have to recurse into directories | 22 this package which have to recurse into directories |
| 23 | 23 |
| 24 :type IGNORED_EXTENSIONS: tuple | 24 :type IGNORED_EXTENSIONS: tuple |
| 25 :var IGNORED_EXTENSIONS: file extensions that may usually be ignored | 25 :var IGNORED_EXTENSIONS: file extensions that may usually be ignored |
| 26 """ | 26 """ |
| 27 __docformat__ = "restructuredtext en" | 27 __docformat__ = "restructuredtext en" |
| 28 |
| 29 from six.moves import range |
| 30 |
| 28 from logilab.common.__pkginfo__ import version as __version__ | 31 from logilab.common.__pkginfo__ import version as __version__ |
| 29 | 32 |
| 30 STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build') | 33 STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build') |
| 31 | 34 |
| 32 IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~', '.swp', '.orig') | 35 IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~', '.swp', '.orig') |
| 33 | 36 |
| 34 # set this to False if you've mx DateTime installed but you don't want your db | 37 # set this to False if you've mx DateTime installed but you don't want your db |
| 35 # adapter to use it (should be set before you got a connection) | 38 # adapter to use it (should be set before you got a connection) |
| 36 USE_MX_DATETIME = True | 39 USE_MX_DATETIME = True |
| 37 | 40 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 | 53 |
| 51 def __getitem__(self, attr): | 54 def __getitem__(self, attr): |
| 52 try: | 55 try: |
| 53 return getattr(self.__proxy, attr) | 56 return getattr(self.__proxy, attr) |
| 54 except AttributeError: | 57 except AttributeError: |
| 55 raise KeyError(attr) | 58 raise KeyError(attr) |
| 56 | 59 |
| 57 class nullobject(object): | 60 class nullobject(object): |
| 58 def __repr__(self): | 61 def __repr__(self): |
| 59 return '<nullobject>' | 62 return '<nullobject>' |
| 60 def __nonzero__(self): | 63 def __bool__(self): |
| 61 return False | 64 return False |
| 65 __nonzero__ = __bool__ |
| 62 | 66 |
| 63 class tempattr(object): | 67 class tempattr(object): |
| 64 def __init__(self, obj, attr, value): | 68 def __init__(self, obj, attr, value): |
| 65 self.obj = obj | 69 self.obj = obj |
| 66 self.attr = attr | 70 self.attr = attr |
| 67 self.value = value | 71 self.value = value |
| 68 | 72 |
| 69 def __enter__(self): | 73 def __enter__(self): |
| 70 self.oldvalue = getattr(self.obj, self.attr) | 74 self.oldvalue = getattr(self.obj, self.attr) |
| 71 setattr(self.obj, self.attr, self.value) | 75 setattr(self.obj, self.attr, self.value) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 """remove files/directories in the black list | 166 """remove files/directories in the black list |
| 163 | 167 |
| 164 dirnames/filenames are usually from os.walk | 168 dirnames/filenames are usually from os.walk |
| 165 """ | 169 """ |
| 166 for norecurs in blacklist: | 170 for norecurs in blacklist: |
| 167 if norecurs in dirnames: | 171 if norecurs in dirnames: |
| 168 dirnames.remove(norecurs) | 172 dirnames.remove(norecurs) |
| 169 elif norecurs in filenames: | 173 elif norecurs in filenames: |
| 170 filenames.remove(norecurs) | 174 filenames.remove(norecurs) |
| 171 | 175 |
| OLD | NEW |