comparison piecrust/sources/prose.py @ 1089:a4d7ff2cdc5c

sources: Update prose source to correctly use the new source API.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 16 Feb 2018 00:14:27 -0800
parents d9059257743c
children
comparison
equal deleted inserted replaced
1088:c5f1936e9e89 1089:a4d7ff2cdc5c
11 11
12 def __init__(self, app, name, config): 12 def __init__(self, app, name, config):
13 super().__init__(app, name, config) 13 super().__init__(app, name, config)
14 self.config_recipe = config.get('config', {}) 14 self.config_recipe = config.get('config', {})
15 15
16 def _doCreateItemMetadata(self, path): 16 def _createItemMetadata(self, path):
17 metadata = super()._doCreateItemMetadata(path) 17 metadata = super()._createItemMetadata(path)
18 config = metadata.setdefault('config', {}) 18 config = metadata.setdefault('config', {})
19 config.update(self._makeConfig(path)) 19 config.update(self._makeConfig(path))
20 return metadata 20 return metadata
21 21
22 def _makeConfig(self, path): 22 def _makeConfig(self, path):
27 27
28 28
29 def get_first_line(path): 29 def get_first_line(path):
30 with open(path, 'r') as f: 30 with open(path, 'r') as f:
31 while True: 31 while True:
32 l = f.readline() 32 line = f.readline()
33 if not l: 33 if not line:
34 break 34 break
35 l = l.strip() 35 line = line.strip()
36 if not l: 36 if not line:
37 continue 37 continue
38 return l 38 return line
39 return None 39 return None
40 40