Commits

Anonymous committed 3acde82

Add hooks for import path setup and move pylint's sys.path
modifications into them. These hooks can be overridden by other implementations.

Comments (0)

Files changed (2)

     * Make dot output for import graph predictable and not depend
       on ordering of strings in hashes. (patch by Torsten Marek)
 
+    * Add hooks for import path setup and move pylint's sys.path
+      modifications into them. (patch by Torsten Marek)
+
 2012-10-05  --  0.26.0
     * #106534: add --ignore-imports option to code similarity checking
       and 'symilar' command line tool (patch by Ry4an Brase)
         from pylint import checkers
         checkers.initialize(self)
 
+    def prepare_import_path(self, args):
+        """Prepare sys.path for running the linter checks."""
+        if len(args) == 1:
+            sys.path.insert(0, _get_python_path(args[0]))
+        else:
+            sys.path.insert(0, os.getcwd())
+
+    def cleanup_import_path(self):
+        """Revert any changes made to sys.path in prepare_import_path."""
+        sys.path.pop(0)
+
     def load_plugin_modules(self, modnames):
         """take a list of module names which are pylint plugins and load
         and register them
             sys.exit(32)
         # insert current working directory to the python path to have a correct
         # behaviour
-        if len(args) == 1:
-            sys.path.insert(0, _get_python_path(args[0]))
-        else:
-            sys.path.insert(0, os.getcwd())
+        linter.prepare_import_path(args)
         if self.linter.config.profile:
             print >> sys.stderr, '** profiled run'
             import cProfile, pstats
             data.print_stats(30)
         else:
             linter.check(args)
-        sys.path.pop(0)
+        linter.cleanup_import_path()
         if exit:
             sys.exit(self.linter.msg_status)