tangled
alpha
login
or
join now
dekker.one
/
Fourmi
0
fork
atom
A web scraper build to search specific information for a given compound (and its pseudonyms)
0
fork
atom
overview
issues
pulls
pipelines
Fixed merge conflict
Harmen Prins
11 years ago
1a5b804e
e015cc96
+39
-37
4 changed files
expand all
collapse all
unified
split
GUI
configImporter.py
gui.py
fourmi.py
gui_launcher.py
+30
GUI/configImporter.py
···
1
1
+
import ConfigParser
2
2
+
3
3
+
4
4
+
class ConfigImporter():
5
5
+
def __init__(self, filename):
6
6
+
"""Read the filename into the parser."""
7
7
+
self.filename = filename
8
8
+
self.parser = ConfigParser.ConfigParser()
9
9
+
self.parser.read(self.filename)
10
10
+
11
11
+
def load_common_attributes(self):
12
12
+
"""Loads common attributes from the initialized file."""
13
13
+
try:
14
14
+
return self.parser.get('GUI_Options', 'CommonParameters')
15
15
+
except:
16
16
+
return 'One, Two, Three'
17
17
+
18
18
+
def load_output_types(self):
19
19
+
"""Loads output types from the initialized file."""
20
20
+
try:
21
21
+
return self.parser.get('GUI_Options', 'OutputTypes')
22
22
+
except:
23
23
+
return 'csv'
24
24
+
25
25
+
def load_always_attributes(self):
26
26
+
"""Loads attributes that are always searched for from the initialized file."""
27
27
+
try:
28
28
+
return self.parser.get('GUI_Options', 'AlwaysParameters')
29
29
+
except:
30
30
+
return 'Name, Weight'
+3
-30
GUI/gui.py
···
1
1
from Tkinter import *
2
2
import os
3
3
4
4
-
class ConfigImporter():
5
5
-
def __init__(self, filename):
6
6
-
"""Read the filename into the parser."""
7
7
-
import ConfigParser
8
8
-
self.filename = filename
9
9
-
self.parser = ConfigParser.ConfigParser()
10
10
-
self.parser.read(self.filename)
11
11
-
4
4
+
from configImporter import *
12
5
13
13
-
def load_common_attributes(self):
14
14
-
"""Loads common attributes from the initialized file."""
15
15
-
try:
16
16
-
return self.parser.get('GUI_Options', 'CommonParameters')
17
17
-
except:
18
18
-
return 'One, Two, Three'
19
19
-
20
20
-
def load_output_types(self):
21
21
-
"""Loads output types from the initialized file."""
22
22
-
try:
23
23
-
return self.parser.get('GUI_Options', 'OutputTypes')
24
24
-
except:
25
25
-
return 'csv'
26
26
-
27
27
-
def load_always_attributes(self):
28
28
-
"""Loads attributes that are always searched for from the initialized file."""
29
29
-
try:
30
30
-
return self.parser.get('GUI_Options', 'AlwaysParameters')
31
31
-
except:
32
32
-
return 'Name, Weight'
33
6
34
7
class GUI():
35
35
-
def __init__(self, search, config_file='GUI/gui.cfg', sourceloader = None, in_source=True):
8
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
171
-
if all([values.get(i)!='' for i in self.required_variables]):
144
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:
+6
fourmi.py
···
3
3
Fourmi, a web scraper build to search specific information for a given compound (and it's pseudonyms).
4
4
5
5
Usage:
6
6
+
fourmi
6
7
fourmi search <compound>
7
8
fourmi [options] search <compound>
8
9
fourmi [options] [-v | -vv | -vvv] [--include=<sourcename> | --exclude=<sourcename>] search <compound>
···
24
25
"""
25
26
26
27
from twisted.internet import reactor
28
28
+
27
29
from scrapy.crawler import Crawler
28
30
from scrapy import signals, log
29
31
import docopt
···
31
33
from FourmiCrawler.spider import FourmiSpider
32
34
from utils.configurator import Configurator
33
35
from utils.sourceloader import SourceLoader
36
36
+
from GUI import gui
34
37
35
38
36
39
def setup_crawler(compound, settings, source_loader, attributes):
···
82
85
elif arguments["list"]:
83
86
print "-== Available Sources ==-"
84
87
print str(loader)
88
88
+
else:
89
89
+
gui_window = gui.GUI(search, sourceloader=SourceLoader())
90
90
+
gui_window.run()
-7
gui_launcher.py
···
1
1
-
from fourmi import search
2
2
-
from GUI import gui
3
3
-
from utils.sourceloader import SourceLoader
4
4
-
5
5
-
6
6
-
gui_window = gui.GUI(search, sourceloader=SourceLoader())
7
7
-
gui_window.run()