Added TODO and DEVELOPMENT.
[faces-project.git] / faces / utils.py
blobf7d61fb1dc97e71ef08abe78a7ca2acb6dd1107b
1 ############################################################################
2 # Copyright (C) 2005 by Reithinger GmbH
3 # mreithinger@web.de
5 # This file is part of faces.
6 #
7 # faces is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # faces is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the
19 # Free Software Foundation, Inc.,
20 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ############################################################################
23 import observer
24 import os.path
25 import sys
26 import os.path
28 _call_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
30 def get_installation_path():
31 try:
32 if sys.frozen:
33 path = _call_dir
34 else:
35 raise AttributeError()
36 except AttributeError:
37 path = os.path.abspath(observer.__file__)
38 path = os.path.split(path)[0]
40 path = os.path.normcase(path)
41 return path
44 def get_resource_path():
45 try:
46 if sys.frozen:
47 path = _call_dir
48 path = os.path.join(path, "resources", "faces", "gui")
49 else:
50 raise AttributeError()
51 except AttributeError:
52 path = get_installation_path()
53 path = os.path.join(path, "gui", "resources")
55 path = os.path.normcase(path)
56 return path
59 def get_template_path():
60 try:
61 if sys.frozen:
62 path = _call_dir
63 path = os.path.join(path, "resources", "faces", "templates")
64 else:
65 raise AttributeError()
66 except AttributeError:
67 path = get_installation_path()
68 path = os.path.join(path, "templates")
70 path = os.path.normcase(path)
71 return path
74 def get_howtos_path():
75 try:
76 if sys.frozen:
77 path = _call_dir
78 else:
79 raise AttributeError()
80 except AttributeError:
81 path = get_installation_path()
83 path = os.path.join(path, "howtos")
84 path = os.path.normcase(path)
85 return path
89 def flatten(items):
90 if isinstance(items, tuple):
91 items = list(items)
93 if not isinstance(items, list):
94 yield items
96 stack = [iter(items)]
97 while stack:
98 for item in stack[-1]:
99 if isinstance(item, tuple):
100 item = list(item)
102 if isinstance(item, list):
103 stack.append(iter(item))
104 break
105 yield item
106 else:
107 stack.pop()
110 def do_yield():
111 pass
114 def progress_start(title, maximum, message=""):
115 pass
117 def progress_update(value, message=""):
118 pass
120 def progress_end():
121 pass