1616
1717BITS = platform .architecture ()[0 ]
1818assert (BITS == "32bit" or BITS == "64bit" )
19- IF BITS == "32bit" :
19+ if BITS == "32bit" :
2020 LINUX_BITS = "linux32"
21- ELSE :
21+ else :
2222 LINUX_BITS = "linux64"
2323PACKAGE_NAME = "cefpython3"
2424
25- README_TEMPLATE = os .getcwd ()+ r"/README.txt.template "
25+ README_FILE = os .getcwd ()+ r"/README.txt"
2626INIT_TEMPLATE = os .getcwd ()+ r"/__init__.py.template"
2727SETUP_TEMPLATE = os .getcwd ()+ r"/setup.py.template"
2828SETUP_CFG_TEMPLATE = os .getcwd ()+ r"/setup.cfg.template"
2929
30+ def str_format (string , dictionary ):
31+ orig_string = string
32+ for key , value in dictionary .iteritems ():
33+ string = string .replace ("%(" + key + ")s" , value )
34+ if string == orig_string :
35+ raise Exception ("Nothing to format" )
36+ return string
37+
38+
3039def main ():
3140 parser = argparse .ArgumentParser (usage = "%(prog)s [options]" )
3241 parser .add_argument ("-v" , "--version" , help = "cefpython version" ,
@@ -37,28 +46,28 @@ def main():
3746
3847 vars = {}
3948 vars ["APP_VERSION" ] = args .version
40- vars ["PLATFORM " ] = sysconfig .get_platform ()
49+ vars ["PLATFORM2 " ] = sysconfig .get_platform ()
4150 vars ["PY_VERSION_DIGITS_ONLY" ] = (str (sys .version_info .major ) + ""
4251 + str (sys .version_info .minor )) # "27" or "34"
4352
44- print ("Reading template: %s" % README_TEMPLATE )
45- f = open (README_TEMPLATE )
46- README_CONTENT = f .read () % vars
53+ print ("Reading template: %s" % README_FILE )
54+ f = open (README_FILE )
55+ README_CONTENT = f .read ()
4756 f .close ()
4857
4958 print ("Reading template: %s" % INIT_TEMPLATE )
5059 f = open (INIT_TEMPLATE )
51- INIT_CONTENT = f .read () % vars
60+ INIT_CONTENT = str_format ( f .read (), vars )
5261 f .close ()
5362
5463 print ("Reading template: %s" % SETUP_TEMPLATE )
5564 f = open (SETUP_TEMPLATE )
56- SETUP_CONTENT = f .read () % vars
65+ SETUP_CONTENT = str_format ( f .read (), vars )
5766 f .close ()
5867
5968 print ("Reading template: %s" % SETUP_CFG_TEMPLATE )
6069 f = open (SETUP_CFG_TEMPLATE )
61- SETUP_CFG_CONTENT = f .read () % vars
70+ SETUP_CFG_CONTENT = str_format ( f .read (), vars )
6271 f .close ()
6372
6473 installer_dir = os .path .dirname (os .path .abspath (__file__ ))
0 commit comments