当前位置: 首页>>代码示例>>Python>>正文


Python project.Project类代码示例

本文整理汇总了Python中rope.base.project.Project的典型用法代码示例。如果您正苦于以下问题:Python Project类的具体用法?Python Project怎么用?Python Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main(config_file=None):
    """ """

    if not config_file:
        print "You need to provide a valid config file"
        sys.exit(1)

    config = Config(config_file)
    print "Tying the rope..."
    myproject = Project(config.buildout_dir+'/src', python_path=sys.path)
    handle.add_observer(update_progress)

    # analyze_modules(myproject, task_handle=handle)


    print "Done."

    print "Going to hurricane:" + PATH

    os.chdir(PATH)


    from thread import start_new_thread
    start_new_thread(temp_tornado_thread, ())

    httpd = PloneIDEServer(config, PloneIDEHandler, myproject, handle)

    try:
        httpd.run()
    except KeyboardInterrupt:
        print "Closing the project..."
        myproject.close()
        httpd.stop()
开发者ID:collective,项目名称:collective.ploneide,代码行数:33,代码来源:main.py

示例2: getRopeProject

        def getRopeProject( self, fileName = "" ):
            " Provides existed or creates a new rope project "
            if self.project.isLoaded():
                return self.project.getRopeProject()

            # There is no current project so create a temporary one.
            # Two cases: the buffer has been saved
            #            not saved buffer
            if os.path.isabs( fileName ):
                dirName = os.path.dirname( fileName )
            else:
                # Unsaved buffer, make an assumption that
                # it is in home directory
                dirName = str( QDir.homePath() )

            prefs = copy.deepcopy( ropePreferences )

            # Exclude nested dirs as it could take too long
            # Get only dir names and do not get those dirs
            # where __init__.py[3] are present
            subdirsToExclude = getSubdirs( dirName, True, True )

            if "ignored_resources" in prefs:
                prefs[ "ignored_resources" ] += subdirsToExclude
            else:
                prefs[ "ignored_resources" ] = subdirsToExclude

            project = RopeProject( dirName, None, None, **prefs )
            project.validate( project.root )
            return project
开发者ID:eaglexmw,项目名称:codimension,代码行数:30,代码来源:globals.py

示例3: RopeComplete

class RopeComplete(object):
	def __init__(self, project_path, source_code, resource_path, code_point):
		self.project = Project(project_path)
		self.project.pycore._init_python_files()
		
		self.resource = self.project.get_resource(resource_path)
		self.source_code = source_code
		self.code_point = code_point

	def __del__(self):
		self.project.close()

	def get_proposals(self):
		ret = []
		proposals = codeassist.code_assist(self.project, self.source_code, self.code_point, resource=self.resource, maxfixes=10)
		proposals = codeassist.sorted_proposals(proposals)

		if V(ROPE_VERSION) <= V('0.9.2'):
			for proposal in proposals:
				ret.append(new_completion_item(name=proposal.name, scope=proposal.kind, type=proposal.type))
		else:
			for proposal in proposals:
				ret.append(new_completion_item(name=proposal.name, scope=proposal.scope, type=proposal.type))

		return ret

	def get_calltip(self):
		calltip = codeassist.get_doc(self.project, self.source_code, self.code_point, resource=self.resource, maxfixes=10)
		return calltip
开发者ID:VujinovM,项目名称:anjuta,代码行数:29,代码来源:anjuta-python-autocomplete.py

示例4: main

def main():
    prj = Project(os.path.realpath("../shuup/core/models"))
    rst = Restructure(prj, "_(${str})", "")
    rst.template = LanguageTwist("./shuup_fi_to_en.po")

    twist_set = rst.get_changes()

    for chg in twist_set.changes:
        print(chg.get_description())

    prj.do(twist_set)
开发者ID:NamiStudio,项目名称:shuup,代码行数:11,代码来源:language_twister.py

示例5: __init__

	def __init__(self, project_path, source_code, resource_path, code_point):
		self.project = Project(project_path)
		self.project.pycore._init_python_files()
		
		self.resource = self.project.get_resource(resource_path)
		self.source_code = source_code
		self.code_point = code_point
开发者ID:VujinovM,项目名称:anjuta,代码行数:7,代码来源:anjuta-python-autocomplete.py

示例6: Agent

