コード例 #1
0
ファイル: __init__.py プロジェクト: aevri/ropecli
def rename(target, new_name):
    """Rename the global entry TARGET to NEW_NAME.

    All references to the entry will be adjusted to refer to the new name,
    including in documentation.

    e.g.

      rope rename modulea.py::MyClass MyAwesomeClass

    or

      rope rename modulea.py moduleb

    """
    project = rope.base.project.Project(".", ropefolder=".clirope")

    resource, offset = resourcespec_to_resource_offset(project, target)

    def very_sure(_):
        return True

    renamer = rope.refactor.rename.Rename(project, resource, offset)
    changes = renamer.get_changes(new_name, docs=True, unsure=very_sure)

    project.do(changes)
コード例 #2
0
ファイル: __init__.py プロジェクト: aevri/ropecli
def do_move(project, source, target_file):
    filefrom, offset = resourcespec_to_resource_offset(project, source)

    fileto = project.get_resource(target_file)

    mover = rope.refactor.move.create_move(project, filefrom, offset)
    changes = mover.get_changes(fileto)
    project.do(changes)
コード例 #3
0
def move_all_api_modules_to_package():
    print('API modules are moving their own packages.')
    for api_resource in api_resources.get_files():
        if api_resource.name != '__init__.py':
            print('\tfileName: ' + api_resource.name)

            moduleToPackage = ModuleToPackage(project, api_resource)
            changes = moduleToPackage.get_changes()
            project.do(changes)
コード例 #4
0
def rename_all_api_modules():
    print('API modules are renaming (drop redundant "_api" suffix).')
    for api_resource in api_resources.get_folders():
        if api_resource.name.endswith('_api'):
            rename = Rename(project, api_resource)
            new_name = rename.get_old_name().split('_api')[0]

            print('\told: ' + api_resource.name + ' new: ' + new_name)

            changes = rename.get_changes(new_name)
            project.do(changes)
コード例 #5
0
def get_result(changes, project, resource):
    # perform the changes
    project.do(changes)
    project.validate(resource)
    project.close()

    # get the refactored code from the temp file and return it
    file = io.open(TEMP_PATH)
    refactored_code = file.read()
    file.close()

    return refactored_code
コード例 #6
0
def move_domain_models():
    print('Domain specific models are moving to related api packages.')
    with open(sdk_generated_path + 'opsgenieCodegenModels.csv', mode='r') as csv_file:
        csv_reader = csv.DictReader(csv_file)

        for row in csv_reader:
            if row['opsgenieDomain'] != 'common':
                model_resource = libutils.path_to_resource(project,
                                                           sdk_generated_path + sdk_path + 'models/' + row['classFilename'] + '.py',
                                                           'file')
                model_dest_resource = libutils.path_to_resource(project,
                                                                sdk_generated_path + sdk_path + 'api/' + row['opsgenieDomain'],
                                                                'folder')

                if model_resource.exists() and model_dest_resource.exists():
                    print('\tclassname: ' + row["classname"] + ' classFilename: ' + row["classFilename"] + ' opsgenieDomain: ' + row["opsgenieDomain"])

                    moveModule = MoveModule(project, model_resource)
                    changes = moveModule.get_changes(model_dest_resource)
                    project.do(changes)
コード例 #7
0
def perform(project_changes):
    for project, changes in project_changes:
        project.do(changes)
コード例 #8
0
ファイル: multiproject.py プロジェクト: 0Chuzz/python-mode
def perform(project_changes):
    for project, changes in project_changes:
        project.do(changes)
コード例 #9
0
import rope.base.project
from rope.base import libutils

from rope.refactor.extract import ExtractVariable

project = rope.base.project.Project('../lib/ansible')

resource = libutils.path_to_resource(
    project, '../lib/ansible/collections/list.py')

extractor = ExtractVariable(project, resource, 1, 50)

changes = extractor.get_changes('extracted_variable')

project.do(changes)