##// END OF EJS Templates
obsolete: gather _fm0 meta encoding with other _fm0 code
Pierre-Yves David -
r22848:72100c1d default
parent child Browse files
Show More
@@ -208,6 +208,27 b' def _fm0encodeonemarker(marker):'
208 data.extend(sucs)
208 data.extend(sucs)
209 return _pack(format, *data) + metadata
209 return _pack(format, *data) + metadata
210
210
211 def _fm0encodemeta(meta):
212 """Return encoded metadata string to string mapping.
213
214 Assume no ':' in key and no '\0' in both key and value."""
215 for key, value in meta.iteritems():
216 if ':' in key or '\0' in key:
217 raise ValueError("':' and '\0' are forbidden in metadata key'")
218 if '\0' in value:
219 raise ValueError("':' is forbidden in metadata value'")
220 return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)])
221
222 def _fm0decodemeta(data):
223 """Return string to string dictionary from encoded version."""
224 d = {}
225 for l in data.split('\0'):
226 if l:
227 key, value = l.split(':')
228 d[key] = value
229 return d
230
231
211 # mapping to read/write various marker formats
232 # mapping to read/write various marker formats
212 # <version> -> (decoder, encoder)
233 # <version> -> (decoder, encoder)
213 formats = {_fm0version: (_fm0readmarkers, _fm0encodeonemarker)}
234 formats = {_fm0version: (_fm0readmarkers, _fm0encodeonemarker)}
@@ -232,26 +253,6 b' def encodemarkers(markers, addheader=Fal'
232 yield encodeone(marker)
253 yield encodeone(marker)
233
254
234
255
235 def _fm0encodemeta(meta):
236 """Return encoded metadata string to string mapping.
237
238 Assume no ':' in key and no '\0' in both key and value."""
239 for key, value in meta.iteritems():
240 if ':' in key or '\0' in key:
241 raise ValueError("':' and '\0' are forbidden in metadata key'")
242 if '\0' in value:
243 raise ValueError("':' is forbidden in metadata value'")
244 return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)])
245
246 def _fm0decodemeta(data):
247 """Return string to string dictionary from encoded version."""
248 d = {}
249 for l in data.split('\0'):
250 if l:
251 key, value = l.split(':')
252 d[key] = value
253 return d
254
255 class marker(object):
256 class marker(object):
256 """Wrap obsolete marker raw data"""
257 """Wrap obsolete marker raw data"""
257
258
General Comments 0
You need to be logged in to leave comments. Login now