class Agent(object):
    def __init__(self, target_file, dry_run):
        self.project = Project(os.getcwd())
        self.target_file = target_file
        self.dry_run = dry_run
        self.commands = []

    @property
    def resource(self):
        return File(self.project, self.target_file)

    def add_command_class(self, command_class):
        self.commands.append(command_class)

    def do(self):
        commands = [
            command_class(self.project, self.target_file, self.dry_run)
            for command_class in self.commands
        ]
        changesets = filter(
            lambda x: x is not None,
            [
                command.get_changeset()
                for command in commands
            ]
        )

        # merge changesets
        def merge_changesets(aggregated_changeset, next_changeset):
            for change in next_changeset.changes:
                aggregated_changeset.add_change(change)
            aggregated_changeset.description += next_changeset.description
            return aggregated_changeset

        new_changeset = reduce(
            merge_changesets,
            changesets,
            ChangeSet('')
        )

        if not new_changeset.changes:
            return

        if self.dry_run:
            print new_changeset.get_description()
        else:
            self.project.do(new_changeset)
开发者ID:kevinjqiu,项目名称:imporganizer,代码行数:47,代码来源:cli.py

示例7: _get_other_projects

 def _get_other_projects(path_only=False):
     """
     Gets the list of secondary projects (all except current).
     """
     projects = []
     current = api.project.get_current_project()
     for path in api.project.get_projects():
         if path == current:
             continue
         if not path_only:
             prj = Project(path, ropefolder=api.project.FOLDER,
                           fscommands=FileSystemCommands())
             prj.validate()
         else:
             prj = path
         projects.append(prj)
     return projects
开发者ID:SirmoGames,项目名称:hackedit-python,代码行数:17,代码来源:refactor.py

示例8: __init__

 def __init__(self, project_path=None, module_path=None):
     """ initialize using project path and optional sub module path to limit rename scope """
     if project_path:
         self.project = Project(project_path)
     self.module_path = module_path
     self.words = set()
     self.files = []
     self.namemap = {}
     self.classname_regex = re.compile('class\s+(?P<name>[a-zA-Z0-9_]+)')
     self.methodname_regex = re.compile('def\s+(?P<name>[a-zA-Z0-9_]+)')
开发者ID:patrikha,项目名称:pyrename,代码行数:10,代码来源:pyrename.py

示例9: test_source_folders_preference

 def test_source_folders_preference(self):
     testutils.create_package(self.project, 'pkg1')
     testutils.create_package(self.project, 'pkg1.src2')
     lost = testutils.create_module(self.project, 'pkg1.src2.lost')
     self.assertEqual(self.project.find_module('lost'), None)
     self.project.close()
     from rope.base.project import Project
     self.project = Project(self.project.address,
                            source_folders=['pkg1/src2'])
     self.assertEqual(self.project.find_module('lost'), lost)
开发者ID:DonJayamanne,项目名称:rope,代码行数:10,代码来源:pycoretest.py

示例10: _on_current_project_changed

 def _on_current_project_changed(self, path):
     """
     Changes the active rope project when the current project changed in
     the IDE.
     :param path: Path of the new project.
     """
     self._main_project.close()
     self._main_project = Project(path, ropefolder=api.project.FOLDER,
                                  fscommands=FileSystemCommands())
     self._main_project.validate()
开发者ID:SirmoGames,项目名称:hackedit-python,代码行数:10,代码来源:refactor.py

示例11: complete

    def complete(self):
        if TM_PROJECT_DIRECTORY is None:
            return ''
        #from rope.contrib import autoimport
        project = Project(TM_PROJECT_DIRECTORY)
        #autoimport = autoimport.AutoImport(project)
        resource = project.get_resource(TM_FILEPATH.replace(TM_PROJECT_DIRECTORY, '')[1:])
        #project.validate(self.project_path)
        caret_index = self.source.find(TM_CURRENT_LINE) + TM_LINE_INDEX
        try:
            proposals = codeassist.code_assist(project, self.source, caret_index, resource)
        except:
            ass = PythonCodeAssist(project)
            proposals = ass.assist(self.source, caret_index, resource)
        try:
            if len(proposals) == 0:
                return ''
        except:
            return ''
        if len(proposals) == 1:
            selection = proposals[0].name
        else:
            proposals = codeassist.sorted_proposals(proposals)
            #autoimport.generate_cache()
            #autoimport.generate_modules_cache(modules)
            #project.pycore.analyze_module(resource)
            names = [proposal.name for proposal in proposals]
            #if self.starting.strip() and '.' not in self.expression:
            #        import_assists = self.autoimport.import_assist(self.starting)
            #        names.extend(x[0] + ' : ' + x[1] for x in import_assists)

            #plist = "{ menuItems=(%s);}"
            selection = dialog.menu(names)
            if selection is None:
                return ''
        if TM_CURRENT_WORD is None:
            return selection
        else:
            return selection.replace(TM_CURRENT_WORD, '')
