Module misc
[hide private]
[frames] | no frames]

Source Code for Module misc

 1  # This file is part of Androguard. 
 2  # 
 3  # Copyright (C) 2010, Anthony Desnos <desnos at t0t0.org> 
 4  # All rights reserved. 
 5  # 
 6  # Androguard is free software: you can redistribute it and/or modify 
 7  # it under the terms of the GNU Lesser General Public License as published by 
 8  # the Free Software Foundation, either version 3 of the License, or 
 9  # (at your option) any later version. 
10  # 
11  # Androguard is distributed in the hope that it will be useful, 
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of   
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  # GNU Lesser General Public License for more details. 
15  # 
16  # You should have received a copy of the GNU Lesser General Public License 
17  # along with Androguard.  If not, see <http://www.gnu.org/licenses/>. 
18   
19  import sys, time, types 
20   
21  VERSION = "ALPHA 0" 
22   
23 -class Color:
24 normal = "\033[0m" 25 black = "\033[30m" 26 red = "\033[31m" 27 green = "\033[32m" 28 yellow = "\033[33m" 29 blue = "\033[34m" 30 purple = "\033[35m" 31 cyan = "\033[36m" 32 grey = "\033[37m" 33 bold = "\033[1m" 34 uline = "\033[4m" 35 blink = "\033[5m" 36 invert = "\033[7m"
37
38 -def long2str(l):
39 """Convert an integer to a string.""" 40 if type(l) not in (types.IntType, types.LongType): 41 raise ValueError, 'the input must be an integer' 42 43 if l < 0: 44 raise ValueError, 'the input must be greater than 0' 45 s = '' 46 while l: 47 s = s + chr(l & 255L) 48 l >>= 8 49 50 return s
51 52
53 -def str2long(s):
54 """Convert a string to a long integer.""" 55 if type(s) not in (types.StringType, types.UnicodeType): 56 raise ValueError, 'the input must be a string' 57 58 l = 0L 59 for i in s: 60 l <<= 8 61 l |= ord(i) 62 63 return l
64