Skip to content

Commit

Permalink
Don't put things on LHS during script migration. Refs #6328
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Feb 25, 2013
1 parent 00d6c1f commit ed17687
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/scripts/lib1to2/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import messages
import rules
import astbuilder

class Grammar(object):
"""
Translation from v1->v2 of the Python API
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/scripts/lib1to2/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import shutil
import traceback

def run(files, backup=True):
"""
Expand All @@ -27,10 +28,9 @@ def run(files, backup=True):
try:
msg = script.migrate()
except Exception, exc:
raise
msg = str(exc)
traceback.print_exc()
script.restore_backup()
msg += "\nBackup restored."
msg = "%s: Backup restored." % (filename)
reports.append(msg)

messages.notify("\n" + "="*10 + " Report " + "="*10 + "\n")
Expand Down
3 changes: 0 additions & 3 deletions Code/Mantid/scripts/lib1to2/rules/simpleapireplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ def apply_to_node(self, name, parent):
alg_object.initialize()
self.transform_arglist_to_keywords(arglist_node, alg_object)

# Pull out the output args from the argument list
self.put_output_args_on_lhs(fn_call_node, arglist_node, alg_object)

def transform_arglist_to_keywords(self, arglist_node, alg_object):
"""Takes a node that points to argument list and transforms
it to all keyword=values
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/scripts/lib1to2/test/MigrationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def compare_file_contents(self, filename, expected_contents):
migrated_file = file(filename, 'r')
migrated_string = migrated_file.read()
migrated_file.close()
self.assertEquals(migrated_string, expected_contents)
self.assertEquals(migrated_string, expected_contents)
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@ def tearDown(self):

def test_no_arg_no_indent_is_migrated_correctly(self):
inputstring = """LoadRaw("test-file.raw",'testWS',SpectrumMax=1)"""
expected = """testWS = LoadRaw(Filename="test-file.raw",SpectrumMax=1)"""
expected = """LoadRaw(Filename="test-file.raw",OutputWorkspace='testWS',SpectrumMax=1)"""
self.do_migration(inputstring)
self.check_outcome(inputstring, expected)

def test_function_returning_no_args_is_replaced_correctly(self):
inputstring = \
"""
def foo():
LoadRaw("test-file.raw",'testWS',SpectrumMax=1)
"""
expected = \
"""
def foo():
testWS = LoadRaw(Filename="test-file.raw",SpectrumMax=1)
"""
inputstring = """
def foo():
LoadRaw("test-file.raw",'testWS',SpectrumMax=1)
"""
expected = """
def foo():
LoadRaw(Filename="test-file.raw",OutputWorkspace='testWS',SpectrumMax=1)
"""
self.do_migration(inputstring)
self.check_outcome(inputstring, expected)

def test_function_call_split_over_multiple_lines_is_replaced_correctly(self):
inputstring = """alg = LoadRaw("test-file.raw",'testWS',
SpectrumMax=1)"""
expected = """testWS = LoadRaw("test-file.raw", SpectrumMax=1)"""
inputstring = """
LoadRaw("test-file.raw",'testWS',
SpectrumMax=1)"""
expected = """
LoadRaw(Filename="test-file.raw",OutputWorkspace='testWS',
SpectrumMax=1)"""
self.create_test_file(inputstring)
self.do_migration(inputstring)
self.check_outcome(inputstring, expected)

Expand Down
1 change: 0 additions & 1 deletion Code/Mantid/scripts/lib1to2/test/all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from SimpleStringReplaceMigrationTest import *
from SimpleAPIFunctionCallReplaceMigrationTest import *
from PythonAlgorithmReplaceMigrationTest import *

if __name__ == "__main__":
unittest.main()

0 comments on commit ed17687

Please sign in to comment.