comparison piecrust/sources/posts.py @ 109:438509f12332

Fix post sources datetimes by adding missing metadata when in "find" mode.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 15 Oct 2014 23:02:21 -0700
parents d74ae33832ae
children f130365568ff
comparison
equal deleted inserted replaced
108:b6ec402d32bb 109:438509f12332
97 pattern = path_format_re % regex_repl + '$' 97 pattern = path_format_re % regex_repl + '$'
98 m = re.search(pattern, path.replace('\\', '/')) 98 m = re.search(pattern, path.replace('\\', '/'))
99 if not m: 99 if not m:
100 raise Exception("Expected to be able to match path with path " 100 raise Exception("Expected to be able to match path with path "
101 "format: %s" % path) 101 "format: %s" % path)
102
103 year = int(m.group('year'))
104 month = int(m.group('month'))
105 day = int(m.group('day'))
106 timestamp = datetime.date(year, month, day)
102 fac_metadata = { 107 fac_metadata = {
103 'year': m.group('year'), 108 'year': year,
104 'month': m.group('month'), 109 'month': month,
105 'day': m.group('day'), 110 'day': day,
106 'slug': m.group('slug') 111 'slug': m.group('slug'),
112 'date': timestamp
107 } 113 }
114
108 rel_path = os.path.relpath(path, self.fs_endpoint_path) 115 rel_path = os.path.relpath(path, self.fs_endpoint_path)
109 rel_path = rel_path.replace('\\', '/') 116 rel_path = rel_path.replace('\\', '/')
110 return rel_path, fac_metadata 117 return rel_path, fac_metadata
111 118
112 def setupPrepareParser(self, parser, app): 119 def setupPrepareParser(self, parser, app):