* Lib/sgi/flp.py: fix caching bug (always write the whole file to

the cache!)
This commit is contained in:
Guido van Rossum 1994-08-23 13:29:21 +00:00
parent 29e7af07f0
commit 9e1e149a5f
2 changed files with 8 additions and 28 deletions

View File

@ -23,22 +23,12 @@ error = 'flp.error'
# #
def parse_form(filename, formname): def parse_form(filename, formname):
forms = checkcache(filename) forms = checkcache(filename)
if forms != None: if forms is None:
forms = parse_forms(filename)
if forms.has_key(formname): if forms.has_key(formname):
return forms[formname] return forms[formname]
else:
forms = {}
fp = _open_formfile(filename)
nforms = _parse_fd_header(fp)
for i in range(nforms):
form = _parse_fd_form(fp, formname)
if form <> None:
break
else: else:
raise error, 'No such form in fd file' raise error, 'No such form in fd file'
forms[formname] = form
writecache(filename, forms)
return form
# #
# Externally visible function. Load all forms. # Externally visible function. Load all forms.

View File

@ -23,22 +23,12 @@ error = 'flp.error'
# #
def parse_form(filename, formname): def parse_form(filename, formname):
forms = checkcache(filename) forms = checkcache(filename)
if forms != None: if forms is None:
forms = parse_forms(filename)
if forms.has_key(formname): if forms.has_key(formname):
return forms[formname] return forms[formname]
else:
forms = {}
fp = _open_formfile(filename)
nforms = _parse_fd_header(fp)
for i in range(nforms):
form = _parse_fd_form(fp, formname)
if form <> None:
break
else: else:
raise error, 'No such form in fd file' raise error, 'No such form in fd file'
forms[formname] = form
writecache(filename, forms)
return form
# #
# Externally visible function. Load all forms. # Externally visible function. Load all forms.