# PCI Geomatics Help Center

 ``` 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``` ```# -*- coding: utf-8 -*- # This script updates other scripts created for Geomatica 2013-2015 with all the renamed algorithms in Geomatica 2016. Ex. ortho2 to ortho. # To update your script, run this python file from command line. When it asks you for the python file you wish to update you can drag and drop # the python (.py) file. A new copy of that python file will be created with all of the old algorithm names changed to the new names. # Import modules import re import itertools import textwrap # Dictionnary of renamed algorithms algo_ren = {"autochip2":"autochip", "autodem2":"autodem", "autogcp2":"autogcp", "autotie2":"autotie", "csg2":"csg", "eoimport2":"eoimport", "epipolar2":"epipolar", "geocodedem2":"geocodedem", "lut2":"lut", "masking2":"masking", "mosrun2":"mosrun", "ortho2":"ortho", "reproj2":"reproj", "scale2":"scale", "vecsel2":"vecsel"} cachedict = {} # Function to find and replace the words (case insensitive) def strrep(orig, repdict): for k,v in repdict.iteritems(): if k in cachedict: pattern = cachedict[k] else: pattern = re.compile(k, re.IGNORECASE) cachedict[k] = pattern orig = pattern.sub(v, orig) return orig # Message in the command prompt print 45 * '*' print('{:^45}'.format('Program To Transform')) print('{:^45}'.format('Python Scripts')) print('{:^45}'.format('From')) print('{:^45}'.format('Geomatica 2015')) print('{:^45}'.format('To')) print('{:^45}'.format('Geomatica 2016')) print 45 * '*' print"" mots_rempl = [] for x in algo_ren: mots_rempl.append(x) # Display the renamed algorithms print("Algorithms changed:") print(textwrap.fill("%s" % ", ".join(mots_rempl), width=45)) print"" # User input nom_fichier = raw_input("Drag and drop the python file to convert: ") # Read input file and write output with open(nom_fichier, 'r') as main, open(nom_fichier[:-3] + "_2016.py", 'w') as f: for line in main: f.write(strrep(line, algo_ren)) ```