#!/usr/bin/env python3 from assignment3 import ConfigDict cc = ConfigDict('config_file.txt') print(cc['sql_query']) print(cc['email_to']) cc['database'] = 'mysql_manage' print(cc)
#!/usr/bin/python """ Usages: ./test.py (reads out the entire config dict) ./test.py thiskey thisvalue (sets 'thiskey' and 'thisvalue' in the dict) """ import sys from assignment3 import ConfigDict # assumes "assignment3.py" holds a # class caleld ConfigDict cd = ConfigDict('./config_file.txt') # if 2 arguments on the command line, # set a key and value in the object's dictionary if len(sys.argv) == 3: key = sys.argv[1] value = sys.argv[2] print('writing data: {0}, {1}'.format(key, value)) cd[key] = value # if 1 argument on the command line, treat it as a key and show the value elif len(sys.argv) == 2: print('reading a value') key = sys.argv[1] print('the value for {0} is {1}'.format(sys.argv[1], cd[key])) # if no arguments on the command line, show all keys and values else: print('keys/values:') for key in cd.keys():
""" Usages: ./assignment_3.py (reads out the entire config dict) ./assignment_3.py thiskey thisvalue (sets 'thiskey' and 'thisvalue' in the dict) """ import sys from assignment3 import ConfigDict cd = ConfigDict('config_file.txt') if len(sys.argv) == 3: key = sys.argv[1] value = sys.argv[2] print("writing data: {0}, {1}".format(key, value)) cd[key] = value else: print("reading data") for key in cd.keys(): print(' {0} = {1}'.format(key, cd[key])) print(cd)
#!/usr/bin/python """ Usages: ./dictTest.py (reads out the entire config dict) ./dictTest.py wheel (gets the value for that key) ./dictTest.py wheel air (sets wheel as key and air as value in the dict) """ import sys import os from assignment3 import ConfigDict file_name = './dict_1.txt' dict_file = ConfigDict(file_name) if len(sys.argv) == 3: key = sys.argv[1] value = sys.argv[2] dict_file[key] = value print('wrote "{0} = {1}" to a dict file.'.format(key, value)) elif len(sys.argv) == 2: print(sys.argv[1] + ' = ' + dict_file[sys.argv[1]]) else: if os.path.isfile(file_name): empty = True print('Reading dict file: ') with open(file_name) as df: # print(' key value') for line in df: empty = False key, value = line.rstrip().lstrip().split('=', 1) print(' {0} : {1}'.format(key, value))
import sys from assignment3 import ConfigDict cc = ConfigDict('config_file.txt') if len(sys.argv) == 3: key = sys.argv[1] value = sys.argv[2] print('wrting data {} {}'.format(key, value)) cc[key] = value else: print('reading data') for key in cc.keys(): print(' {} = {}'.format(key, cc[key])) print(cc['sql_query']) print(cc['email_to']) cc['database'] = 'mysql_managed' print(cc['database'])
#!/usr/bin/env python from assignment3 import ConfigDict cc = ConfigDict('0507_config_file.txt') print(cc['sql_query']) print(cc['email_to']) cc['database'] = 'mysql_managed' print cc
import sys import time from assignment3 import ConfigDict cd = ConfigDict('Configo6_file.txt') if len(sys.argv) == 3: # a = sys.argv[1] # b = sys.argv[2] # print('writing data: {0}, {1}'.format(a, b)) # # cd[a] = b key = sys.argv[1] value = sys.argv[2] print('writing data: {0}, {1}'.format(key, value)) cd[key] = value else: print('reading data') for key in cd.keys(): print(' {0} -- {1}'.format(key, cd[key])) time.sleep(3) print(cd)
#!/usr/bin/python import sys from assignment3 import ConfigDict cd = ConfigDict("configFile.txt") cd["another"] = "te" if len(sys.argv) == 3: key = sys.argv[1] value = sus.argv[2] print("writing data: {0}, {1}".format(key, value)) cd[key] = value else: print("reading data") for key in cd.keys(): print(" {0} = {1}".format(key, cd[key])) print(cd)