diff options
author | Sylvain Th?nault <thenault@gmail.com> | 2013-12-20 17:26:41 +0100 |
---|---|---|
committer | Sylvain Th?nault <thenault@gmail.com> | 2013-12-20 17:26:41 +0100 |
commit | 1722f16ed58528768370ace7991ddaa70f3cbe3f (patch) | |
tree | 7354c64adbbddf4448fe4f057f743362f3e957ff /config.py | |
parent | e7fc0a23d8a963daf4b367e4e8fd9f6ec7087a35 (diff) | |
parent | f24227aae012740653e8708379b7e9c22f938400 (diff) | |
download | pylint-1722f16ed58528768370ace7991ddaa70f3cbe3f.tar.gz |
Merged in jmcgeheeiv/pylintrc_search_doc (pull request #65)
Correct documentation for the manner in which Pylint finds its pylintrc configuration file
Diffstat (limited to 'config.py')
-rw-r--r-- | config.py | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -1,4 +1,4 @@ -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE). +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later @@ -16,6 +16,7 @@ * pylintrc * pylint.d (PYLINTHOME) """ +from __future__ import with_statement import pickle import os @@ -34,12 +35,6 @@ elif USER_HOME == '~': else: PYLINT_HOME = join(USER_HOME, '.pylint.d') -if not exists(PYLINT_HOME): - try: - os.mkdir(PYLINT_HOME) - except OSError: - print >> sys.stderr, 'Unable to create directory %s' % PYLINT_HOME - def get_pdata_path(base_name, recurs): """return the path of the file which should contain old search data for the given base_name with the given options values @@ -55,7 +50,8 @@ def load_results(base): """ data_file = get_pdata_path(base, 1) try: - return pickle.load(open(data_file)) + with open(data_file) as stream: + return pickle.load(stream) except: return {} @@ -66,9 +62,15 @@ else: def save_results(results, base): """pickle results""" + if not exists(PYLINT_HOME): + try: + os.mkdir(PYLINT_HOME) + except OSError: + print >> sys.stderr, 'Unable to create directory %s' % PYLINT_HOME data_file = get_pdata_path(base, 1) try: - pickle.dump(results, open(data_file, _PICK_MOD)) + with open(data_file, _PICK_MOD) as stream: + pickle.dump(results, stream) except (IOError, OSError), ex: print >> sys.stderr, 'Unable to create file %s: %s' % (data_file, ex) |