[Avida-cvs] [Avida2-svn] r50 - trunk/source/python/AvidaGui2
baerb at myxo.css.msu.edu
baerb at myxo.css.msu.edu
Tue Mar 15 12:04:51 PST 2005
Author: baerb
Date: 2005-03-15 15:04:51 -0500 (Tue, 15 Mar 2005)
New Revision: 50
Added:
trunk/source/python/AvidaGui2/pyInstructionSet.py
Log:
File to translate back and forth from single letter codes to full "Assembly
Language" codes. By reading the inst_set.default in the Resources directory.
Added: trunk/source/python/AvidaGui2/pyInstructionSet.py
===================================================================
--- trunk/source/python/AvidaGui2/pyInstructionSet.py 2005-03-15 20:01:53 UTC (rev 49)
+++ trunk/source/python/AvidaGui2/pyInstructionSet.py 2005-03-15 20:04:51 UTC (rev 50)
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+import string
+
+class pyInstructionSet:
+
+ def __init__(self, in_file = None):
+
+ self.cmd_letter_dict = {}
+ self.letter_cmd_dict = {}
+ letters = ['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l',
+ 'k','j','i','h','g','f','e','d','c','b','a']
+ inst_file = open(in_file)
+ lines = inst_file.readlines()
+ inst_file.close
+ for line in lines:
+ comment_start = line.find("#")
+ if comment_start > -1:
+ if comment_start == 0:
+ line = ""
+ else:
+ line = line[:comment_start]
+ line = line.strip()
+ if len(line) > 0:
+ cmd_name, junk = string.split(line)
+ cmd_name = cmd_name.upper()
+ letter = letters.pop()
+ self.cmd_letter_dict[cmd_name] = letter
+ self.letter_cmd_dict[letter] = cmd_name
More information about the Avida-cvs
mailing list