diff -r 7685cec9fd3c -r f2ddfa555b0f doc/api/python/bsf-pysrc.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/api/python/bsf-pysrc.html Fri Sep 11 11:54:49 2009 +0100 @@ -0,0 +1,273 @@ + + + + + bsf + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Module bsf + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module bsf

+
+  1  #============================================================================  
+  2  #Name        : bsf.py  
+  3  #Part of     : Helium  
+  4   
+  5  #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+  6  #All rights reserved. 
+  7  #This component and the accompanying materials are made available 
+  8  #under the terms of the License "Eclipse Public License v1.0" 
+  9  #which accompanies this distribution, and is available 
+ 10  #at the URL "http://www.eclipse.org/legal/epl-v10.html". 
+ 11  # 
+ 12  #Initial Contributors: 
+ 13  #Nokia Corporation - initial contribution. 
+ 14  # 
+ 15  #Contributors: 
+ 16  # 
+ 17  #Description: 
+ 18  #=============================================================================== 
+ 19   
+ 20  """ Helper module to read bsf files. 
+ 21  """ 
+ 22  import dircache 
+ 23  import os.path 
+ 24  import re 
+ 25   
+
26 -class BSF(object): +
27 """ Class that parse and abstract a bsf file. + 28 """ +
29 - def __init__(self, filename, bsflist): +
30 self._filename = filename + 31 self._is_variant = False + 32 self._is_virtual_variant = False + 33 self._customize = None + 34 self._compile_with_parent = False + 35 self._list = bsflist + 36 self.parse() +
37 +
38 - def parse(self): +
39 """ Parse the bsf file + 40 """ + 41 bsffile = open(self._filename) + 42 for line in bsffile.readlines(): + 43 # skipping empty lines and comment + 44 if re.match(r"^(\s*|\s*#.*)$", line) != None: + 45 continue + 46 + 47 res = re.search(r"^^\s*(?P<key>\w+)\s+(?P<value>\w+)\s*$", line) + 48 if res != None: + 49 if res.groupdict()['key'].lower() == "customizes": + 50 self._customize = res.groupdict()['value'] + 51 + 52 if re.match(r"^^\s*VARIANT\s*$", line) != None: + 53 self._is_variant = True + 54 if re.match(r"^^\s*VIRTUALVARIANT\s*$", line) != None: + 55 self._is_virtual_variant = True + 56 if re.match(r"^^\s*COMPILEWITHPARENT\s*$", line) != None: + 57 self._compile_with_parent = True + 58 + 59 + 60 bsffile.close() +
61 +
62 - def is_variant(self): +
63 """ I am a variant + 64 """ + 65 return self._is_variant +
66 +
67 - def is_virtual_variant(self): +
68 """ I am a virtual variant + 69 """ + 70 return self._is_virtual_variant +
71 +
72 - def customize(self): +
73 """ who am I customizing? + 74 """ + 75 return self._customize.lower() +
76 +
77 - def compile_with_parent(self): +
78 """ who am I customizing? + 79 """ + 80 return self._compile_with_parent +
81 +
82 - def get_name(self): +
83 """ get my name... + 84 """ + 85 return os.path.splitext((os.path.basename(self._filename)))[0].lower() +
86 +
87 - def get_path_as_array(self): +
88 """ return myself plus my parents + 89 """ + 90 result = [self.get_name()] + 91 parent = self._list[self.customize()] + 92 while not parent.is_virtual_variant(): + 93 result.append(parent.get_name()) + 94 parent = self._list[parent.customize()] + 95 result.reverse() + 96 return result +
97 +
98 - def get_path(self): +
99 """ return the path section +100 """ +101 path = self.get_name() +102 parent = self._list[self.customize()] +103 while not parent.is_virtual_variant(): +104 path = parent.get_name()+'/'+path +105 parent = self._list[parent.customize()] +106 return path +107 +108 +
109 -def read_all(path="/epoc32/tools"): +
110 """ Read all bsfs from a directory +111 """ +112 result = {} +113 for bsf in dircache.listdir(path): +114 if os.path.splitext(bsf)[1]==".bsf": +115 bsf = BSF(path+"/"+bsf, result) +116 result[bsf.get_name()] = bsf +117 return result +118 +
119 -def get_includes(bsfs, product): +
120 """ Return an array representing all include path from specific path (product) to generic (platform) +121 """ +122 result = [] +123 configs = bsfs[product].get_path_as_array() +124 configs.reverse() +125 for customisation in configs: +126 result.append(bsfs[customisation].get_path()) +127 return result +
128 +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +