diff --git a/adstreme/glade/KeywordGenerator.py b/adstreme/glade/KeywordGenerator.py
new file mode 100755
index 0000000..0f9da9a
--- /dev/null
+++ b/adstreme/glade/KeywordGenerator.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+class Main:
+ 'run this class to see the keyword generator in action'
+ import sys
+
+ try:
+ import pygtk
+ pygtk.require("2.0") #we want to use gtk2
+ except:
+ print "\nYou need \"pygtk\" to get this working."
+ print "In Debian do: apt-get install python2.3-gtk2\n"
+ sys.exit(1)
+
+ try:
+ import gtk
+ from gtk import glade
+ except:
+ print "\nYou need \"libglade\" to get this working."
+ print "In Debian do: apt-get install python2.3-glade2\n"
+ sys.exit(1)
+
+ import kg_frontend
+ kgf = kg_frontend.KeywordGeneratorFrontend(gtk)
+ gtk.main()
+
+
diff --git a/adstreme/glade/kg-frontend/kg-frontend.glade b/adstreme/glade/kg-frontend/kg-frontend.glade
new file mode 100644
index 0000000..4f6fb2d
--- /dev/null
+++ b/adstreme/glade/kg-frontend/kg-frontend.glade
@@ -0,0 +1,340 @@
+
+
+
+
+
+
+ 3
+ True
+ Keyword Generator
+ GTK_WINDOW_TOPLEVEL
+ GTK_WIN_POS_NONE
+ False
+ 300
+ 500
+ True
+ False
+ stock_filters
+ True
+ False
+ False
+ GDK_WINDOW_TYPE_HINT_NORMAL
+ GDK_GRAVITY_NORTH_WEST
+ True
+
+
+
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ Keyword Generator 0.1
+ False
+ False
+ GTK_JUSTIFY_CENTER
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 5
+ False
+ False
+
+
+
+
+
+ True
+ True
+ 5
+
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ True
+ True
+ True
+ True
+ 0
+
+ True
+ *
+ False
+
+
+ 5
+ True
+ True
+ GTK_PACK_END
+
+
+
+
+ 0
+ True
+ True
+
+
+
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ True
+ True
+ True
+ 0
+
+ True
+ *
+ False
+
+
+ 5
+ True
+ True
+ GTK_PACK_END
+
+
+
+
+ 0
+ True
+ True
+
+
+
+
+
+ True
+ True
+ 0
+
+
+
+ True
+ True
+ True
+ True
+ 0
+
+ True
+ *
+ False
+
+
+ 5
+ True
+ True
+ GTK_PACK_END
+
+
+
+
+ 0
+ True
+ True
+
+
+
+
+ 0
+ False
+ True
+
+
+
+
+
+ True
+ True
+ False
+
+
+
+ 5
+ True
+ True
+ 0
+
+
+
+ True
+
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ GTK_RELIEF_NORMAL
+ True
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-apply
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ loslegen
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+ 0
+ True
+ False
+
+
+
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ 180
+ True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+ GTK_SHADOW_IN
+ GTK_CORNER_TOP_LEFT
+
+
+
+ 3
+ True
+ True
+ False
+ False
+ True
+ GTK_JUSTIFY_LEFT
+ GTK_WRAP_WORD
+ False
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ In jedes der drei oberen Textfelder können kommaseparierte Wortlisten eingetragen werden. Daraus wird dann in dieser Textbox die Keywordliste generiert.
+
+Aber das Beste ist, das funktioniert auch alles ohne Maus 8]
+
+
+
+
+ 0
+ True
+ True
+
+
+
+
+
+
+
diff --git a/adstreme/glade/kg-frontend/kg-frontend.gladep b/adstreme/glade/kg-frontend/kg-frontend.gladep
new file mode 100644
index 0000000..f5a4158
--- /dev/null
+++ b/adstreme/glade/kg-frontend/kg-frontend.gladep
@@ -0,0 +1,8 @@
+
+
+
+
+ Kg-frontend
+ kg-frontend
+ FALSE
+
diff --git a/adstreme/glade/kg_calc.py b/adstreme/glade/kg_calc.py
new file mode 100644
index 0000000..26621e9
--- /dev/null
+++ b/adstreme/glade/kg_calc.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#TODO: funktion, die aus parametern schoene listen macht.
+
+class KeywordGenerator:
+ def __init__(self):
+ import string,sys
+ return
+
+ def add_prefix_to_strings(self,prefix,stringlist):
+ """gets a string and a list of strings
+ returns a list of strings each prefixed with given string."""
+ ret = []
+ for item in stringlist:
+ ret.append(prefix+item)
+ return ret
+
+ def quotes_and_braces(self,keywords):
+ """gets a string with keywords, returns
+ given string
+ "given string"
+ [given string]
+ """
+ ret = '%s\n' % keywords
+ #ret += '"%s"\n' % keywords
+ #ret += '[%s]\n' % keywords
+ return ret
+
+ def arg_string_to_list(self,s):
+ """gets a string.
+ removes all occurences of " and splits with , as separator."""
+ s = s.replace('"','')
+ ret = s.split(',')
+ return ret
+
+ def generate_keywords(self,l1,l2,l3):
+ """
+ gets 3 lists of keyword parts.
+ returns a string containing every possible combination of above
+ keywords and its generated variants from quotes_and_braces."
+ """
+ ret = ""
+ list1 = self.arg_string_to_list(l1)
+ list2 = self.arg_string_to_list(l2)
+ list3 = self.arg_string_to_list(l3)
+ for list1item in list1:
+ tmplist1 = []
+ tmplist1 = self.add_prefix_to_strings(list1item+" ",list2)
+ for tmplist1item in tmplist1:
+ tmplist2 = []
+ tmplist2 = self.add_prefix_to_strings(tmplist1item+" ",list3)
+ for tmplist2item in tmplist2:
+ ret += self.quotes_and_braces(tmplist2item)
+ ret += "\n"
+ return ret[:-3] #cut the tailing '\n\n\n'
+
+'''
+ def test():
+ #sample data
+
+
+ #test quotes_and_brace
+ keywords = "fair clothing"
+ expected_result = """fair clothing\n"fair clothing"\n[fair clothing]\n"""
+ if quotes_and_braces(keywords) != expected_result:
+ raise "test of quotes_and_braces() failed!"
+
+ #test add_prefix_to_strings
+ pref = "fair "
+ strlist = ["clothing","clothings"]
+ expected_result = ["fair clothing","fair clothings"]
+ if add_prefix_to_strings(pref,strlist) != expected_result:
+ raise "test of add_prefix_to_strings() failed!"
+
+ #test generate_keywords
+ list1 = ["fair"]
+ list2 = ["clothing","clothings"]
+ list3 = ["buy"]
+ expected_result = """fair clothing buy\n"fair clothing buy"\n[fair clothing buy]\n\n\nfair clothings buy\n"fair clothings buy"\n[fair clothings buy]\n\n\n"""
+
+ if generate_keywords(list1,list2,list3) != expected_result:
+ raise "test of generate_keywords() failed!"
+
+ #test arg_string_to_list(s)
+ s = '"clothing,clothings"'
+ expected_result = ['clothing', 'clothings']
+ if arg_string_to_list(s) != expected_result:
+ raise "test of arg_string_to_list() failed!"
+
+ #test get_arguments()
+ (list1,list2,list3) = get_arguments()
+
+
+if __name__ == "__main__":
+ #test()
+ if len(sys.argv) !=4 :
+ print ' %s is a script for generating keyword lists suitable for google adwords.' % sys.argv[0]
+ print ' usage: %s "part1,alterative part1" "part2, another part2" ",verb"' % sys.argv[0]
+ else:
+ (list1,list2,list3) = get_arguments()
+ print generate_keywords(list1,list2,list3)
+'''
diff --git a/adstreme/glade/kg_frontend.py b/adstreme/glade/kg_frontend.py
new file mode 100644
index 0000000..2db3f45
--- /dev/null
+++ b/adstreme/glade/kg_frontend.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python -v
+
+class KeywordGeneratorFrontend:
+ 'this class handles the gui'
+
+ import kg_calc
+ import sys,string
+
+ def __init__(self, gtkext):
+ # gtk is given, it has to be known in the whole class
+ self.gtk = gtkext
+ # define which gladefile to use for frontend
+ gladefile = "kg-frontend/kg-frontend.glade"
+ self.gui = self.gtk.glade.XML(gladefile)
+ # set button handlers
+ actions = { "on_bu_ok_clicked": self.clicked_ok,
+ "on_window1_destroy": self.exit }
+ # connect the actions to the events
+ self.gui.signal_autoconnect (actions)
+ return
+
+
+ #### implementation of actions
+
+ def clicked_ok(self, widget):
+ 'read input fields and print them'
+ #self.gui.get_widget("tf_output").set_text("saved to file")
+ entry1 = self.gui.get_widget("entry1").get_text()
+ entry2 = self.gui.get_widget("entry2").get_text()
+ entry3 = self.gui.get_widget("entry3").get_text()
+ kg = self.kg_calc.KeywordGenerator()
+ self.keywords = kg.generate_keywords(entry1,entry2,entry3)
+ self.outputfield = self.gui.get_widget("tf_output")
+ self.textbuffer = self.outputfield.get_buffer()
+ self.textbuffer.set_text(self.keywords)
+
+ def exit(self, widget):
+ print "schiss digga"
+ self.sys.exit(1)
+
+
diff --git a/adstreme/keyword_generator.py b/adstreme/keyword_generator.py
index 8352683..cdf4fc1 100644
--- a/adstreme/keyword_generator.py
+++ b/adstreme/keyword_generator.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
#TODO: funktion, die aus parametern schoene listen macht.
import string,sys
@@ -107,9 +108,9 @@ def test():
if __name__ == "__main__":
#test()
- if len(sys.argv) <=1:
+ if len(sys.argv) !=4 :
print ' %s is a script for generating keyword lists suitable for google adwords.' % sys.argv[0]
print ' usage: %s "part1,alterative part1" "part2, another part2" ",verb"' % sys.argv[0]
else:
(list1,list2,list3) = get_arguments()
- print generate_keywords(list1,list2,list3)
\ No newline at end of file
+ print generate_keywords(list1,list2,list3)