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

Side by Side Diff: third_party/pylint/config.py

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years 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/pylint/checkers/variables.py ('k') | third_party/pylint/epylint.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 (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). 1 # Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
2 # This program is free software; you can redistribute it and/or modify it under 2 # This program is free software; you can redistribute it and/or modify it under
3 # the terms of the GNU General Public License as published by the Free Software 3 # the terms of the GNU General Public License as published by the Free Software
4 # Foundation; either version 2 of the License, or (at your option) any later 4 # Foundation; either version 2 of the License, or (at your option) any later
5 # version. 5 # version.
6 # 6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT 7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details 9 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
10 # 10 #
11 # You should have received a copy of the GNU General Public License along with 11 # You should have received a copy of the GNU General Public License along with
12 # this program; if not, write to the Free Software Foundation, Inc., 12 # this program; if not, write to the Free Software Foundation, Inc.,
13 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 """utilities for Pylint configuration : 14 """utilities for Pylint configuration :
15 15
16 * pylintrc 16 * pylintrc
17 * pylint.d (PYLINTHOME) 17 * pylint.d (PYLINTHOME)
18 """ 18 """
19 from __future__ import with_statement 19 from __future__ import with_statement
20 from __future__ import print_function
20 21
21 import pickle 22 import pickle
22 import os 23 import os
23 import sys 24 import sys
24 from os.path import exists, isfile, join, expanduser, abspath, dirname 25 from os.path import exists, isfile, join, expanduser, abspath, dirname
25 26
26 # pylint home is used to save old runs results ################################ 27 # pylint home is used to save old runs results ################################
27 28
28 USER_HOME = expanduser('~') 29 USER_HOME = expanduser('~')
29 if 'PYLINTHOME' in os.environ: 30 if 'PYLINTHOME' in os.environ:
(...skipping 15 matching lines...) Expand all
45 def load_results(base): 46 def load_results(base):
46 """try to unpickle and return data from file if it exists and is not 47 """try to unpickle and return data from file if it exists and is not
47 corrupted 48 corrupted
48 49
49 return an empty dictionary if it doesn't exists 50 return an empty dictionary if it doesn't exists
50 """ 51 """
51 data_file = get_pdata_path(base, 1) 52 data_file = get_pdata_path(base, 1)
52 try: 53 try:
53 with open(data_file, _PICK_LOAD) as stream: 54 with open(data_file, _PICK_LOAD) as stream:
54 return pickle.load(stream) 55 return pickle.load(stream)
55 except: 56 except Exception: # pylint: disable=broad-except
56 return {} 57 return {}
57 58
58 if sys.version_info < (3, 0): 59 if sys.version_info < (3, 0):
59 _PICK_DUMP, _PICK_LOAD = 'w', 'r' 60 _PICK_DUMP, _PICK_LOAD = 'w', 'r'
60 else: 61 else:
61 _PICK_DUMP, _PICK_LOAD = 'wb', 'rb' 62 _PICK_DUMP, _PICK_LOAD = 'wb', 'rb'
62 63
63 def save_results(results, base): 64 def save_results(results, base):
64 """pickle results""" 65 """pickle results"""
65 if not exists(PYLINT_HOME): 66 if not exists(PYLINT_HOME):
66 try: 67 try:
67 os.mkdir(PYLINT_HOME) 68 os.mkdir(PYLINT_HOME)
68 except OSError: 69 except OSError:
69 print >> sys.stderr, 'Unable to create directory %s' % PYLINT_HOME 70 print('Unable to create directory %s' % PYLINT_HOME, file=sys.stderr )
70 data_file = get_pdata_path(base, 1) 71 data_file = get_pdata_path(base, 1)
71 try: 72 try:
72 with open(data_file, _PICK_DUMP) as stream: 73 with open(data_file, _PICK_DUMP) as stream:
73 pickle.dump(results, stream) 74 pickle.dump(results, stream)
74 except (IOError, OSError), ex: 75 except (IOError, OSError) as ex:
75 print >> sys.stderr, 'Unable to create file %s: %s' % (data_file, ex) 76 print('Unable to create file %s: %s' % (data_file, ex), file=sys.stderr)
76 77
77 # location of the configuration file ########################################## 78 # location of the configuration file ##########################################
78 79
79 80
80 def find_pylintrc(): 81 def find_pylintrc():
81 """search the pylint rc file and return its path if it find it, else None 82 """search the pylint rc file and return its path if it find it, else None
82 """ 83 """
83 # is there a pylint rc file in the current directory ? 84 # is there a pylint rc file in the current directory ?
84 if exists('pylintrc'): 85 if exists('pylintrc'):
85 return abspath('pylintrc') 86 return abspath('pylintrc')
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 msg = 'If you commit now, people should not be making nasty \ 148 msg = 'If you commit now, people should not be making nasty \
148 comments about you on c.l.py' 149 comments about you on c.l.py'
149 elif note < 9: 150 elif note < 9:
150 msg = 'That\'s pretty good. Good work mate.' 151 msg = 'That\'s pretty good. Good work mate.'
151 elif note < 10: 152 elif note < 10:
152 msg = 'So close to being perfect...' 153 msg = 'So close to being perfect...'
153 else: 154 else:
154 msg = 'Wow ! Now this deserves our uttermost respect.\nPlease send \ 155 msg = 'Wow ! Now this deserves our uttermost respect.\nPlease send \
155 your code to python-projects@logilab.org' 156 your code to python-projects@logilab.org'
156 return msg 157 return msg
OLDNEW
« no previous file with comments | « third_party/pylint/checkers/variables.py ('k') | third_party/pylint/epylint.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698