On Thu, Feb  2, 2012 at 10:47:24 -0700, JT Olds wrote:

> diff -r f673b9738dcd lint.py
> --- a/lint.py Mon Jan 09 21:25:10 2012 +0100
> +++ b/lint.py Thu Feb 02 10:42:06 2012 -0700
> @@ -866,7 +866,10 @@
>              sys.exit(32)
>          # insert current working directory to the python path to have a 
> correct
>          # behaviour
> -        sys.path.insert(0, os.getcwd())
> +        if len(args) == 1:
> +            sys.path.insert(0, self._get_python_path(args[0]))
> +        else:
> +            sys.path.insert(0, os.getcwd())
>          if self.linter.config.profile:
>              print >> sys.stderr, '** profiled run'
>              import cProfile, pstats
> @@ -881,6 +884,16 @@
>          if exit:
>              sys.exit(self.linter.msg_status)
>  
> +    def _get_python_path(self, filepath):
> +        dirname = os.path.dirname(os.path.realpath(
> +                os.path.expanduser(filepath)))

Do you actually need expanduser here?  I'd expect the shell to pass an
expanded filename already, and I can't find a place where pylint does
that expansion for its arguments.

> +        while True:
> +            if not os.path.exists(os.path.join(dirname, "__init__.py")):
> +                return dirname
> +            old_dirname = dirname
> +            dirname = os.path.dirname(dirname)
> +            if old_dirname == dirname: return os.getcwd()
> +
>      def cb_set_rcfile(self, name, value):
>          """callback for option preprocessing (i.e. before optik parsing)"""
>          self._rcfile = value

Thanks for the patch, I've added it to our code review system, with a
made up commit message, hopefully it's ok:
http://hg.logilab.org/patches/pylint/file/9e743f56071b/pythonpath.diff

Cheers,
Julien
-- 
Julien Cristau          <[email protected]>
Logilab                 http://www.logilab.fr/
Informatique scientifique & gestion de connaissances
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to