configurationengine/source/plugins/symbian/ConeThemePlugin/themeplugin/theme_function.py
changeset 0 2e8eeb919028
child 5 d2c80f5cab53
equal deleted inserted replaced
-1:000000000000 0:2e8eeb919028
       
     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
       
    31 
       
    32 def convert_hexa_to_decimal(hexa_number):
       
    33     """
       
    34     convert hexa number to decimal number. Hexa number has to have 16 digitals.
       
    35     This method split hexa number to two half and convert them to decimal format.
       
    36     First decimal format is modified using by binary operations. This is for reasons that
       
    37     AknSkinDescCompiler from SDK can't work with big integer numbers
       
    38     """
       
    39     
       
    40     if len(hexa_number) == 16:
       
    41        hexa1 = hexa_number[0:8]
       
    42        hexa2 = hexa_number[8:16]
       
    43 
       
    44        decimal1 = long(hexa1,16)
       
    45        decimal2 = long(hexa2,16)
       
    46        
       
    47        max = 0x7fffffff
       
    48        
       
    49        if decimal1 >= max:
       
    50            pow = 2**31
       
    51            num = decimal1 - pow
       
    52            result = max ^ num
       
    53            decimal1 = 0 - (result + 1);
       
    54 
       
    55        decimal = str(decimal1)+" " +str(decimal2)
       
    56        return decimal   
       
    57    
       
    58     
       
    59 def get_tdf_file(path):
       
    60     """
       
    61     This method takes the name of the tdf file from the .project file 
       
    62     """
       
    63     
       
    64     path = os.path.join(path,".project")
       
    65     etree = ElementTree.parse(path)
       
    66     
       
    67     el_name =  etree.find("name")
       
    68     if el_name != None:
       
    69         return el_name.text
       
    70     else:
       
    71         logging.getLogger('cone.thememl').error("The element name is not in %s" % path)
       
    72         
       
    73 
       
    74 
       
    75 def find_text_in_file(file_path, start_text, end_text):
       
    76     """
       
    77     This method goes over the file and searches text which is located 
       
    78     between start_text and end_text
       
    79     """
       
    80 
       
    81     pkg_file=file(file_path,'r')  
       
    82     for row in pkg_file:  
       
    83         pid = find_text_in_string(row, start_text, end_text)
       
    84         if pid != None:
       
    85             pkg_file.close()
       
    86             return pid
       
    87 
       
    88     pkg_file.close()  
       
    89     return None
       
    90 
       
    91 
       
    92 def find_text_in_string(string, start_text, end_text):
       
    93     """
       
    94     This method return text which is located between start_text and end_text
       
    95     """
       
    96     index_start = string.rfind(start_text)
       
    97     if not index_start==-1:
       
    98         index_end = string.rfind(end_text)
       
    99         str = string[index_start+len(start_text):index_end]
       
   100         return str
       
   101 
       
   102 
       
   103 
       
   104 
       
   105     
       
   106 
       
   107 
       
   108     
       
   109