3 # Copyright 2014 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # -*- mode: python; encoding: utf-8; -*-
20 def get_string(self, prompt=""):
21 return raw_input(prompt.encode("utf-8"))
25 self.show_item(str(i) + ". " + l)
27 ans = self.get_string("Option: ")
35 def show_item(self, s):
38 menu = [ "Exit", "Edit", "Delete" ]
39 actions = [ None, "edit", "delete" ]
45 self.show_item("0. Exit")
46 self.show_item("1. Add")
49 self.show_item(str(i) + ". " + l)
51 ans = self.get_string("Option: ")
54 if opt >= i or opt <= 0:
58 return (opt - 1, self.item())
64 self.show_item("0. Exit")
67 if f.get_type() == "string":
68 self.show_item(str(i) + ". " + f.get_name() + ": " + f.get_value())
69 elif f.get_type() == "options":
70 self.show_item(str(i) + ". " + f.get_name() + ": " + f.get_cur_display())
72 ans = self.get_string("Option: ")
76 # raise/show error/message about wrong option
83 self.show_form(fs[opt - 1])
84 def show_form(self, f):
85 if f.get_type() == "string":
86 self.show_item(f.get_name() + ": " + f.get_value())
87 s = self.get_string(f.get_name() + ": ")
89 elif f.get_type() == "options":
91 def show_options(self, f):
92 self.show_item(f.get_name() + ": " + f.get_cur_display())
93 for i in range(f.get_length()):
94 self.show_item(str(i) + ". " + f.get_display(i))
95 ans = self.get_string("Option: ")
99 # raise/show error/message about wrong option
103 f.set_value(f.get_value(opt))
106 # vim:tabstop=4:expandtab:smartindent