e5a21d9b4989fa898ee518f9e55d936d88df9b66
[bertos.git] / wizard / bertos_utils.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
5 # All rights reserved.
6 #
7 # $Id:$
8 #
9 # Author: Lorenzo Berni <duplo@develer.com>
10 #
11
12 import os
13 import fnmatch
14
15 def isBertosDir(directory):
16    return os.path.exists(directory + "/VERSION")
17
18 def bertosVersion(directory):
19    return open(directory + "/VERSION").readline().strip()
20
21 def createBertosProject(directory):
22     if not os.path.isdir(directory):
23         os.mkdir(directory)
24     open(directory + "/project.bertos", "w")
25
26 def findDefinitions(ftype, path):
27     l = os.walk(path)
28     definitions = {}
29     for element in l:
30         for filename in element[2]:
31             if fnmatch.fnmatch(filename, "*." + ftype):
32                 definitions[filename] = element[0]
33     return definitions