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 | |
31 from logilab.common.__pkginfo__ import version as __version__ | 28 from logilab.common.__pkginfo__ import version as __version__ |
32 | 29 |
33 STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build') | 30 STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build') |
34 | 31 |
35 IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~', '.swp', '.orig') | 32 IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~', '.swp', '.orig') |
36 | 33 |
37 # set this to False if you've mx DateTime installed but you don't want your db | 34 # set this to False if you've mx DateTime installed but you don't want your db |
38 # adapter to use it (should be set before you got a connection) | 35 # adapter to use it (should be set before you got a connection) |
39 USE_MX_DATETIME = True | 36 USE_MX_DATETIME = True |
40 | 37 |
(...skipping 12 matching lines...) Expand all Loading... |
53 | 50 |
54 def __getitem__(self, attr): | 51 def __getitem__(self, attr): |
55 try: | 52 try: |
56 return getattr(self.__proxy, attr) | 53 return getattr(self.__proxy, attr) |
57 except AttributeError: | 54 except AttributeError: |
58 raise KeyError(attr) | 55 raise KeyError(attr) |
59 | 56 |
60 class nullobject(object): | 57 class nullobject(object): |
61 def __repr__(self): | 58 def __repr__(self): |
62 return '<nullobject>' | 59 return '<nullobject>' |
63 def __bool__(self): | 60 def __nonzero__(self): |
64 return False | 61 return False |
65 __nonzero__ = __bool__ | |
66 | 62 |
67 class tempattr(object): | 63 class tempattr(object): |
68 def __init__(self, obj, attr, value): | 64 def __init__(self, obj, attr, value): |
69 self.obj = obj | 65 self.obj = obj |
70 self.attr = attr | 66 self.attr = attr |
71 self.value = value | 67 self.value = value |
72 | 68 |
73 def __enter__(self): | 69 def __enter__(self): |
74 self.oldvalue = getattr(self.obj, self.attr) | 70 self.oldvalue = getattr(self.obj, self.attr) |
75 setattr(self.obj, self.attr, self.value) | 71 setattr(self.obj, self.attr, self.value) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 """remove files/directories in the black list | 162 """remove files/directories in the black list |
167 | 163 |
168 dirnames/filenames are usually from os.walk | 164 dirnames/filenames are usually from os.walk |
169 """ | 165 """ |
170 for norecurs in blacklist: | 166 for norecurs in blacklist: |
171 if norecurs in dirnames: | 167 if norecurs in dirnames: |
172 dirnames.remove(norecurs) | 168 dirnames.remove(norecurs) |
173 elif norecurs in filenames: | 169 elif norecurs in filenames: |
174 filenames.remove(norecurs) | 170 filenames.remove(norecurs) |
175 | 171 |
OLD | NEW |