1212from sys import stdout , stderr , platform
1313from os .path import (join , dirname , realpath , exists , isdir , basename ,
1414 expanduser , splitext , split )
15- from os import listdir , unlink , makedirs , environ , chdir , getcwd , walk , uname
15+ from os import listdir , unlink , makedirs , environ , chdir , getcwd , uname
1616import os
1717import zipfile
1818import tarfile
@@ -56,7 +56,7 @@ def __init__(self):
5656
5757 def __getattr__ (self , key ):
5858 return self ._dict [key ]
59-
59+
6060Null_Style = Null_Fore = colorama_shim ()
6161
6262if stdout .isatty ():
@@ -148,14 +148,19 @@ def pretty_log_dists(dists, log_func=info):
148148 for line in infos :
149149 log_func ('\t ' + line )
150150
151+
151152def shorten_string (string , max_width ):
152153 ''' make limited length string in form:
153154 "the string is very lo...(and 15 more)"
154- '''
155+ '''
155156 string_len = len (string )
156- if string_len <= max_width : return string
157- visible = max_width - 16 - int (log10 (string_len )) #expected suffix len "...(and XXXXX more)"
158- return '' .join ((string [:visible ], '...(and ' , str (string_len - visible ), ' more)' ))
157+ if string_len <= max_width :
158+ return string
159+ visible = max_width - 16 - int (log10 (string_len ))
160+ # expected suffix len "...(and XXXXX more)"
161+ return '' .join ((string [:visible ], '...(and ' , str (string_len - visible ),
162+ ' more)' ))
163+
159164
160165def shprint (command , * args , ** kwargs ):
161166 '''Runs the command (which should be an sh.Command instance), while
@@ -351,17 +356,19 @@ def current_directory(new_dir):
351356 Err_Fore .RESET )))
352357 chdir (cur_dir )
353358
359+
354360@contextlib .contextmanager
355361def temp_directory ():
356362 temp_dir = mkdtemp ()
357363 try :
358- logger .debug ('' .join ((Err_Fore .CYAN , ' + temp directory used ' , temp_dir ,
359- Err_Fore .RESET )))
364+ logger .debug ('' .join ((Err_Fore .CYAN , ' + temp directory used ' ,
365+ temp_dir , Err_Fore .RESET )))
360366 yield temp_dir
361367 finally :
362368 shutil .rmtree (temp_dir )
363- logger .debug ('' .join ((Err_Fore .CYAN , ' - temp directory deleted ' , temp_dir ,
364- Err_Fore .RESET )))
369+ logger .debug ('' .join ((Err_Fore .CYAN , ' - temp directory deleted ' ,
370+ temp_dir , Err_Fore .RESET )))
371+
365372
366373def cache_execution (f ):
367374 def _cache_execution (self , * args , ** kwargs ):
@@ -532,21 +539,25 @@ def get_env(self):
532539
533540 return env
534541
542+
535543class ArchARM (Arch ):
536544 arch = "armeabi"
537545 toolchain_prefix = 'arm-linux-androideabi'
538546 command_prefix = 'arm-linux-androideabi'
539547 platform_dir = 'arch-arm'
540548
549+
541550class ArchARMv7_a (ArchARM ):
542551 arch = 'armeabi-v7a'
543552
544553 def get_env (self ):
545554 env = super (ArchARMv7_a , self ).get_env ()
546- env ['CFLAGS' ] = env ['CFLAGS' ] + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb'
555+ env ['CFLAGS' ] = (env ['CFLAGS' ] +
556+ ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb' )
547557 env ['CXXFLAGS' ] = env ['CFLAGS' ]
548558 return env
549559
560+
550561class Archx86 (Arch ):
551562 arch = 'x86'
552563 toolchain_prefix = 'x86'
@@ -555,10 +566,12 @@ class Archx86(Arch):
555566
556567 def get_env (self ):
557568 env = super (Archx86 , self ).get_env ()
558- env ['CFLAGS' ] = env ['CFLAGS' ] + ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32'
569+ env ['CFLAGS' ] = (env ['CFLAGS' ] +
570+ ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32' )
559571 env ['CXXFLAGS' ] = env ['CFLAGS' ]
560572 return env
561573
574+
562575class Archx86_64 (Arch ):
563576 arch = 'x86_64'
564577 toolchain_prefix = 'x86'
@@ -567,7 +580,8 @@ class Archx86_64(Arch):
567580
568581 def get_env (self ):
569582 env = super (Archx86_64 , self ).get_env ()
570- env ['CFLAGS' ] = env ['CFLAGS' ] + ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel'
583+ env ['CFLAGS' ] = (env ['CFLAGS' ] +
584+ ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel' )
571585 env ['CXXFLAGS' ] = env ['CFLAGS' ]
572586 return env
573587
0 commit comments