0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
from shutil import copy
|
|
18 |
try:
|
|
19 |
from cElementTree import ElementTree
|
|
20 |
except ImportError:
|
|
21 |
try:
|
|
22 |
from elementtree import ElementTree
|
|
23 |
except ImportError:
|
|
24 |
try:
|
|
25 |
from xml.etree import cElementTree as ElementTree
|
|
26 |
except ImportError:
|
|
27 |
from xml.etree import ElementTree
|
|
28 |
|
|
29 |
import os
|
|
30 |
import logging
|
5
|
31 |
import re
|
0
|
32 |
|
|
33 |
def convert_hexa_to_decimal(hexa_number):
|
|
34 |
"""
|
|
35 |
convert hexa number to decimal number. Hexa number has to have 16 digitals.
|
|
36 |
This method split hexa number to two half and convert them to decimal format.
|
|
37 |
First decimal format is modified using by binary operations. This is for reasons that
|
|
38 |
AknSkinDescCompiler from SDK can't work with big integer numbers
|
|
39 |
"""
|
|
40 |
|
|
41 |
if len(hexa_number) == 16:
|
|
42 |
hexa1 = hexa_number[0:8]
|
|
43 |
hexa2 = hexa_number[8:16]
|
|
44 |
|
|
45 |
decimal1 = long(hexa1,16)
|
|
46 |
decimal2 = long(hexa2,16)
|
|
47 |
|
|
48 |
max = 0x7fffffff
|
|
49 |
|
|
50 |
if decimal1 >= max:
|
|
51 |
pow = 2**31
|
|
52 |
num = decimal1 - pow
|
|
53 |
result = max ^ num
|
|
54 |
decimal1 = 0 - (result + 1);
|
|
55 |
|
|
56 |
decimal = str(decimal1)+" " +str(decimal2)
|
|
57 |
return decimal
|
|
58 |
|
|
59 |
|
|
60 |
def get_tdf_file(path):
|
|
61 |
"""
|
|
62 |
This method takes the name of the tdf file from the .project file
|
|
63 |
"""
|
|
64 |
|
5
|
65 |
prj_file_path = os.path.join(path,".project")
|
|
66 |
if os.path.exists(prj_file_path):
|
|
67 |
etree = ElementTree.parse(prj_file_path)
|
|
68 |
|
|
69 |
el_name = etree.find("name")
|
|
70 |
if el_name != None:
|
|
71 |
return el_name.text
|
|
72 |
else:
|
|
73 |
logging.getLogger('cone.thememl').error("The element name is not in %s" % prj_file_path)
|
0
|
74 |
else:
|
5
|
75 |
logging.getLogger('cone.thememl').info("No .project file found. Trying to find tdf file.")
|
|
76 |
for root,dirs,files in os.walk(path):
|
|
77 |
for f in files:
|
|
78 |
if f.endswith('tdf'):
|
|
79 |
return re.sub('\.tdf', '', os.path.join(root, f))
|
0
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
def find_text_in_file(file_path, start_text, end_text):
|
|
84 |
"""
|
|
85 |
This method goes over the file and searches text which is located
|
|
86 |
between start_text and end_text
|
|
87 |
"""
|
|
88 |
|
|
89 |
pkg_file=file(file_path,'r')
|
|
90 |
for row in pkg_file:
|
|
91 |
pid = find_text_in_string(row, start_text, end_text)
|
|
92 |
if pid != None:
|
|
93 |
pkg_file.close()
|
|
94 |
return pid
|
|
95 |
|
|
96 |
pkg_file.close()
|
|
97 |
return None
|
|
98 |
|
|
99 |
|
|
100 |
def find_text_in_string(string, start_text, end_text):
|
|
101 |
"""
|
|
102 |
This method return text which is located between start_text and end_text
|
|
103 |
"""
|
|
104 |
index_start = string.rfind(start_text)
|
|
105 |
if not index_start==-1:
|
|
106 |
index_end = string.rfind(end_text)
|
|
107 |
str = string[index_start+len(start_text):index_end]
|
|
108 |
return str
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|