开发者ID:a-bot,项目名称:settings,代码行数:39,代码来源:textmate_rope.py

示例12: main

def main():
    # TODO: Determine if this is necessary. Can we still provide basic completion in a 'standalone' file?
    if textmate.PROJECT_DIRECTORY is None:
        textmate.exit_show_tool_tip('No completions.')

    source = sys.stdin.read()

    #from rope.contrib import autoimport
    project = Project(textmate.PROJECT_DIRECTORY)
    #autoimport = autoimport.AutoImport(project)
    resource = project.get_resource(textmate.FILEPATH.replace(textmate.PROJECT_DIRECTORY, '')[1:])
    #project.validate(self.project_path)
    caret_index = source.find(textmate.CURRENT_LINE) + textmate.LINE_INDEX

    current_word = textmate.current_word(r"[a-zA-Z_]*", 'both')

    proposals = codeassist.code_assist(project, source, caret_index, resource)
    
    try:
        if len(proposals) == 0:
            raise 'no proposals found'
    except:
        textmate.exit_show_tool_tip("No completions.")
    
    if len(proposals) == 1:
        textmate.exit_insert_text(proposals[0].name.replace(current_word, '', 1))
    else:
        proposals = codeassist.sorted_proposals(proposals)
        #autoimport.generate_cache()
        #autoimport.generate_modules_cache(modules)
        #project.pycore.analyze_module(resource)
        names = [proposal.name for proposal in proposals]
        #if self.starting.strip() and '.' not in self.expression:
        #        import_assists = self.autoimport.import_assist(self.starting)
        #        names.extend(x[0] + ' : ' + x[1] for x in import_assists)

        #plist = "{ menuItems=(%s);}"
        ui.complete(names, {'initial_filter': current_word, 'extra_chars': "_"})
开发者ID:lettertwo,项目名称:python.tmbundle,代码行数:38,代码来源:complete.py

示例13: test_loading_config_dot_py

 def test_loading_config_dot_py(self):
     self.project = testutils.sample_project(ropefolder='.ropeproject')
     config = self.project.get_file('.ropeproject/config.py')
     if not config.exists():
         config.create()
     config.write('def set_prefs(prefs):\n'
                  '    prefs["ignored_resources"] = ["myfile.txt"]\n'
                  'def project_opened(project):\n'
                  '    project.root.create_file("loaded")\n')
     self.project.close()
     self.project = Project(self.project.address, ropefolder='.ropeproject')
     self.assertTrue(self.project.get_file('loaded').exists())
     myfile = self.project.get_file('myfile.txt')
     self.assertTrue(self.project.is_ignored(myfile))
开发者ID:felix-d,项目名称:dot-files,代码行数:14,代码来源:projecttest.py

示例14: activate

 def activate(self):
     self._preview_dock = None
     self._occurrences_dock = None
     self._occurrences_results = None
     self._review_widget = None
     api.signals.connect_slot(api.signals.CURRENT_PROJECT_CHANGED,
                              self._on_current_project_changed)
     api.signals.connect_slot(api.signals.EDITOR_CREATED,
                              self._on_editor_created)
     api.signals.connect_slot(api.signals.CURRENT_EDITOR_CHANGED,
                              self._update_edit_actions_state)
     path = api.project.get_current_project()
     self._main_project = Project(path, ropefolder=api.project.FOLDER,
                                  fscommands=FileSystemCommands())
     self._main_project.validate()
     api.signals.connect_slot(api.signals.DOCUMENT_SAVED,
                              self._on_document_saved)
开发者ID:SirmoGames,项目名称:hackedit-python,代码行数:17,代码来源:refactor.py

示例15: __createRopeProject

    def __createRopeProject( self ):
        " Creates a rope library project "
        if self.__ropeProject is not None:
            self.__ropeProject.close()
            self.__ropeProject = None
            self.__ropeSourceDirs = []

        # Deal with import dirs and preferences first
        self.__ropeSourceDirs = self.__getImportDirsForRope()
        prefs = copy.deepcopy( ropePreferences )
        if len( self.__ropeSourceDirs ) != 0:
            prefs[ "source_folders" ] = self.__ropeSourceDirs

        # Rope folder is default here, so it will be created
        self.__ropeProject = RopeProject( self.getProjectDir(),
                                          **prefs )
        self.__ropeProject.validate( self.__ropeProject.root )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:18,代码来源:project.py


注:本文中的rope.base.project.Project类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。