118118"""
119119
120120from __future__ import print_function , unicode_literals
121- import hashlib , site , shutil , os
121+ import hashlib
122+ import site
123+ import shutil
124+ import os
122125
123126_ROOT = os .getcwd ()
124127_PACKAGE_NAME = os .path .basename (_ROOT )
125128_DST = os .path .join (site .getsitepackages ()[1 ], _PACKAGE_NAME )
126-
129+
130+
127131def md5_of_file (abspath ):
128132 """Md5 value of a file.
129133 """
@@ -137,6 +141,7 @@ def md5_of_file(abspath):
137141 m .update (data )
138142 return m .hexdigest ()
139143
144+
140145def check_need_install ():
141146 """Check if installed package are exactly the same to this one.
142147 """
@@ -153,7 +158,8 @@ def check_need_install():
153158 else :
154159 return True
155160 return need_install_flag
156-
161+
162+
157163def install ():
158164 """Manual install main script.
159165 """
@@ -164,29 +170,29 @@ def install():
164170 print ("\t package is up-to-date, no need to install." )
165171 return
166172 print ("Difference been found, start installing ..." )
167-
173+
168174 # remove __pycache__ folder and *.pyc file
169- print ("Remove *.pyc file ..." )
175+ print ("Remove *.pyc file ..." )
170176 pyc_folder_list = list ()
171177 for root , _ , basename_list in os .walk (_ROOT ):
172178 if os .path .basename (root ) == "__pycache__" :
173179 pyc_folder_list .append (root )
174-
180+
175181 for folder in pyc_folder_list :
176182 shutil .rmtree (folder )
177183 print ("\t all *.pyc file has been removed." )
178-
184+
179185 # install this package to all python version
180186 print ("Uninstall %s from %s ..." % (_PACKAGE_NAME , _DST ))
181187 try :
182188 shutil .rmtree (_DST )
183189 print ("\t Successfully uninstall %s" % _PACKAGE_NAME )
184190 except Exception as e :
185191 print ("\t %s" % e )
186-
192+
187193 print ("Install %s to %s ..." % (_PACKAGE_NAME , _DST ))
188- shutil .copytree (_ROOT , _DST )
194+ shutil .copytree (_ROOT , _DST )
189195 print ("\t Complete!" )
190-
196+
191197if __name__ == "__main__" :
192198 install ()
0 commit comments