source: orange/Orange/fixes/fix_changed_names.py @ 9920:6fa60e34fd8c

Revision 9920:6fa60e34fd8c, 45.2 KB checked in by markotoplak, 2 years ago (diff)

Merged.

Line 
1""" This fixer changes all occurrences of the form 'module.member' from the
2global dictionary MAPPING's keys and replaces them with the corresponding
3value. It adds the proper imports to make it available in the script.
4
5For example this code::
6    import orange
7    import orngSVM
8    data = orange.ExampleTable("iris")
9    learner = orngSVM.SVMLearner(name='svm')
10   
11will be replaced with::
12    import Orange.data
13    import Orange.classification.svm
14    data = Orange.data.Table('iris')
15    learner = Orange.classification.svm.SVMLearner(name='svm')
16   
17Try to add as much name mappings as possible (This fixer is prefered
18(and will run before) the fix_orange_imports 
19   
20"""
21from lib2to3 import fixer_base
22from lib2to3 import pytree
23from lib2to3.fixer_util import Name, Dot, touch_import
24
25# Keys must be in the form of 'orange.name' not name or orange.bla.name
26# If the values name a doted name inside of the package the package and name
27# must be separated by ':' e.g. Orange.classification:Classifier.GetValue
28# indicates Classifier.GetValue is a name inside package Orange.classification,
29# do not use Orange.classification.Classifier.GetValue as this is assumed that
30# Orange.classification.Classifier is a package
31#
32MAPPING = {"orange.ExampleTable": "Orange.data.Table",
33           "orange.Example": "Orange.data.Instance",
34           "orange.Domain": "Orange.data.Domain",
35           "orange.Value": "Orange.data.Value",
36           "orange.VarTypes": "Orange.data.Type",
37           "orange.Variable": "Orange.feature.Descriptor",
38           "orange.EnumVariable": "Orange.feature.Discrete",
39           "orange.FloatVariable": "Orange.feature.Continuous",
40           "orange.StringVariable": "Orange.feature.String",
41           "orange.PythonVariable": "Orange.feature.Python",
42
43           "orange.newmetaid": "Orange.feature.new_meta_id",
44
45           "orange.SymMatrix": "Orange.misc.SymMatrix",
46
47           "orange.GetValue": "Orange.classification:Classifier.GetValue",
48           "orange.GetProbabilities": "Orange.classification:Classifier.GetProbabilities",
49           "orange.GetBoth": "Orange.classification:Classifier.GetBoth",
50
51           "orange.Distribution": "Orange.statistics.distribution.Distribution",
52           "orange.DiscDistribution": "Orange.statistics.distribution.Discrete",
53           "orange.ContDistribution": "Orange.statistics.distribution.Continuous",
54           "orange.GaussianDistribution": "Orange.statistics.distribution.Gaussian",
55           "orange.DomainDistributions": "Orange.statistics.distribution.Domain",
56
57           "orange.BasicAttrStat": "Orange.statistics.basic.Variable",
58           "orange.DomainBasicAttrStat": "Orange.statistics.basic.Domain",
59
60           "orange.ContingencyAttrAttr": "Orange.statistics.contingency.VarVar",
61           "orange.ContingencyClass": "Orange.statistics.contingency.Class",
62           "orange.ContingencyAttrClass": "Orange.statistics.contingency.VarClass",
63           "orange.ContingencyClassAttr": "Orange.statistics.contingency.ClassVar",
64           "orange.DomainContingency": "Orange.statistics.contingency.Domain",
65           "orange.Contingency": "Orange.statistics.contingency.Table",
66
67           "orange.MeasureAttribute": "Orange.feature.scoring.Score",
68           "orange.MeasureAttributeFromProbabilities": "Orange.feature.scoring.ScoreFromProbabilities",
69           "orange.MeasureAttribute_gainRatio": "Orange.feature.scoring.GainRatio",
70           "orange.MeasureAttribute_relief": "Orange.feature.scoring.Relief",
71           "orange.MeasureAttribute_info": "Orange.feature.scoring.InfoGain",
72           "orange.MeasureAttribute_gini": "Orange.feature.scoring.Gini",
73
74           "orange.MeasureAttribute_relevance": "Orange.feature.scoring.Relevance",
75           "orange.MeasureAttribute_cost": "Orange.feature.scoring.Cost",
76           "orange.MeasureAttribute_MSE": "Orange.feature.scoring.MSE",
77
78           "orange.EntropyDiscretization": "Orange.feature.discretization.Entropy",
79           "orange.EquiDistDiscretization": "Orange.feature.discretization.EqualWidth",
80           "orange.EquiNDiscretization": "Orange.feature.discretization.EqualFreq",
81           "orange.BiModalDiscretization": "Orange.feature.discretization.BiModal",
82
83           "orngFSS.attMeasure": "Orange.feature.scoring.score_all",
84           "orngFSS.bestNAtts": "Orange.feature.selection.best_n",
85           "orngFSS.attsAbovethreshold": "Orange.feature.selection.above_threshold",
86           "orngFSS.selectBestNAtts": "Orange.feature.selection.select_best_n",
87           "orngFSS.selectAttsAboveThresh": "Orange.feature.selection.select_above_threshold",
88           "orngFSS.filterRelieff": "Orange.feature.selection.select_relief",
89           "orngFSS.FilterAttsAboveThresh": "Orange.feature.selection.FilterAboveThreshold",
90           "orngFSS.FilterAttsAboveThresh_Class": "Orange.feature.selection.FilterAboveThreshold",
91           "orngFSS.FilterBestNAtts": "Orange.feature.selection.FilterBestN",
92           "orngFSS.FilterBestNAtts_Class": "Orange.feature.selection.FilterBestN",
93           "orngFSS.FilterRelief": "Orange.feature.selection.FilterRelief",
94           "orngFSS.FilterRelief_Class": "Orange.feature.selection.FilterRelief",
95           "orngFSS.FilteredLearner": "Orange.feature.selection.FilteredLearner",
96           "orngFSS.FilteredLearner_Class": "Orange.feature.selection.FilteredLearner",
97           "orngFSS.FilteredClassifier": "Orange.feature.selection.FilteredClassifier",
98           "orngFSS.StepwiseLearner_Class": "Orange.classification.wrappers.StepwiseLearner",
99           "orngFSS.StepwiseLearner": "Orange.classification.wrappers.StepwiseLearner",
100
101           "orange.ImputerConstructor_model": "Orange.feature.imputation.ImputerConstructor_model",
102           "orange.Imputer_model": "Orange.feature.imputation.Imputer_model",
103           "orange.Imputer_defaults": "Orange.feature.imputation.Imputer_defaults",
104           "orange.ImputerConstructor_asValue": "Orange.feature.imputation.ImputerConstructor_asValue",
105           "orange.ImputerConstructor_minimal": "Orange.feature.imputation.ImputerConstructor_minimal",
106           "orange.ImputerConstructor_maximal": "Orange.feature.imputation.ImputerConstructor_maximal",
107           "orange.ImputerConstructor_average": "Orange.feature.imputation.ImputerConstructor_average",
108
109           "orange.ExamplesDistance": "Orange.distance.Distance",
110           "orange.ExamplesDistance_Normalized": "Orange.distance.DistanceNormalized",
111           "orange.ExamplesDistanceConstructor": "Orange.distance.DistanceConstructor",
112           "orange.ExamplesDistance_Hamming": "Orange.distance.HammingDistance",
113           "orange.ExamplesDistance_DTW": "Orange.distance.DTWDistance",
114           "orange.ExamplesDistance_Euclidean": "Orange.distance.EuclideanDistance",
115           "orange.ExamplesDistance_Manhattan": "Orange.distance.ManhattanDistance",
116           "orange.ExamplesDistance_Maximal": "Orange.distance.MaximalDistance",
117           "orange.ExamplesDistance_Relief": "Orange.distance.ReliefDistance",
118
119           "orange.ExamplesDistanceConstructor_DTW": "Orange.distance.DTW",
120           "orange.ExamplesDistanceConstructor_Euclidean": "Orange.distance.Euclidean",
121           "orange.ExamplesDistanceConstructor_Hamming": "Orange.distance.Hamming",
122           "orange.ExamplesDistanceConstructor_Manhattan": "Orange.distance.Manhattan",
123           "orange.ExamplesDistanceConstructor_Maximal": "Orange.distance.Maximal",
124           "orange.ExamplesDistanceConstructor_Relief": "Orange.distance.Relief",
125
126           "orngClustering.ExamplesDistanceConstructor_PearsonR": "Orange.distance.PearsonR",
127           "orngClustering.ExamplesDistance_PearsonR": "Orange.distance.PearsonRDistance",
128           "orngClustering.ExamplesDistanceConstructor_SpearmanR": "Orange.distance.SpearmanR",
129           "orngClustering.ExamplesDistance_SpearmanR": "Orange.distance.SpearmanRDistance",
130
131           "orngClustering.KMeans": "Orange.clustering.kmeans.Clustering",
132           "orngClustering.kmeans_init_random": "Orange.clustering.kmeans.init_random",
133           "orngClustering.kmeans_init_diversity": "Orange.clustering.kmeans.init_diversity",
134           "orngClustering.KMeans_init_hierarchicalClustering": "Orange.clustering.kmeans.init_hclustering",
135           "orngClustering.data_center": "Orange.clustering.kmeans.data_center",
136           "orngClustering.plot_silhouette": "Orange.clustering.kmeans.plot_silhouette",
137           "orngClustering.score_distance_to_centroids": "Orange.clustering.kmeans.score_distance_to_centroids",
138           "orngClustering.score_silhouette": "Orange.clustering.kmeans.score_silhouette",
139
140           "orange.HierarchicalClustering": "Orange.clustering.hierarchical.HierarchicalClustering",
141           "orange.HierarchicalCluster": "Orange.clustering.hierarchical.HierarchicalCluster",
142           "orngClustering.hierarchicalClustering": "Orange.clustering.hierarchical.clustering",
143           "orngClustering.hierarchicalClustering_attributes": "Orange.clustering.hierarchical.clustering_features",
144           "orngClustering.hierarchicalClustering_clusterList": "Orange.clustering.hierarchical.cluster_to_list",
145           "orngClustering.hierarchicalClustering_topClusters": "Orange.clustering.hierarchical.top_clusters",
146           "orngClustering.hierarhicalClustering_topClustersMembership": "Orange.clustering.hierarchical.top_cluster_membership",
147           "orngClustering.orderLeaves": "Orange.clustering.hierarchical.order_leaves",
148           "orngClustering.dendrogram_draw": "Orange.clustering.hierarchical.dendrogram_draw",
149           "orngClustering.DendrogramPlot": "Orange.clustering.hierarchical.DendrogramPlot",
150           "orngClustering.DendrogramPlotPylab": "Orange.clustering.hierarchical.DendrogramPlotPylab",
151
152           "orngSVM.RBFKernelWrapper": "Orange.classification.svm.kernels.RBFKernelWrapper",
153           "orngSVM.CompositeKernelWrapper": "Orange.classification.svm.kernels.CompositeKernelWrapper",
154           "orngSVM.KernelWrapper": "Orange.classification.svm.kernels.KernelWrapper",
155           "orngSVM.DualKernelWrapper": "Orange.classification.svm.kernels.DualKernelWrapper",
156           "orngSVM.PolyKernelWrapper": "Orange.classification.svm.kernels.PolyKernelWrapper",
157           "orngSVM.AdditionKernelWrapper": "Orange.classification.svm.kernels.AdditionKernelWrapper",
158           "orngSVM.MultiplicationKernelWrapper": "Orange.classification.svm.kernels.MultiplicationKernelWrapper",
159           "orngSVM.SparseLinKernel": "Orange.classification.svm.kernels.SparseLinKernel",
160           "orngSVM.BagOfWords": "Orange.classification.svm.kernels.BagOfWords",
161           "orngSVM.SVMLearner": "Orange.classification.svm.SVMLearner",
162           "orngSVM.SVMLearnerEasy": "Orange.classification.svm.SVMLearnerEasy",
163           "orngSVM.SVMLearnerSparse": "Orange.classification.svm.SVMLearnerSparse",
164
165           "orange.kNNLearner":"Orange.classification.knn.kNNLearner",
166           "orange.kNNClassifier":"Orange.classification.knn.kNNClassifier",
167           "orange.FindNearest_BruteForce":"Orange.classification.knn.FindNearest",
168           "orange.FindNearestConstructor_BruteForce":"Orange.classification.knn.FindNearestConstructor",
169           "orange.P2NN":"Orange.classification.knn.P2NN",
170
171           "orange.BayesLearner":"Orange.classification.bayes.NaiveLearner",
172           "orange.BayesClassifier":"Orange.classification.bayes.NaiveClassifier",
173           "orngBayes.BayesLearner":"Orange.classification.bayes.NaiveLearner",
174           "orngBayes.BayesClassifier":"Orange.classification.bayes.NaiveClassifier",
175           "orngBayes.printModel": "Orange.classification.bayes.printModel",
176
177           "orngNetwork.MdsTypeClass":"Orange.network.MdsTypeClass",
178           "orngNetwork.Network":"Orange.network.Network",
179           "orngNetwork.NetworkOptimization":"Orange.network.NetworkOptimization",
180           "orngNetwork.NetworkClustering":"Orange.network.NetworkClustering",
181           "orange.Graph":"Orange.network.Graph",
182           "orange.GraphAsList":"Orange.network.GraphAsList",
183           "orange.GraphAsMatrix":"Orange.network.GraphAsMatrix",
184           "orange.GraphAsTree":"Orange.network.GraphAsTree",
185
186           "orange.TreeLearner": "Orange.classification.tree.TreeLearner",
187           "orange.TreeClassifier": "Orange.classification.tree.TreeClassifier",
188           "orange.C45Learner": "Orange.classification.tree.C45Learner",
189           "orange.C45Classifier": "Orange.classification.tree.C45Classifier",
190           "orange.C45TreeNode": "Orange.classification.tree.C45Node",
191           "orange.C45TreeNodeList": "Orange.classification.tree.C45NodeList",
192           "orange.TreeDescender": "Orange.classification.tree.Descender",
193           "orange.TreeDescender_UnknownMergeAsBranchSizes": "Orange.classification.tree.Descender_UnknownMergeAsBranchSizes",
194           "orange.TreeDescender_UnknownMergeAsSelector": "Orange.classification.tree.Descender_UnknownMergeAsSelector",
195           "orange.TreeDescender_UnknownToBranch": "Orange.classification.tree.Descender_UnknownToBranch",
196           "orange.TreeDescender_UnknownToCommonBranch": "Orange.classification.tree.Descender_UnknownToCommonBranch",
197           "orange.TreeDescender_UnknownToCommonSelector":"Orange.classification.tree.Descender_UnknownToCommonSelector",
198           "orange.TreeExampleSplitter":"Orange.classification.tree.Splitter",
199           "orange.TreeExampleSplitter_IgnoreUnknowns":"Orange.classification.tree.Splitter_IgnoreUnknowns",
200           "orange.TreeExampleSplitter_UnknownsAsBranchSizes":"Orange.classification.tree.Splitter_UnknownsAsBranchSizes",
201           "orange.TreeExampleSplitter_UnknownsAsSelecto":"Orange.classification.tree.Splitter_UnknownsAsSelector",
202           "orange.TreeExampleSplitter_UnknownsToAll":"Orange.classification.tree.Splitter_UnknownsToAll",
203           "orange.TreeExampleSplitter_UnknownsToBranch":"Orange.classification.tree.Splitter_UnknownsToBranch",
204           "orange.TreeExampleSplitter_UnknownsToCommon":"Orange.classification.tree.Splitter_UnknownsToCommon",
205           "orange.TreeExampleSplitter_UnknownsToRandom":"Orange.classification.tree.Splitter_UnknownsToRandom",
206           "orange.TreeNode":"Orange.classification.tree.Node",
207           "orange.TreeNodeList":"Orange.classification.tree.NodeList",
208           "orange.TreePruner":"Orange.classification.tree.Pruner",
209           "orange.TreePruner_SameMajority":"Orange.classification.tree.Pruner_SameMajority",
210           "orange.TreePruner_m":"Orange.classification.tree.Pruner_m",
211           "orange.TreeSplitConstructor":"Orange.classification.tree.SplitConstructor",
212           "orange.TreeSplitConstructor_Combined":"Orange.classification.tree.SplitConstructor_Combined",
213           "orange.TreeSplitConstructor_Measure":"Orange.classification.tree.SplitConstructor_Score",
214           "orange.TreeSplitConstructor_Attribute":"Orange.classification.tree.SplitConstructor_Feature",
215           "orange.TreeSplitConstructor_ExhaustiveBinary":"Orange.classification.tree.SplitConstructor_ExhaustiveBinary",
216           "orange.TreeSplitConstructor_OneAgainstOthers":"Orange.classification.tree.SplitConstructor_OneAgainstOthers",
217           "orange.TreeSplitConstructor_Threshold":"Orange.classification.tree.SplitConstructor_Threshold",
218           "orange.TreeStopCriteria":"Orange.classification.tree.StopCriteria",
219           "orange.TreeStopCriteria_Python":"Orange.classification.tree.StopCriteria_Python",
220           "orange.TreeStopCriteria_common":"Orange.classification.tree.StopCriteria_common",
221
222           "orngTree.printTxt": "Orange.classification.tree:TreeClassifier.dump",
223           "orngTree.printTree": "Orange.classification.tree:TreeClassifier.dump",
224           "orngTree.dumpTree": "Orange.classification.tree:TreeClassifier.dump",
225           "orngTree.printDot": "Orange.classification.tree:TreeClassifier.dot",
226           "orngTree.dotTree": "Orange.classification.tree:TreeClassifier.dot",
227           "orngTree.dump": "Orange.classification.tree:TreeClassifier.dump",
228           "orngTree.dot": "Orange.classification.tree:TreeClassifier.dot",
229           "orngTree.countLeaves": "Orange.classification.tree:TreeClassifier.count_leaves",
230           "orngTree.countNodes": "Orange.classification.tree:TreeClassifier.count_nodes",
231           "orngTree.byWhom": "Orange.classification.tree.by_whom",
232           "orngTree.insertStr": "Orange.classification.tree.insert_str",
233           "orngTree.insertDot": "Orange.classification.tree.insert_dot",
234           "orngTree.insertNum": "Orange.classification.tree.insert_num",
235
236           "orange.MajorityLearner":"Orange.classification.majority.MajorityLearner",
237           "orange.DefaultClassifier":"Orange.classification.ConstantClassifier",
238
239           "orange.LookupLearner":"Orange.classification.lookup.LookupLearner",
240           "orange.ClassifierByLookupTable":"Orange.classification.lookup.ClassifierByLookupTable",
241           "orange.ClassifierByLookupTable1":"Orange.classification.lookup.ClassifierByLookupTable1",
242           "orange.ClassifierByLookupTable2":"Orange.classification.lookup.ClassifierByLookupTable2",
243           "orange.ClassifierByLookupTable3":"Orange.classification.lookup.ClassifierByLookupTable3",
244           "orange.ClassifierByExampleTable":"Orange.classification.lookup.ClassifierByDataTable",
245
246           "orngLookup.lookupFromBound":"Orange.classification.lookup.lookup_from_bound",
247           "orngLookup.lookupFromExamples":"Orange.classification.lookup.lookup_from_data",
248           "orngLookup.lookupFromFunction":"Orange.classification.lookup.lookup_from_function",
249           "orngLookup.printLookupFunction":"Orange.classification.lookup.dump_lookup_function",
250
251           "orange.AssociationRule" : "Orange.associate.AssociationRule",
252           "orange.AssociationRules" : "Orange.associate.AssociationRules",
253           "orange.AssociationRulesInducer" : "Orange.associate.AssociationRulesInducer",
254           "orange.AssociationRulesSparseInducer" : "Orange.associate.AssociationRulesSparseInducer",
255           "orange.ItemsetNodeProxy" : "Orange.associate.ItemsetNodeProxy",
256           "orange.ItemsetsSparseInducer" : "Orange.associate.ItemsetsSparseInducer",
257
258           "orngCN2.ruleToString": "Orange.classification.rules.rule_to_string",
259           "orngCN2.LaplaceEvaluator": "Orange.classification.rules.LaplaceEvaluator",
260           "orngCN2.WRACCEvaluator": "Orange.classification.rules.WRACCEvaluator",
261           "orngCN2.mEstimate": "Orange.classification.rules.MEstimateEvaluator",
262           "orngCN2.RuleStopping_apriori": "Orange.classification.rules.RuleStopping_Apriori",
263           "orngCN2.LengthValidator": "Orange.classification.rules.LengthValidator",
264           "orngCN2.supervisedClassCheck": "Orange.classification.rules.supervisedClassCheck",
265           "orngCN2.CN2Learner": "Orange.classification.rules.CN2Learner",
266           "orngCN2.CN2Classifier": "Orange.classification.rules.CN2Classifier",
267           "orngCN2.CN2UnorderedLearner": "Orange.classification.rules.CN2UnorderedLearner",
268           "orngCN2.CN2UnorderedClassifier": "Orange.classification.rules.CN2UnorderedClassifier",
269           "orngCN2.RuleClassifier_bestRule": "Orange.classification.rules.RuleClassifier_BestRule",
270           "orngCN2.CovererAndRemover_multWeights": "Orange.classification.rules.CovererAndRemover_MultWeights",
271           "orngCN2.CovererAndRemover_addWeights": "Orange.classification.rules.CovererAndRemover_AddWeights",
272           "orngCN2.rule_in_set": "Orange.classification.rules.rule_in_set",
273           "orngCN2.rules_equal": "Orange.classification.rules.rules_equal",
274           "orngCN2.noDuplicates_validator": "Orange.classification.rules.NoDuplicatesValidator",
275           "orngCN2.ruleSt_setRules": "Orange.classification.rules.RuleStopping_SetRules",
276           "orngCN2.CN2SDUnorderedLearner": "Orange.classification.rules.CN2SDUnorderedLearner",
277#           "orngCN2.avg": "Orange.classification.rules.avg",
278#           "orngCN2.var": "Orange.classification.rules.var",
279#           "orngCN2.median": "Orange.classification.rules.median",
280#           "orngCN2.perc": "Orange.classification.rules.perc",
281#           "orngCN2.createRandomDataSet": "Orange.classification.rules.createRandomDataSet",
282#           "orngCN2.compParameters": "Orange.classification.rules.compParameters",
283#           "orngCN2.computeDists": "Orange.classification.rules.computeDists",
284#           "orngCN2.createEVDistList": "Orange.classification.rules.createEVDistList",
285           "orngCN2.CovererAndRemover_Prob": "Orange.classification.rules.CovererAndRemover_Prob",
286           "orngCN2.add_sub_rules": "Orange.classification.rules.add_sub_rules",
287           "orngCN2.CN2EVCUnorderedLearner": "Orange.classification.rules.CN2EVCUnorderedLearner",
288
289           "orngMDS.KruskalStress": "Orange.projection.mds.KruskalStress",
290           "orngMDS.SammonStress": "Orange.projection.mds.SammonStress",
291           "orngMDS.SgnSammonStress": "Orange.projection.mds.SgnSammonStress",
292           "orngMDS.SgnRelStress": "Orange.projection.mds.SgnRelStress",
293           "orngMDS.PointList": "Orange.projection.mds.PointList",
294           "orngMDS.FloatListList": "Orange.projection.mds.FloatListList",
295           "orngMDS.PivotMDS": "Orange.projection.mds.PivotMDS",
296           "orngMDS.MDS": "Orange.projection.mds.MDS",
297
298           "orngStat.AP" : "Orange.evaluation.scoring.AP",
299           "orngStat.AROC" : "Orange.evaluation.scoring.AROC",
300           "orngStat.AROCFromCDT" : "Orange.evaluation.scoring.AROC_from_CDT",
301           "orngStat.AUC" : "Orange.evaluation.scoring.AUC",
302           "orngStat.AUCWilcoxon" : "Orange.evaluation.scoring.AUCWilcoxon",
303           "orngStat.AUC_binary" : "Orange.evaluation.scoring.AUC_binary",
304           "orngStat.AUC_i" : "Orange.evaluation.scoring.AUC_i",
305           "orngStat.AUC_ij" : "Orange.evaluation.scoring.AUC_ij",
306           "orngStat.AUC_iterations" : "Orange.evaluation.scoring.AUC_iterations",
307           "orngStat.AUC_matrix" : "Orange.evaluation.scoring.AUC_matrix",
308           "orngStat.AUC_multi" : "Orange.evaluation.scoring.AUC_multi",
309           "orngStat.AUC_pair" : "Orange.evaluation.scoring.AUC_pair",
310           "orngStat.AUC_single" : "Orange.evaluation.scoring.AUC_single",
311           "orngStat.AUC_x" : "Orange.evaluation.scoring.AUC_x",
312           "orngStat.BSS" : "Orange.evaluation.scoring.BSS",
313           "orngStat.BrierScore" : "Orange.evaluation.scoring.Brier_score",
314           "orngStat.CA" : "Orange.evaluation.scoring.CA",
315           "orngStat.CA_se" : "Orange.evaluation.scoring.CA_se",
316           "orngStat.CDT" : "Orange.evaluation.scoring.CDT",
317           "orngStat.ConfusionMatrix" : "Orange.evaluation.scoring.ConfusionMatrix",
318           "orngStat.F1" : "Orange.evaluation.scoring.F1",
319           "orngStat.Falpha" : "Orange.evaluation.scoring.Falpha",
320           "orngStat.Friedman" : "Orange.evaluation.scoring.Friedman",
321           "orngStat.IS" : "Orange.evaluation.scoring.IS",
322           "orngStat.IS_ex" : "Orange.evaluation.scoring.IS_ex",
323           "orngStat.MAE" : "Orange.evaluation.scoring.MAE",
324           "orngStat.MCC" : "Orange.evaluation.scoring.MCC",
325           "orngStat.ME" : "Orange.evaluation.scoring.ME",
326           "orngStat.MSE" : "Orange.evaluation.scoring.MSE",
327           "orngStat.MSE_old" : "Orange.evaluation.scoring.MSE_old",
328           "orngStat.McNemar" : "Orange.evaluation.scoring.McNemar",
329           "orngStat.McNemarOfTwo" : "Orange.evaluation.scoring.McNemar_of_two",
330           "orngStat.NPV" : "Orange.evaluation.scoring.NPV",
331           "orngStat.PPV" : "Orange.evaluation.scoring.PPV",
332           "orngStat.R2" : "Orange.evaluation.scoring.R2",
333           "orngStat.RAE" : "Orange.evaluation.scoring.RAE",
334           "orngStat.RMSE" : "Orange.evaluation.scoring.RMSE",
335           "orngStat.RMSE_old" : "Orange.evaluation.scoring.RMSE_old",
336           "orngStat.ROCaddPoint" : "Orange.evaluation.scoring.ROC_add_point",
337           "orngStat.ROCsFromCDT" : "Orange.evaluation.scoring.ROCs_from_CDT",
338           "orngStat.ROCslope" : "Orange.evaluation.scoring.ROC_slope",
339           "orngStat.RRSE" : "Orange.evaluation.scoring.RRSE",
340           "orngStat.RSE" : "Orange.evaluation.scoring.RSE",
341           "orngStat.TCbestThresholdsOnROCcurve" : "Orange.evaluation.scoring.TC_best_thresholds_on_ROC_curve",
342           "orngStat.TCcomputeROC" : "Orange.evaluation.scoring.TC_compute_ROC",
343           "orngStat.TCthresholdlAverageROC" : "Orange.evaluation.scoring.TC_threshold_average_ROC",
344           "orngStat.TCverticalAverageROC" : "Orange.evaluation.scoring.TC_vertical_average_ROC",
345           "orngStat.Wilcoxon" : "Orange.evaluation.scoring.Wilcoxon",
346           "orngStat.WilcoxonPairs" : "Orange.evaluation.scoring.Wilcoxon_pairs",
347#           "orngStat.add" : "Orange.evaluation.scoring.add",
348#           "orngStat.checkArgkw" : "Orange.evaluation.scoring.checkArgkw",
349#           "orngStat.checkNonZero" : "Orange.evaluation.scoring.checkNonZero",
350           "orngStat.classProbabilitiesFromRes" : "Orange.evaluation.scoring.class_probabilities_from_res",
351           "orngStat.compare2AROCs" : "Orange.evaluation.scoring.compare_2_AROCs",
352           "orngStat.compare2AUCs" : "Orange.evaluation.scoring.compare_2_AUCs",
353           "orngStat.computeCDT" : "Orange.evaluation.scoring.compute_CDT",
354           "orngStat.computeCalibrationCurve" : "Orange.evaluation.scoring.compute_calibration_curve",
355           "orngStat.computeConfusionMatrices" : "Orange.evaluation.scoring.compute_confusion_matrices",
356           "orngStat.computeLiftCurve" : "Orange.evaluation.scoring.compute_lift_curve",
357           "orngStat.computeROC" : "Orange.evaluation.scoring.compute_ROC",
358           "orngStat.compute_CD" : "Orange.evaluation.scoring.compute_CD",
359           "orngStat.compute_friedman" : "Orange.evaluation.scoring.compute_friedman",
360           "orngStat.confusionChiSquare" : "Orange.evaluation.scoring.confusion_chi_square",
361           "orngStat.confusionMatrices" : "Orange.evaluation.scoring.confusion_matrices",
362           "orngStat.defaultLineTypes" : "Orange.evaluation.scoring.default_line_types",
363           "orngStat.defaultPointTypes" : "Orange.evaluation.scoring.default_point_types",
364#           "orngStat.frange" : "Orange.evaluation.scoring.frange",
365#           "orngStat.gettotsize" : "Orange.evaluation.scoring.gettotsize",
366#           "orngStat.gettotweight" : "Orange.evaluation.scoring.gettotweight",
367           "orngStat.graph_ranks" : "Orange.evaluation.scoring.graph_ranks",
368           "orngStat.isCDTEmpty" : "Orange.evaluation.scoring.is_CDT_empty",
369           "orngStat.learningCurve2PiCTeX" : "Orange.evaluation.scoring.learning_curve_to_PiCTeX",
370           "orngStat.learningCurveLearners2PiCTeX" : "Orange.evaluation.scoring.learning_curve_learners_to_PiCTeX",
371           "orngStat.legend2PiCTeX" : "Orange.evaluation.scoring.legend_to_PiCTeX",
372           "orngStat.legendLearners2PiCTeX" : "Orange.evaluation.scoring.legend_learners_to_PiCTeX",
373#           "orngStat.log2" : "Orange.evaluation.scoring.log2",
374#           "orngStat.math" : "Orange.evaluation.scoring.math",
375#           "orngStat.numpy" : "Orange.evaluation.scoring.numpy",
376#           "orngStat.operator" : "Orange.evaluation.scoring.operator",
377           "orngStat.plotLearningCurve" : "Orange.evaluation.scoring.plot_learning_curve",
378           "orngStat.plotLearningCurveLearners" : "Orange.evaluation.scoring.plot_learning_curve_learners",
379           "orngStat.plotMcNemarCurve" : "Orange.evaluation.scoring.plot_McNemar_curve",
380           "orngStat.plotMcNemarCurveLearners" : "Orange.evaluation.scoring.plot_McNemar_curve_learners",
381           "orngStat.plotROC" : "Orange.evaluation.scoring.plot_ROC",
382           "orngStat.plotROCLearners" : "Orange.evaluation.scoring.plot_ROC_learners",
383           "orngStat.precision" : "Orange.evaluation.scoring.precision",
384           "orngStat.printSingleROCCurveCoordinates" : "Orange.evaluation.scoring.print_single_ROC_curve_coordinates",
385           "orngStat.rankDifference" : "Orange.evaluation.scoring.rank_difference",
386           "orngStat.recall" : "Orange.evaluation.scoring.recall",
387           "orngStat.regressionError" : "Orange.evaluation.scoring.regression_error",
388           "orngStat.scottsPi" : "Orange.evaluation.scoring.scotts_pi",
389           "orngStat.sens" : "Orange.evaluation.scoring.sens",
390           "orngStat.spec" : "Orange.evaluation.scoring.spec",
391           "orngStat.splitByIterations" : "Orange.evaluation.scoring.split_by_iterations",
392#           "orngStat.statc" : "Orange.evaluation.scoring.statc",
393           "orngStat.statisticsByFolds" : "Orange.evaluation.scoring.statistics_by_folds",
394#           "orngStat.x" : "Orange.evaluation.scoring.x",
395
396           # Orange.selection
397           "orngMisc.BestOnTheFly":"Orange.misc.selection.BestOnTheFly",
398           "orngMisc.selectBest":"Orange.misc.selection.select_best",
399           "orngMisc.selectBestIndex":"Orange.misc.selection.select_best_index",
400           "orngMisc.compare2_firstBigger":"Orange.misc.selection.compare_first_bigger",
401           "orngMisc.compare2_firstSmaller":"Orange.misc.selection.compare_first_smaller",
402           "orngMisc.compare2_lastBigger":"Orange.misc.selection.compare_last_bigger",
403           "orngMisc.compare2_lastSmaller":"Orange.misc.selection.compare_last_smaller",
404           "orngMisc.compare2_bigger":"Orange.misc.selection.compare_bigger",
405           "orngMisc.compare2_smaller":"Orange.misc.selection.compare_smaller",
406
407           "orngMisc.Renderer": "Orange.misc.render.Renderer",
408           "orngMisc.EPSRenderer": "Orange.misc.render.EPSRenderer",
409           "orngMisc.SVGRenderer": "Orange.misc.render.SVGRenderer",
410           "orngMisc.PILRenderer": "Orange.misc.render.PILRenderer",
411           # The rest of orngMisc is handled by fix_orange_imports (maps to Orange.misc)
412
413           "orngEnsemble.BaggedLearner":"Orange.ensemble.bagging.BaggedLearner",
414           "orngEnsemble.BaggedClassifier":"Orange.ensemble.bagging.BaggedClassifier",
415           "orngEnsemble.BoostedLearner":"Orange.ensemble.boosting.BoostedLearner",
416           "orngEnsemble.BoostedClassifier":"Orange.ensemble.boosting.BoostedClassifier",
417           "orngEnsemble.RandomForestClassifier":"Orange.ensemble.forest.RandomForestClassifier",
418           "orngEnsemble.RandomForestLearner":"Orange.ensemble.forest.RandomForestLearner",
419           "orngEnsemble.MeasureAttribute_randomForests":"Orange.ensemble.forest.ScoreFeature",
420           "orngEnsemble.SplitConstructor_AttributeSubset":"Orange.ensemble.forest.SplitConstructor_AttributeSubset",
421
422           "orngTest.proportionTest":"Orange.evaluation.testing.proportion_test",
423           "orngTest.leaveOneOut":"Orange.evaluation.testing.leave_one_out",
424           "orngTest.crossValidation":"Orange.evaluation.testing.cross_validation",
425           "orngTest.testWithIndices":"Orange.evaluation.testing.test_with_indices",
426           "orngTest.learningCurve":"Orange.evaluation.testing.learning_curve",
427           "orngTest.learningCurveN":"Orange.evaluation.testing.learning_curve_n",
428           "orngTest.learningCurveWithTestData":"Orange.evaluation.testing.learning_curve_with_test_data",
429           "orngTest.learnAndTestOnTestData":"Orange.evaluation.testing.learn_and_test_on_test_data",
430           "orngTest.learnAndTestOnLearnData":"Orange.evaluation.testing.learn_and_test_on_learn_data",
431           "orngTest.testOnData":"Orange.evaluation.testing.test_on_data",
432           "orngTest.TestedExample":"Orange.evaluation.testing.TestedExample",
433           "orngTest.ExperimentResults":"Orange.evaluation.testing.ExperimentResults",
434
435           "orngLR.dump":"Orange.classification.logreg.dump",
436           "orngLR.printOUT":"Orange.classification.logreg.dump",
437           "orngLR.printOut":"Orange.classification.logreg.dump",
438           "orngLR.hasDiscreteValues":"Orange.classification.logreg.has_discrete_values",
439           "orngLR.LogRegLearner":"Orange.classification.logreg.LogRegLearner",
440           "orngLR.LogRegLearnerClass":"Orange.classification.logreg.LogRegLearner",
441           "orngLR.Univariate_LogRegLearner":"Orange.classification.logreg.UnivariateLogRegLearner",
442           "orngLR.Univariate_LogRegLearner_Class":"Orange.classification.logreg.UnivariateLogRegLearner",
443           "orngLR.Univariate_LogRegClassifier":"Orange.classification.logreg.UnivariateLogRegClassifier",
444           "orngLR.LogRegLearner_getPriors":"Orange.classification.logreg.LogRegLearnerGetPriors",
445           "orngLR.LogRegLearnerClass_getPriors":"Orange.classification.logreg.LogRegLearnerGetPriors",
446           "orngLR.LogRegLearnerClass_getPriors_OneTable":"Orange.classification.logreg.LogRegLearnerGetPriorsOneTable",
447           "orngLR.Pr":"Orange.classification.logreg.pr",
448           "orngLR.lh":"Orange.classification.logreg.lh",
449           "orngLR.diag":"Orange.classification.logreg.diag",
450           "orngLR.simpleFitter":"Orange.classification.logreg.SimpleFitter",
451           "orngLR.Pr_bx":"Orange.classification.logreg.pr_bx",
452           "orngLR.bayesianFitter":"Orange.classification.logreg.BayesianFitter",
453           "orngLR.StepWiseFSS":"Orange.classification.logreg.StepWiseFSS",
454           "orngLR.getLikelihood":"Orange.classification.logreg.get_likelihood",
455           "orngLR.StepWiseFSS_class":"Orange.classification.logreg.StepWiseFSS",
456           "orngLR.StepWiseFSS_Filter":"Orange.classification.logreg.StepWiseFSSFilter",
457           "orngLR.StepWiseFSS_Filter_class":"Orange.classification.logreg.StepWiseFSSFilter",
458           "orngLR.lchisqprob":"Orange.classification.logreg.lchisqprob",
459           "orngLR.zprob":"Orange.classification.logreg.zprob",
460
461           "orange.Preprocessor": "Orange.preprocess.Preprocessor",
462           "orange.Preprocessor_addCensorWeight": "Orange.preprocess.Preprocessor_addCensorWeight",
463           "orange.Preprocessor_addClassNoise": "Orange.preprocess.Preprocessor_addClassNoise",
464           "orange.Preprocessor_addClassWeight": "Orange.preprocess.Preprocessor_addClassWeight",
465           "orange.Preprocessor_addGaussianClassNoise": "Orange.preprocess.Preprocessor_addGaussianClassNoise",
466           "orange.Preprocessor_addGaussianNoise": "Orange.preprocess.Preprocessor_addGaussianNoise",
467           "orange.Preprocessor_addMissing": "Orange.preprocess.Preprocessor_addMissing",
468           "orange.Preprocessor_addMissingClasses": "Orange.preprocess.Preprocessor_addMissingClasses",
469           "orange.Preprocessor_addNoise": "Orange.preprocess.Preprocessor_addNoise",
470           "orange.Preprocessor_discretize": "Orange.preprocess.Preprocessor_discretize",
471           "orange.Preprocessor_drop": "Orange.preprocess.Preprocessor_drop",
472           "orange.Preprocessor_dropMissing": "Orange.preprocess.Preprocessor_dropMissing",
473           "orange.Preprocessor_dropMissingClasses": "Orange.preprocess.Preprocessor_dropMissingClasses",
474           "orange.Preprocessor_filter": "Orange.preprocess.Preprocessor_filter",
475           "orange.Preprocessor_ignore": "Orange.preprocess.Preprocessor_ignore",
476           "orange.Preprocessor_imputeByLearner": "Orange.preprocess.Preprocessor_imputeByLearner",
477           "orange.Preprocessor_removeDuplicates": "Orange.preprocess.Preprocessor_removeDuplicates",
478           "orange.Preprocessor_select": "Orange.preprocess.Preprocessor_select",
479           "orange.Preprocessor_shuffle": "Orange.preprocess.Preprocessor_shuffle",
480           "orange.Preprocessor_take": "Orange.preprocess.Preprocessor_take",
481           "orange.Preprocessor_takeMissing": "Orange.preprocess.Preprocessor_takeMissing",
482           "orange.Preprocessor_takeMissingClasses": "Orange.preprocess.Preprocessor_takeMissingClasses",
483
484           "orange.Discretizer": "Orange.feature.discretization.Discretizer",
485           "orange.BiModalDiscretizer": "Orange.feature.discretization.BiModalDiscretizer",
486           "orange.EquiDistDiscretizer": "Orange.feature.discretization.EquiDistDiscretizer",
487           "orange.IntervalDiscretizer": "Orange.feature.discretization.IntervalDiscretizer",
488           "orange.ThresholdDiscretizer": "Orange.feature.discretization.ThresholdDiscretizer",
489           "orange.Discrete2Continuous": "Orange.feature.discretization.Discrete2Continuous",
490
491           "orange.DomainContinuizer": "Orange.feature.continuization.DomainContinuizer",
492
493           "orange.MakeRandomIndices": "Orange.data.sample.SubsetIndices",
494           "orange.MakeRandomIndicesN": "Orange.data.sample.SubsetIndicesN",
495           "orange.MakeRandomIndicesCV": "Orange.data.sample.SubsetIndicesCV",
496           "orange.MakeRandomIndicesMultiple": "Orange.data.sample.SubsetIndicesMultiple",
497           "orange.MakeRandomIndices2": "Orange.data.sample.SubsetIndices2",
498
499           "orngLinProj.FAST_IMPLEMENTATION": "Orange.projection.linear.FAST_IMPLEMENTATION",
500           "orngLinProj.SLOW_IMPLEMENTATION": "Orange.projection.linear.SLOW_IMPLEMENTATION",
501           "orngLinProj.LDA_IMPLEMENTATION": "Orange.projection.linear.LDA_IMPLEMENTATION",
502           "orngLinProj.LAW_LINEAR": "Orange.projection.linear.LAW_LINEAR",
503           "orngLinProj.LAW_SQUARE": "Orange.projection.linear.LAW_SQUARE",
504           "orngLinProj.LAW_GAUSSIAN": "Orange.projection.linear.LAW_GAUSSIAN",
505           "orngLinProj.LAW_KNN": "Orange.projection.linear.LAW_KNN",
506           "orngLinProj.LAW_LINEAR_PLUS": "Orange.projection.linear.LAW_LINEAR_PLUS",
507           "orngLinProj.DR_PCA": "Orange.projection.linear.DR_PCA",
508           "orngLinProj.DR_SPCA": "Orange.projection.linear.DR_SPCA",
509           "orngLinProj.DR_PLS": "Orange.projection.linear.DR_PLS",
510           "orngLinProj.normalize": "Orange.projection.linear.normalize",
511           "orngLinProj.center": "Orange.projection.linear.center",
512           "orngLinProj.FreeViz": "Orange.projection.linear.FreeViz",
513           "orngLinProj.createPLSProjection": "Orange.projection.linear.create_pls_projection",
514           "orngLinProj.createPCAProjection": "Orange.projection.linear.create_pca_projection",
515           "orngLinProj.FreeVizClassifier": "Orange.projection.linear.FreeVizClassifier",
516           "orngLinProj.FreeVizLearner": "Orange.projection.linear.FreeVizLearner",
517           "orngLinProj.S2NHeuristicLearner": "Orange.projection.linear.S2NHeuristicLearner",
518
519           "orngDisc.entropyDiscretization": "Orange.feature.discretization.entropyDiscretization_wrapper",
520           "orngDisc.EntropyDiscretization": "Orange.feature.discretization.EntropyDiscretization_wrapper",
521
522           "orange.ProbabilityEstimatorList": "Orange.statistics.estimate.ProbabilityEstimatorList",
523
524           "orange.FilterList": "Orange.preprocess.FilterList",
525           "orange.Filter": "Orange.preprocess.Filter",
526           "orange.Filter_conjunction": "Orange.preprocess.Filter_conjunction",
527           "orange.Filter_disjunction": "Orange.preprocess.Filter_disjunction",
528           "orange.Filter_hasClassValue": "Orange.preprocess.Filter_hasClassValue",
529           "orange.Filter_hasMeta": "Orange.preprocess.Filter_hasMeta",
530           "orange.Filter_hasSpecial": "Orange.preprocess.Filter_hasSpecial",
531           "orange.Filter_isDefined": "Orange.preprocess.Filter_isDefined",
532           "orange.Filter_random": "Orange.preprocess.Filter_random",
533           "orange.Filter_sameValue": "Orange.preprocess.Filter_sameValue",
534           "orange.Filter_values": "Orange.preprocess.Filter_values",
535
536           # orngEnviron
537
538           "orngEnviron.orangeDir": "Orange.misc.environ.install_dir",
539           "orngEnviron.orangeDocDir": "Orange.misc.environ.doc_install_dir",
540           "orngEnviron.orangeVer": "Orange.misc.environ.version",
541           "orngEnviron.canvasDir": "Orange.misc.environ.canvas_install_dir",
542           "orngEnviron.widgetDir": "Orange.misc.environ.widget_install_dir",
543           "orngEnviron.picsDir": "Orange.misc.environ.icons_install_dir",
544           "orngEnviron.addOnsDirSys": "Orange.misc.environ.add_ons_dir",
545           "orngEnviron.addOnsDirUser": "Orange.misc.environ.add_ons_dir_user",
546           "orngEnviron.applicationDir": "Orange.misc.environ.application_dir",
547           "orngEnviron.outputDir": "Orange.misc.environ.output_dir",
548           "orngEnviron.defaultReportsDir": "Orange.misc.environ.default_reports_dir",
549           "orngEnviron.orangeSettingsDir": "Orange.misc.environ.orange_settings_dir",
550           "orngEnviron.widgetSettingsDir": "Orange.misc.environ.widget_settings_dir",
551           "orngEnviron.canvasSettingsDir": "Orange.misc.environ.canvas_settings_dir",
552           "orngEnviron.bufferDir": "Orange.misc.environ.buffer_dir",
553           "orngEnviron.directoryNames": "Orange.misc.environ.directories",
554           "orngEnviron.samepath": "Orange.misc.environ.samepath",
555           "orngEnviron.addOrangeDirectoriesToPath": "Orange.misc.environ.add_orange_directories_to_path",
556
557           "orngScaleData.getVariableValuesSorted": "Orange.preprocess.scaling.get_variable_values_sorted",
558           "orngScaleData.getVariableValueIndices": "Orange.preprocess.scaling.get_variable_value_indices",
559           "orngScaleData.discretizeDomain": "Orange.preprocess.scaling.discretize_domain",
560           "orngScaleData.orngScaleData": "Orange.preprocess.scaling.ScaleData",
561           "orngScaleLinProjData.orngScaleLinProjData": "Orange.preprocess.scaling.ScaleLinProjData",
562           "orngScalePolyvizData.orngScalePolyvizData": "Orange.preprocess.scaling.ScalePolyvizData",
563           "orngScaleScatterPlotData.orngScaleScatterPlotData": "Orange.preprocess.scaling.ScaleScatterPlotData",
564
565           "orngEvalAttr.mergeAttrValues": "Orange.feature.scoring.merge_values",
566           "orngEvalAttr.MeasureAttribute_MDL": "Orange.feature.scoring.MDL",
567           "orngEvalAttr.MeasureAttribute_MDLClass": "Orange.feature.scoring.MDL",
568           "orngEvalAttr.MeasureAttribute_Distance": "Orange.feature.scoring.Distance",
569           "orngEvalAttr.MeasureAttribute_DistanceClass": "Orange.feature.scoring.Distance",
570           "orngEvalAttr.OrderAttributesByMeasure": "Orange.feature.scoring.OrderAttributes",
571
572           "orange.ProbabilityEstimator": "Orange.statistics.estimate.Estimator",
573           "orange.ProbabilityEstimator_FromDistribution": "Orange.statistics.estimate.EstimatorFromDistribution",
574           "orange.ProbabilityEstimatorConstructor": "Orange.statistics.estimate.EstimatorConstructor",
575           "orange.ProbabilityEstimatorConstructor_Laplace": "Orange.statistics.estimate.Laplace",
576           "orange.ProbabilityEstimatorConstructor_kernel": "Orange.statistics.estimate.Kernel",
577           "orange.ProbabilityEstimatorConstructor_loess": "Orange.statistics.estimate.Loess",
578           "orange.ProbabilityEstimatorConstructor_m": "Orange.statistics.estimate.M",
579           "orange.ProbabilityEstimatorConstructor_relative": "Orange.statistics.estimate.RelativeFrequency",
580           "orange.ConditionalProbabilityEstimator": "Orange.statistics.estimate.ConditionalEstimator",
581           "orange.ConditionalProbabilityEstimator_FromDistribution": "Orange.statistics.estimate.ConditionalEstimatorFromDistribution",
582           "orange.ConditionalProbabilityEstimator_ByRows": "Orange.statistics.estimate.ConditionalEstimatorByRows",
583           "orange.ConditionalProbabilityEstimatorConstructor_ByRows": "Orange.statistics.estimate.ConditionalByRows",
584           "orange.ConditionalProbabilityEstimatorConstructor_loess": "Orange.statistics.estimate.ConditionalLoess",
585
586           "orange.RandomGenerator": "Orange.misc.Random",
587
588           }
589
590def build_pattern(mapping=MAPPING):
591    PATTERN = """
592    power< head=any+
593         trailer< '.' member=(%s) >
594         tail=any*
595    >
596    """
597    return PATTERN % "|".join("'%s'" % key.split(".")[-1] for key in mapping.keys())
598
599class FixChangedNames(fixer_base.BaseFix):
600    mapping = MAPPING
601
602    run_order = 1
603
604    def compile_pattern(self):
605        self.PATTERN = build_pattern(self.mapping)
606        self._modules_to_change = [key.split(".", 1)[0] for key in self.mapping.keys()]
607        super(FixChangedNames, self).compile_pattern()
608
609    def package_tree(self, package):
610        """ Return pytree tree for accessing the package
611       
612        Example:
613            >>> package_tree("Orange.feature.scoring")
614            [Name('Orange'), trailer('.' 'feature'), trailer('.', 'scoring')]
615        """
616        path = package.split('.')
617        nodes = [Name(path[0])]
618        for name in path[1:]:
619            new = pytree.Node(self.syms.trailer, [Dot(), Name(name)])
620            nodes.append(new)
621        return nodes
622
623
624    def transform(self, node, results):
625        member = results.get("member")
626        head = results.get("head")
627        tail = results.get("tail")
628        module = head[0].value
629
630        if member and module in self._modules_to_change:
631            node = member[0]
632            head = head[0]
633
634            old_name = module + "." + node.value
635            if old_name not in self.mapping:
636                return
637
638            new_name = unicode(self.mapping[old_name])
639
640            if ":" in new_name:
641                # ':' is the delimiter used to separate module namespace
642                package = new_name.split(":", 1)[0]
643                new_name = new_name.replace(":", ".")
644            else:
645                package = new_name.rsplit(".", 1)[0]
646
647            syms = self.syms
648
649            if tail:
650                tail = [t.clone() for t in  tail]
651            new = self.package_tree(new_name)
652            new = pytree.Node(syms.power, new + tail, prefix=head.prefix)
653
654            # Make sure the proper package is imported
655#            if ":" in new_name:
656#                package = new_name.split(":",1)[0]
657#            else:
658#                package = new_name.rsplit(".", 1)[0]
659
660            def orange_to_root(package):
661                return "Orange" if package.startswith("Orange.") else package
662
663            touch_import(None, orange_to_root(package), node)
664            return new
665
Note: See TracBrowser for help on using the repository browser.