# Path: concepts/formats/base.py
# class SerializedArgs(ContextArgs):
# 
#     lattice: typing.Optional[LatticeType] = None
# 
# class Format(metaclass=FormatMeta):
#     """Parse and serialize formal contexts in a specific string format."""
# 
#     __abstract__ = True
# 
#     encoding = None
# 
#     newline = None
# 
#     dumps_rstrip = None
# 
#     @classmethod
#     def load(cls, filename, encoding, **kwargs) -> ContextArgs:
#         """Load and parse serialized objects, properties, bools from file."""
#         if encoding is None:
#             encoding = cls.encoding
# 
#         with open(filename, encoding=encoding, newline=cls.newline) as f:
#             return cls.loadf(f, **kwargs)
# 
#     @classmethod
#     def loads(cls, source, **kwargs) -> ContextArgs:
#         """Parse source string and return ``ContextArgs``."""
#         with io.StringIO(source) as buf:
#             return cls.loadf(buf, **kwargs)
# 
#     @classmethod
#     def dump(cls, filename, objects, properties, bools,
#              *, encoding: typing.Optional[str], _serialized=None, **kwargs):
#         """Write serialized objects, properties, bools to file."""
#         if encoding is None:
#             encoding = cls.encoding
# 
#         with open(filename, 'w', encoding=encoding, newline=cls.newline) as f:
#             cls.dumpf(f, objects, properties, bools, _serialized=_serialized,
#                       **kwargs)
# 
#     @classmethod
#     def dumps(cls, objects, properties, bools, _serialized=None, **kwargs):
#         with io.StringIO(newline=cls.newline) as buf:
#             cls.dumpf(buf, objects, properties, bools, _serialized=_serialized,
#                       **kwargs)
#             source = buf.getvalue()
#         if cls.dumps_rstrip:
#             source = source.rstrip()
#         return source
# 
#     @staticmethod
#     def loadf(file, **kwargs) -> ContextArgs:
#         """Parse file-like object and return ``ContextArgs``."""
#         raise NotImplementedError  # pragma: no cover
# 
#     @staticmethod
#     def dumpf(file, objects, properties, bools, *, _serialized=None, **kwargs):
#         """Serialize ``(objects, properties, bools)`` into file-like object."""
#         raise NotImplementedError  # pragma: no cover


import ast
import functools
from .base import SerializedArgs, Format
        keys = ('objects', 'properties', 'context')
        assert all(k in doc for k in keys)

    indent = ' ' * 2

    def itersection(key, lines, value_list: bool = False):
        start, end = ('[', ']') if value_list else ('(', ')')

        yield f'{indent}{key!r}: {start}'
        yield from lines
        yield f'{indent}{end},'

    def iterlines(doc):
        yield '{'

        for key in ('objects', 'properties'):
            line = ', '.join(map(repr, doc[key]))
            yield from itersection(key, [f'{indent * 2}{line},'])

        for key in ('context',) + (('lattice',) if 'lattice' in doc else ()):
            lines = [f'{indent * 2}{line},' for line in map(repr, doc[key])]
            yield from itersection(key, lines, value_list=True)

        yield '}'

    write = functools.partial(print, file=file)
    for line in iterlines(doc):
        write(line)



# Path: concepts/formats/base.py
# class SerializedArgs(ContextArgs):
# 
#     lattice: typing.Optional[LatticeType] = None
# 
# class Format(metaclass=FormatMeta):
#     """Parse and serialize formal contexts in a specific string format."""
# 
#     __abstract__ = True
# 
#     encoding = None
# 
#     newline = None
# 
#     dumps_rstrip = None
# 
#     @classmethod
#     def load(cls, filename, encoding, **kwargs) -> ContextArgs:
#         """Load and parse serialized objects, properties, bools from file."""
#         if encoding is None:
#             encoding = cls.encoding
# 
#         with open(filename, encoding=encoding, newline=cls.newline) as f:
#             return cls.loadf(f, **kwargs)
# 
#     @classmethod
#     def loads(cls, source, **kwargs) -> ContextArgs:
#         """Parse source string and return ``ContextArgs``."""
#         with io.StringIO(source) as buf:
#             return cls.loadf(buf, **kwargs)
# 
#     @classmethod
#     def dump(cls, filename, objects, properties, bools,
#              *, encoding: typing.Optional[str], _serialized=None, **kwargs):
#         """Write serialized objects, properties, bools to file."""
#         if encoding is None:
#             encoding = cls.encoding
# 
#         with open(filename, 'w', encoding=encoding, newline=cls.newline) as f:
#             cls.dumpf(f, objects, properties, bools, _serialized=_serialized,
#                       **kwargs)
# 
#     @classmethod
#     def dumps(cls, objects, properties, bools, _serialized=None, **kwargs):
#         with io.StringIO(newline=cls.newline) as buf:
#             cls.dumpf(buf, objects, properties, bools, _serialized=_serialized,
#                       **kwargs)
#             source = buf.getvalue()
#         if cls.dumps_rstrip:
#             source = source.rstrip()
#         return source
# 
#     @staticmethod
#     def loadf(file, **kwargs) -> ContextArgs:
#         """Parse file-like object and return ``ContextArgs``."""
#         raise NotImplementedError  # pragma: no cover
# 
#     @staticmethod
#     def dumpf(file, objects, properties, bools, *, _serialized=None, **kwargs):
#         """Serialize ``(objects, properties, bools)`` into file-like object."""
#         raise NotImplementedError  # pragma: no cover


# Path: concepts/formats/python_literal.py
import ast
import functools
from .base import SerializedArgs, Format

        keys = ('objects', 'properties', 'context')
        assert all(k in doc for k in keys)

    indent = ' ' * 2

    def itersection(key, lines, value_list: bool = False):
        start, end = ('[', ']') if value_list else ('(', ')')

        yield f'{indent}{key!r}: {start}'
        yield from lines
        yield f'{indent}{end},'

    def iterlines(doc):
        yield '{'

        for key in ('objects', 'properties'):
            line = ', '.join(map(repr, doc[key]))
            yield from itersection(key, [f'{indent * 2}{line},'])

        for key in ('context',) + (('lattice',) if 'lattice' in doc else ()):
            lines = [f'{indent * 2}{line},' for line in map(repr, doc[key])]
            yield from itersection(key, lines, value_list=True)

        yield '}'

    write = functools.partial(print, file=file)
    for line in iterlines(doc):
        write(line)



class PythonLiteral(Format):