A web scraper build to search specific information for a given compound (and its pseudonyms)

ConfigImporter in it's own file

+33 -30
+30
GUI/configImporter.py
··· 1 + import ConfigParser 2 + 3 + 4 + class ConfigImporter(): 5 + def __init__(self, filename): 6 + """Read the filename into the parser.""" 7 + self.filename = filename 8 + self.parser = ConfigParser.ConfigParser() 9 + self.parser.read(self.filename) 10 + 11 + def load_common_attributes(self): 12 + """Loads common attributes from the initialized file.""" 13 + try: 14 + return self.parser.get('GUI_Options', 'CommonParameters') 15 + except: 16 + return 'One, Two, Three' 17 + 18 + def load_output_types(self): 19 + """Loads output types from the initialized file.""" 20 + try: 21 + return self.parser.get('GUI_Options', 'OutputTypes') 22 + except: 23 + return 'csv' 24 + 25 + def load_always_attributes(self): 26 + """Loads attributes that are always searched for from the initialized file.""" 27 + try: 28 + return self.parser.get('GUI_Options', 'AlwaysParameters') 29 + except: 30 + return 'Name, Weight'
+3 -30
GUI/gui.py
··· 1 1 from Tkinter import * 2 2 import os 3 3 4 - class ConfigImporter(): 5 - def __init__(self, filename): 6 - """Read the filename into the parser.""" 7 - import ConfigParser 8 - self.filename = filename 9 - self.parser = ConfigParser.ConfigParser() 10 - self.parser.read(self.filename) 11 - 4 + from configImporter import * 12 5 13 - def load_common_attributes(self): 14 - """Loads common attributes from the initialized file.""" 15 - try: 16 - return self.parser.get('GUI_Options', 'CommonParameters') 17 - except: 18 - return 'One, Two, Three' 19 - 20 - def load_output_types(self): 21 - """Loads output types from the initialized file.""" 22 - try: 23 - return self.parser.get('GUI_Options', 'OutputTypes') 24 - except: 25 - return 'csv' 26 - 27 - def load_always_attributes(self): 28 - """Loads attributes that are always searched for from the initialized file.""" 29 - try: 30 - return self.parser.get('GUI_Options', 'AlwaysParameters') 31 - except: 32 - return 'Name, Weight' 33 6 34 7 class GUI(): 35 - def __init__(self, search, config_file='GUI/gui.cfg', sourceloader = None, in_source=True): 8 + def __init__(self, search, config_file='GUI/gui.cfg', sourceloader=None, in_source=True): 36 9 """Boots the window, configuration.""" 37 10 if in_source: 38 11 current_dir = os.path.dirname(os.path.abspath(__file__)) ··· 168 141 print "No known class, {}, {}".format(name, var) 169 142 170 143 self.values = values 171 - if all([values.get(i)!='' for i in self.required_variables]): 144 + if all([values.get(i) != '' for i in self.required_variables]): 172 145 self.finish_with_search = True 173 146 self.window.destroy() 174 147 else: