FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonVSCode/pythonFiles/rope/refactor/multiproject.py at master · MightyWing/pythonVSCode · GitHub
MightyWing
/
pythonVSCode
Public
forked from
DonJayamanne/pythonVSCode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonVSCode
/
pythonFiles
/
rope
/
refactor
/
multiproject.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (58 loc) · 2.55 KB
Breadcrumbs
pythonVSCode
/
pythonFiles
/
rope
/
refactor
/
multiproject.py
Copy path
File metadata and controls
78 lines (58 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""This module can be used for performing cross-project refactorings
See the "cross-project refactorings" section of ``docs/library.rst``
file.
"""
from
rope
.
base
import
resources
,
libutils
class
MultiProjectRefactoring
(
object
):
def
__init__
(
self
,
refactoring
,
projects
,
addpath
=
True
):
"""Create a multiproject proxy for the main refactoring
`projects` are other project.
"""
self
.
refactoring
=
refactoring
self
.
projects
=
projects
self
.
addpath
=
addpath
def
__call__
(
self
,
project
,
*
args
,
**
kwds
):
"""Create the refactoring"""
return
_MultiRefactoring
(
self
.
refactoring
,
self
.
projects
,
self
.
addpath
,
project
,
*
args
,
**
kwds
)
class
_MultiRefactoring
(
object
):
def
__init__
(
self
,
refactoring
,
other_projects
,
addpath
,
project
,
*
args
,
**
kwds
):
self
.
refactoring
=
refactoring
self
.
projects
=
[
project
]
+
other_projects
for
other_project
in
other_projects
:
for
folder
in
self
.
project
.
get_source_folders
():
other_project
.
get_prefs
().
add
(
'python_path'
,
folder
.
real_path
)
self
.
refactorings
=
[]
for
other
in
self
.
projects
:
args
,
kwds
=
self
.
_resources_for_args
(
other
,
args
,
kwds
)
self
.
refactorings
.
append
(
self
.
refactoring
(
other
,
*
args
,
**
kwds
))
def
get_all_changes
(
self
,
*
args
,
**
kwds
):
"""Get a project to changes dict"""
result
=
[]
for
project
,
refactoring
in
zip
(
self
.
projects
,
self
.
refactorings
):
args
,
kwds
=
self
.
_resources_for_args
(
project
,
args
,
kwds
)
result
.
append
((
project
,
refactoring
.
get_changes
(
*
args
,
**
kwds
)))
return
result
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
main_refactoring
,
name
)
def
_resources_for_args
(
self
,
project
,
args
,
kwds
):
newargs
=
[
self
.
_change_project_resource
(
project
,
arg
)
for
arg
in
args
]
newkwds
=
dict
((
name
,
self
.
_change_project_resource
(
project
,
value
))
for
name
,
value
in
kwds
.
items
())
return
newargs
,
newkwds
def
_change_project_resource
(
self
,
project
,
obj
):
if
isinstance
(
obj
,
resources
.
Resource
)
and
\
obj
.
project
!=
project
:
return
libutils
.
path_to_resource
(
project
,
obj
.
real_path
)
return
obj
@
property
def
project
(
self
):
return
self
.
projects
[
0
]
@
property
def
main_refactoring
(
self
):
return
self
.
refactorings
[
0
]
def
perform
(
project_changes
):
for
project
,
changes
in
project_changes
:
project
.
do
(
changes
)
Back
|
FazBrowse Home
|
New Git URL