Skip to content

Commit

Permalink
[更新] 修复python27上运行错误, 目前python27和37都可以运行.
Browse files Browse the repository at this point in the history
  • Loading branch information
liu2guang committed Sep 17, 2018
1 parent e2cc032 commit 3360a3c
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions buildpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,20 @@ def buildpkg_add_readme(pkgname, version):

log.debug("find readme.md template: \"%s\"" % (template_readme_path))

with open(template_readme_path, 'r', encoding='utf-8') as file_in, open(readme_path, 'w+', encoding='utf-8') as file_out:
textlist = file_in.readlines()
for line in textlist:
line = line.replace("{{name}}", pkgname)
line = line.replace("{{version}}", version)
file_out.write(line)
if sys.version_info < (3, 0):
with open(template_readme_path, 'r') as file_in, open(readme_path, 'w+') as file_out:
textlist = file_in.readlines()
for line in textlist:
line = line.replace("{{name}}", pkgname)
line = line.replace("{{version}}", version)
file_out.write(line)
else:
with open(template_readme_path, 'r', encoding='utf-8') as file_in, open(readme_path, 'w+', encoding='utf-8') as file_out:
textlist = file_in.readlines()
for line in textlist:
line = line.replace("{{name}}", pkgname)
line = line.replace("{{version}}", version)
file_out.write(line)
log.info("add readme.md success...")

# add SConscript file
Expand All @@ -83,14 +91,24 @@ def buildpkg_add_sconscript(pkgname, version):

log.debug("find SConscript template: \"%s\"" % (template_sconscript_path))

with open(template_sconscript_path, 'r', encoding='utf-8') as file_in, open(sconscript_path, 'w+', encoding='utf-8') as file_out:
textlist = file_in.readlines()
for line in textlist:
line = line.replace("{{name}}", pkgname)
line = line.replace("{{version}}", version)
line = line.replace("{{date}}", time.strftime("%Y-%m-%d", time.localtime()))
line = line.replace("{{datetime}}", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
file_out.write(line)
if sys.version_info < (3, 0):
with open(template_sconscript_path, 'r') as file_in, open(sconscript_path, 'w+') as file_out:
textlist = file_in.readlines()
for line in textlist:
line = line.replace("{{name}}", pkgname)
line = line.replace("{{version}}", version)
line = line.replace("{{date}}", time.strftime("%Y-%m-%d", time.localtime()))
line = line.replace("{{datetime}}", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
file_out.write(line)
else:
with open(template_sconscript_path, 'r', encoding='utf-8') as file_in, open(sconscript_path, 'w+', encoding='utf-8') as file_out:
textlist = file_in.readlines()
for line in textlist:
line = line.replace("{{name}}", pkgname)
line = line.replace("{{version}}", version)
line = line.replace("{{date}}", time.strftime("%Y-%m-%d", time.localtime()))
line = line.replace("{{datetime}}", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
file_out.write(line)
log.info("add SConscript success...")

# add git repository
Expand Down

0 comments on commit 3360a3c

Please sign in to comment.