本文整理汇总了Python中rope.base.project.Project.close方法的典型用法代码示例。如果您正苦于以下问题:Python Project.close方法的具体用法?Python Project.close怎么用?Python Project.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rope.base.project.Project
的用法示例。
在下文中一共展示了Project.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
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()
示例2: RopeComplete
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
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
示例3: CodimensionProject
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
#.........这里部分代码省略.........
self.projectChanged.emit( self.CompleteProject )
return
@staticmethod
def __safeRemove( path ):
" Safe file removal "
try:
os.remove( path )
except:
return
def __removeProjectFiles( self, userProjectDir ):
" Removes user project files "
self.__safeRemove( userProjectDir + "project" )
self.__safeRemove( userProjectDir + "bookmarks" )
self.__safeRemove( userProjectDir + "todos" )
self.__safeRemove( userProjectDir + "searchhistory" )
self.__safeRemove( userProjectDir + "topleveldirs" )
self.__safeRemove( userProjectDir + "tabsstatus" )
self.__safeRemove( userProjectDir + "findinfiles" )
self.__safeRemove( userProjectDir + "recentfiles" )
self.__safeRemove( userProjectDir + "filebrowser" )
self.__safeRemove( userProjectDir + "ignoredexcpt" )
self.__safeRemove( userProjectDir + "breakpoints" )
self.__safeRemove( userProjectDir + "watchpoints" )
return
def __createProjectFile( self ):
" Helper function to create the user project file "
try:
f = open( self.userProjectDir + "project", "w" )
f.write( self.fileName )
f.close()
except:
return
def saveProject( self ):
" Writes all the settings into the file "
if not self.isLoaded():
return
# Project properties part
propertiesPart = "[properties]\n" \
"scriptname=" + self.scriptName + "\n" \
"creationdate=" + self.creationDate + "\n" \
"author=" + self.author + "\n" \
"license=" + self.license + "\n" \
"copyright=" + self.copyright + "\n" \
"description=" + \
self.description.replace( '\n', '<CR><LF>' ) + \
"\n" \
"version=" + self.version + "\n" \
"email=" + self.email + "\n" \
"uuid=" + self.uuid + "\n"
# It could be another user project file without write permissions
skipProjectFile = False
if os.path.exists( self.fileName ):
if not os.access( self.fileName, os.W_OK ):
skipProjectFile = True
else:
if not os.access( os.path.dirname( self.fileName ), os.W_OK ):
skipProjectFile = True
if not skipProjectFile:
示例4: Refactor
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
class Refactor(QtGui.QWidget):
def __init__(self, editorTabWidget, busyWidget, parent=None):
QtGui.QWidget.__init__(self, parent)
self.editorTabWidget = editorTabWidget
self.busyWidget = busyWidget
self.root = editorTabWidget.pathDict["sourcedir"]
ropeFolder = editorTabWidget.pathDict["ropeFolder"]
prefs = {
'ignored_resources': ['*.pyc', '*~', '.ropeproject',
'.hg', '.svn', '_svn', '.git',
'__pycache__'],
'python_files': ['*.py'],
'save_objectdb': True,
'compress_objectdb': False,
'automatic_soa': True,
'soa_followed_calls': 0,
'perform_doa': True,
'validate_objectdb': True,
'max_history_items': 32,
'save_history': True,
'compress_history': False,
'indent_size': 4,
'extension_modules': [
"PyQt4", "PyQt4.QtGui", "QtGui", "PyQt4.QtCore", "QtCore",
"PyQt4.QtScript", "QtScript", "os.path", "numpy", "scipy", "PIL",
"OpenGL", "array", "audioop", "binascii", "cPickle", "cStringIO",
"cmath", "collections", "datetime", "errno", "exceptions", "gc",
"imageop", "imp", "itertools", "marshal", "math", "mmap", "msvcrt",
"nt", "operator", "os", "parser", "rgbimg", "signal", "strop", "sys",
"thread", "time", "wx", "wxPython", "xxsubtype", "zipimport", "zlib"
],
'import_dynload_stdmods': True,
'ignore_syntax_errors': True,
'ignore_bad_imports': True
}
self.ropeProject = Project(
projectroot=self.root, ropefolder=ropeFolder, **prefs)
self.ropeProject.prefs.add('python_path', 'c:/Python33')
self.ropeProject.prefs.add('source_folders', 'c:/Python33/Lib')
self.ropeProject.validate()
self.noProject = Project(projectroot="temp", ropefolder=None)
self.findThread = FindUsageThread()
self.findThread.finished.connect(self.findOccurrencesFinished)
self.renameThread = RenameThread()
self.renameThread.finished.connect(self.renameFinished)
self.inlineThread = InlineThread()
self.inlineThread.finished.connect(self.inlineFinished)
self.localToFieldThread = LocalToFieldThread()
self.localToFieldThread.finished.connect(self.localToFieldFinished)
self.moduleToPackageThread = ModuleToPackageThread()
self.moduleToPackageThread.finished.connect(
self.moduleToPackageFinished)
self.createActions()
self.refactorMenu = QtGui.QMenu("Refactor")
self.refactorMenu.addAction(self.renameAttributeAct)
self.refactorMenu.addAction(self.inlineAct)
self.refactorMenu.addAction(self.localToFieldAct)
def close(self):
self.ropeProject.close()
def createActions(self):
self.findDefAct = \
QtGui.QAction(
QtGui.QIcon(os.path.join("Resources", "images", "map_marker")),
"Go-to Definition", self, statusTip="Go-to Definition",
triggered=self.findDefinition)
self.findOccurrencesAct = \
QtGui.QAction("Usages", self, statusTip="Usages",
triggered=self.findOccurrences)
self.moduleToPackageAct = \
QtGui.QAction(
"Convert to Package", self, statusTip="Convert to Package",
triggered=self.moduleToPackage)
self.renameModuleAct = \
QtGui.QAction("Rename", self, statusTip="Rename",
triggered=self.renameModule)
self.renameAttributeAct = \
QtGui.QAction("Rename", self, statusTip="Rename",
triggered=self.renameAttribute)
self.inlineAct = \
QtGui.QAction("Inline", self, statusTip="Inline",
triggered=self.inline)
#.........这里部分代码省略.........
示例5: Project
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
option = option_arg;
projectpath = project_arg
if projectpath.startswith("file://"):
projectpath = projectpath.replace("file://", "")
proj = Project(projectpath)
proj.pycore._init_python_files()
input = open(source_code_arg, 'r')
source_code = input.read()
respath = relpath(projectpath, res_arg)
res = proj.get_resource(respath)
position = int(offset_arg)
try:
if option == "autocomplete":
proposals = codeassist.code_assist(proj, source_code, position, resource=res, maxfixes=10)
proposals = codeassist.sorted_proposals(proposals)
for proposal in proposals:
print proposal
elif option == "calltip":
proposals = codeassist.get_doc(proj, source_code, position, resource=res, maxfixes=10)
print proposals
except:
pass
proj.close()
示例6: find_usages
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
def find_usages(_, main_project, other_projects, file_path, offset):
"""
Find usages of symbol under cursor.
"""
try:
occurrences = []
if other_projects:
for path in [main_project] + other_projects:
prj = Project(path, ropefolder=api.project.FOLDER,
fscommands=FileSystemCommands())
prj.validate()
mod = libutils.path_to_resource(prj, file_path)
occurrences += find_occurrences(
prj, mod, offset, unsure=False, in_hierarchy=True)
prj.close()
else:
prj = Project(main_project, ropefolder=api.project.FOLDER,
fscommands=FileSystemCommands())
prj.validate()
mod = libutils.path_to_resource(prj, file_path)
occurrences = find_occurrences(prj, mod, offset, unsure=False,
in_hierarchy=True)
# transform results to a serialisable list of usages that is ready
# to use by the find_results widget.
occurrences_map = {}
for location in occurrences:
path = location.resource.real_path
lineno = location.lineno - 1
# convert file region to line region
content = location.resource.read()
offset = location.offset
char = content[offset]
while char != '\n': # find start of line
offset -= 1
char = content[offset]
# update offsets
start = location.offset - offset - 1
end = location.region[1] - offset - 1
line_text = content.splitlines()[lineno]
data = (lineno, line_text, [(start, end)])
if path not in occurrences_map:
occurrences_map[path] = [data]
else:
occurrences_map[path].append(data)
results = []
for key, value in occurrences_map.items():
results.append((key, value))
results = sorted(results, key=lambda x: x[0])
return results
except RopeError as e:
error = RefactoringError()
error.exc = str(e)
error.traceback = traceback.format_exc()
error.critical = False
return error
except Exception as e:
error = RefactoringError()
error.exc = str(e)
error.traceback = traceback.format_exc()
error.critical = True
return error
示例7: PyRefactor
# 需要导入模块: from rope.base.project import Project [as 别名]
# 或者: from rope.base.project.Project import close [as 别名]
class PyRefactor(plugins.WorkspacePlugin):
"""
Adds some refactoring capabilities to the IDE (using the rope library).
Supported operations:
- Rename
- Extract method
- Extract variable
- Find occurrences
- Organize imports
"""
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)
def close(self):
self._main_project.close()
def rename(self):
"""
Renames word under cursor.
"""
editor = api.editor.get_current_editor()
if editor is None:
return
editor.file.save()
assert isinstance(editor, PyCodeEdit)
module = libutils.path_to_resource(
self._main_project, editor.file.path)
self._main_project.validate()
cursor_position = self._get_real_position(
editor.textCursor().position())
try:
renamer = Rename(self._main_project, module, cursor_position)
except RopeError:
return
if not renamer.get_old_name():
return
preview, replacement = DlgRope.rename(
self.main_window, renamer.get_old_name())
if preview is None and replacement is None:
return
multiproj = self._has_multiple_projects()
other_projects = self._get_other_projects()
main_project = self._main_project
self._preview = preview
api.tasks.start(_('Refactoring: rename'), rename_symbol,
self._on_changes_available,
args=(
main_project, multiproj, other_projects,
editor.file.path, cursor_position, replacement),
cancellable=True, use_thread=True)
def organise_imports(self):
editor = api.editor.get_current_editor()
api.editor.save_all_editors()
if editor is None:
return
self._preview = True
file_path = editor.file.path
project = self.get_project_for_file(file_path)
if project:
api.tasks.start(
_('Refactoring: organize imports'), organize_imports,
self._on_changes_available,
args=(project, file_path),
cancellable=True, use_thread=True)
def extract_method(self):
"""
Extracts a method from the selected text (if possible, otherwise a
warning message will appear).
"""
api.editor.save_all_editors()
self._main_project.validate()
editor = api.editor.get_current_editor()
if editor is None or not editor.textCursor().hasSelection():
return
editor.file.save()
if not editor.textCursor().hasSelection():
TextHelper(editor).select_whole_line()
start = self._get_real_position(editor.textCursor().selectionStart())
end = self._get_real_position(editor.textCursor().selectionEnd())
preview, replacement = DlgRope.extract_method(self.main_window)
if preview is None and replacement is None:
#.........这里部分代码省略.........