Commit d1e46146 authored by Łukasz Nowak's avatar Łukasz Nowak

recipe/readline: Add when-absent feature

Allows to use recipe for cases when file is not present yet so it can return
some default (marker-like) value.
parent b5cd5f6d
Pipeline #17668 passed with stage
......@@ -43,13 +43,14 @@ class Recipe(object):
def __init__(self, buildout, name, options):
storage_path = options['storage-path']
when_absent = options.get('when-absent', None)
with open(storage_path) as f:
readline = f.readline()
except IOError as e:
if e.errno != errno.ENOENT:
readline = None
readline = when_absent
self.readline = readline
options['readline'] = readline
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment