# Path: lektor/metaformat.py
# def serialize(iterable, encoding=None):
#     """Serializes an iterable of key value pairs into a stream of
#     string chunks.  If an encoding is provided, it will be encoded into that.
# 
#     This is primarily used by the editor to write back data to a source file.
#     """
#     def _produce(item, escape=False):
#         if escape:
#             if _line_is_dashes(item):
#                 item = u'-' + item
#         if encoding is not None:
#             item = item.encode(encoding)
#         return item
# 
#     for idx, (key, value) in enumerate(iterable):
#         value = value.replace('\r\n', '\n').replace('\r', '\n')
#         if idx > 0:
#             yield '---\n'
#         if '\n' in value or value.strip('\t ') != value:
#             yield _produce(key + ':\n')
#             yield _produce('\n')
#             for line in value.splitlines(True):
#                 yield _produce(line, escape=True)
#             yield _produce('\n')
#         else:
#             yield _produce('%s: %s\n' % (key, value))
# 
# Path: lektor/environment.py
# PRIMARY_ALT = '_primary'


import os
import shutil
import posixpath
from collections import OrderedDict
from lektor.metaformat import serialize
from lektor.utils import atomic_open, is_valid_id, secure_filename, \
     increment_filename
from lektor.environment import PRIMARY_ALT
            value = self._data.get(key)
            if value is not None:
                yield key, value

    def iterkeys(self):
        for key, _ in self.iteritems():
            yield key

    def itervalues(self):
        for _, value in self.iteritems():
            yield value

    def items(self):
        return list(self.iteritems())

    def keys(self):
        return list(self.iterkeys())

    def values(self):
        return list(self.itervalues())

    __iter__ = iterkeys

    def __len__(self):
        return len(self.items())

    def get_fs_path(self, alt=PRIMARY_ALT):
        """The path to the record file on the file system."""
        base = self.pad.db.to_fs_path(self.path)
        suffix = '.lr'

# Path: lektor/metaformat.py
# def serialize(iterable, encoding=None):
#     """Serializes an iterable of key value pairs into a stream of
#     string chunks.  If an encoding is provided, it will be encoded into that.
# 
#     This is primarily used by the editor to write back data to a source file.
#     """
#     def _produce(item, escape=False):
#         if escape:
#             if _line_is_dashes(item):
#                 item = u'-' + item
#         if encoding is not None:
#             item = item.encode(encoding)
#         return item
# 
#     for idx, (key, value) in enumerate(iterable):
#         value = value.replace('\r\n', '\n').replace('\r', '\n')
#         if idx > 0:
#             yield '---\n'
#         if '\n' in value or value.strip('\t ') != value:
#             yield _produce(key + ':\n')
#             yield _produce('\n')
#             for line in value.splitlines(True):
#                 yield _produce(line, escape=True)
#             yield _produce('\n')
#         else:
#             yield _produce('%s: %s\n' % (key, value))
# 
# Path: lektor/environment.py
# PRIMARY_ALT = '_primary'


# Path: lektor/editor.py
import os
import shutil
import posixpath
from collections import OrderedDict
from lektor.metaformat import serialize
from lektor.utils import atomic_open, is_valid_id, secure_filename, \
     increment_filename
from lektor.environment import PRIMARY_ALT

            value = self._data.get(key)
            if value is not None:
                yield key, value

    def iterkeys(self):
        for key, _ in self.iteritems():
            yield key

    def itervalues(self):
        for _, value in self.iteritems():
            yield value

    def items(self):
        return list(self.iteritems())

    def keys(self):
        return list(self.iterkeys())

    def values(self):
        return list(self.itervalues())

    __iter__ = iterkeys

    def __len__(self):
        return len(self.items())

    def get_fs_path(self, alt=PRIMARY_ALT):
        """The path to the record file on the file system."""
        base = self.pad.db.to_fs_path(self.path)
        suffix = '.lr'

        if alt != PRIMARY_ALT: