mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Use string methods.
This commit is contained in:
parent
06912b7702
commit
071972e426
7 changed files with 18 additions and 23 deletions
|
|
@ -3,7 +3,6 @@
|
|||
Usage: rewrite.py boilerplate.tex [VAR=value] ... <template >output
|
||||
"""
|
||||
|
||||
import string
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
|
@ -12,9 +11,9 @@ def get_info(fp):
|
|||
s = fp.read()
|
||||
|
||||
d = {}
|
||||
start = string.find(s, r"\date{")
|
||||
start = s.find(r"\date{")
|
||||
if start >= 0:
|
||||
end = string.find(s, "}", start)
|
||||
end = s.find("}", start)
|
||||
date = s[start+6:end]
|
||||
if date == r"\today":
|
||||
date = time.strftime("%B %d, %Y", time.localtime(time.time()))
|
||||
|
|
@ -28,14 +27,14 @@ def main():
|
|||
# yes, we actully need to load the replacement values
|
||||
d = get_info(open(sys.argv[1]))
|
||||
for arg in sys.argv[2:]:
|
||||
name, value = string.split(arg, "=", 1)
|
||||
name, value = arg.split("=", 1)
|
||||
d[name] = value
|
||||
start = 0
|
||||
while 1:
|
||||
start = string.find(s, "@", start)
|
||||
start = s.find("@", start)
|
||||
if start < 0:
|
||||
break
|
||||
end = string.find(s, "@", start+1)
|
||||
end = s.find("@", start+1)
|
||||
name = s[start+1:end]
|
||||
if name:
|
||||
value = d.get(name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue