Пример #1
0
    def __enter__(self):
        file_path = self.view.file_name()
        project_dir = self.find_ropeproject(file_path)
        if project_dir:
            self.project = project.Project(project_dir)
            if not os.path.exists("%s/.ropeproject/globalnames" % project_dir):
                importer = autoimport.AutoImport(
                    project=self.project, observe=True)
                importer.generate_cache()
            if os.path.exists("%s/__init__.py" % project_dir):
                sys.path.append(project_dir)

        else:
            # create a single-file project(ignoring other files in the folder)
            folder = os.path.dirname(file_path)
            ignored_res = os.listdir(folder)
            ignored_res.remove(os.path.basename(file_path))

            self.project = project.Project(
                ropefolder=None, projectroot=folder,
                ignored_resources=ignored_res)

        self.resource = libutils.path_to_resource(self.project, file_path)
        update_python_path(self.project.prefs.get('python_path', []))
        self.input = self.view.substr(sublime.Region(0, self.view.size()))

        return self
Пример #2
0
    def __enter__(self):
        project_dir = os.environ.get('TM_PROJECT_DIRECTORY', None)
        file_path = os.environ['TM_FILEPATH']

        if project_dir:
            self.project = project.Project(project_dir)
            # no use to have auto import for a single file project
            if not os.path.exists("%s/.ropeproject/globalnames" % project_dir):
                importer = autoimport.AutoImport(project=self.project,
                                                 observe=True)
                importer.generate_cache()
            if os.path.exists("%s/__init__.py" % project_dir):
                sys.path.append(project_dir)

        else:
            #create a single-file project (ignoring all other files in the file's folder)
            folder = os.path.dirname(file_path)
            ignored_res = os.listdir(folder)
            ignored_res.remove(os.path.basename(file_path))
            self.project = project.Project(ropefolder=None,
                                           projectroot=folder,
                                           ignored_resources=ignored_res)

        self.resource = libutils.path_to_resource(self.project, file_path)

        update_python_path(self.project.prefs.get('python_path', []))

        self.input = sys.stdin.read()

        return self
Пример #3
0
 def __enter__(self):
     project_dir = os.environ.get('TM_PROJECT_DIRECTORY', None)
     file_path = os.environ['TM_FILEPATH']
     
     if project_dir:
         self.project = project.Project(project_dir)
         # no use to have auto import for a single file project
         if not os.path.exists("%s/.ropeproject/globalnames" % project_dir):
             importer = autoimport.AutoImport(project=self.project, observe=True)
             importer.generate_cache()
         if os.path.exists("%s/__init__.py" % project_dir):
             sys.path.append(project_dir)
         
     else:
         #create a single-file project (ignoring all other files in the file's folder)
         folder = os.path.dirname(file_path)
         ignored_res = os.listdir(folder)
         ignored_res.remove(os.path.basename(file_path))
         self.project = project.Project(
             ropefolder=None,projectroot=folder, ignored_resources=ignored_res)
     
     self.resource = libutils.path_to_resource(self.project, file_path)
     
     update_python_path( self.project.prefs.get('python_path', []) )
     
     self.input = sys.stdin.read()
     
     return self