Write and document a Python script convert2.py which takes as command-line arguments a given-unit type in {Metric, Imperial} and an input textfile, and outputs the version of the input textfile in which all units that are the opposite unit-type of that specified are translated into the units of the specified type as described above. Note that unit-quantities may be specified in the given text using either integers or floating-point numbers. The conversion mechanism must be implemented using functions from the re module. Your script must work on datafile convert2.txt to produce the output given in typescript-file convert2.script.
Write and document a Python script rtrans.py which, given a dialect translation file, a translation-direction string "to" or "from", and a dialect textfile as command-line arguments, prints a line-length adjusted version of the given text as translated relative to the given translation file in either the forward or backward direction, respectively. The translation mechanism must be implemented using functions from the re module. Your script must work on dialect-translation files e2g1.txt and e2g2.txt and textfile rtrans.txt to produce the output given in typescript-file rtrans.script. You may assume that all dialect translation files are valid.
In Question 2, you may find it useful to recognize and parse the rules in a dialect translation file using the regular-expression matching functions in re before applying this rule-set (again using re functions) to the provided text.
######################################################### ## CS 2500 (Fall 2010), Assignment #8, Question #1 ## ## Script File Name: convert2.py ## ## Student Name: Todd Wareham ## ## Login Name: harold ## ## MUN #: 8008765 ## #########################################################You do not have to develop your code on our CS departmental systems. However, as your code will be compiled and tested on our CS departmental systems as part of the assignment marking process, you should ensure that your code compiles and runs correctly on at least one of these systems.
Created: October 7, 2010
Last Modified: October 20, 2010