2020BITS_NUMBER = BITS [0 ] + BITS [1 ]
2121PACKAGE_NAME = "cefpython3"
2222
23- README_TEMPLATE = os .getcwd ()+ r"/README.txt.template "
23+ README_FILE = os .getcwd ()+ r"/README.txt"
2424INIT_TEMPLATE = os .getcwd ()+ r"/__init__.py.template"
2525SETUP_TEMPLATE = os .getcwd ()+ r"/setup.py.template"
2626SETUP_CFG_TEMPLATE = os .getcwd ()+ r"/setup.cfg.template"
@@ -47,6 +47,16 @@ def glob_move(src_glob, dst_folder):
4747 shutil .move (fname ,
4848 os .path .join (dst_folder , os .path .basename (fname )))
4949
50+ def str_format (string , dictionary ):
51+ orig_string = string
52+ for key , value in dictionary .iteritems ():
53+ string = string .replace ("%(" + key + ")s" , value )
54+ if string == orig_string :
55+ raise Exception ("Nothing to format" )
56+ if re .search (r"%\([a-zA-Z0-9_]+\)s" , string ):
57+ raise Exception ("Not all strings formatted" )
58+ return string
59+
5060def main ():
5161 parser = argparse .ArgumentParser (usage = "%(prog)s [options]" )
5262 parser .add_argument ("-v" , "--version" , help = "cefpython version" ,
@@ -61,24 +71,24 @@ def main():
6171 vars ["PY_VERSION_DIGITS_ONLY" ] = (str (sys .version_info .major ) + ""
6272 + str (sys .version_info .minor )) # "27" or "34"
6373
64- print ("Reading template: %s" % README_TEMPLATE )
65- f = open (README_TEMPLATE )
66- README_CONTENT = f .read () % vars
74+ print ("Reading template: %s" % README_FILE )
75+ f = open (README_FILE )
76+ README_CONTENT = f .read ()
6777 f .close ()
6878
6979 print ("Reading template: %s" % INIT_TEMPLATE )
7080 f = open (INIT_TEMPLATE )
71- INIT_CONTENT = f .read () % vars
81+ INIT_CONTENT = str_format ( f .read (), vars )
7282 f .close ()
7383
7484 print ("Reading template: %s" % SETUP_TEMPLATE )
7585 f = open (SETUP_TEMPLATE )
76- SETUP_CONTENT = f .read () % vars
86+ SETUP_CONTENT = str_format ( f .read (), vars )
7787 f .close ()
7888
7989 print ("Reading template: %s" % SETUP_CFG_TEMPLATE )
8090 f = open (SETUP_CFG_TEMPLATE )
81- SETUP_CFG_CONTENT = f .read () % vars
91+ SETUP_CFG_CONTENT = str_format ( f .read (), vars )
8292 f .close ()
8393
8494 installer_dir = os .path .dirname (os .path .abspath (__file__ ))
0 commit comments