Example #1
0
    def move_module(self, path, dest_folder):
        dest_res = self.get_folder(dest_folder)
        if not dest_res.exists():
            dest_res.create()

        mover = MoveModule(self.root_project,
                           self.get_resource(path))

        return mover.get_changes(dest_res)
Example #2
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)
Example #3
0
def _move_package(project: Project, source: str, target: str) -> None:
    """
    Move a Python package, refactoring relevant imports along the way.
    A target of empty string means moving to the root of the `project`.

    Args:
        project: rope.base.Project holding the scope of the refactoring.
        source: Name of the Python package to be moved. Can be a fully
            qualified module path relative to the `project` root, e.g.
            "package.pipelines.pipeline" or "package/pipelines/pipeline".
        target: Destination of the Python package to be moved. Can be a fully
            qualified module path relative to the `project` root, e.g.
            "package.pipelines.pipeline" or "package/pipelines/pipeline".
    """
    src_folder = project.get_module(source).get_resource()
    target_folder = project.get_module(target).get_resource()
    change = MoveModule(project, src_folder).get_changes(dest=target_folder)
    project.do(change)
from rope.base import project
from rope.refactor.move import MoveModule
from rope.refactor.rename import Rename

my_project = project.Project('.')

providers_dest = my_project.get_folder('cfme/providers')
if not providers_dest.exists():
    providers_dest.create()

if not providers_dest.get_children():
    providers_dest.create_file('__init__.py')

folders_to_process = ['infrastructure', 'cloud', 'middleware', 'containers']

for folder in folders_to_process:

    def find(fmt):
        return my_project.find_module(fmt.format(folder=folder))

    print(folder)
    print(" append name")
    res = find('cfme.{folder}.provider')
    Rename(my_project, res).get_changes('provider_' + folder).do()
    print(" move")
    res = find('cfme.{folder}.provider_{folder}')
    MoveModule(my_project, res).get_changes(providers_dest).do()
    print(" fix_name")
    res = find('cfme.providers.provider_{folder}')
    Rename(my_project, res).get_changes(folder).do()
Example #5
0
from rope.base.project import Project
from rope.refactor.move import MoveModule

project = Project('.')

utils = project.find_module('utils')
move = MoveModule(project, utils)
cfme = project.find_module('cfme')
print(cfme)
changes = move.get_changes(cfme)
changes.do()