# Path: newsreap/NNTPSettings.py
# NNTP_EOL = '\r\n'
# 
# Path: newsreap/NNTPMetaContent.py
# class NNTPMetaContent(NNTPContent):
#     """
#     An NNTP Meta representation
#     """
#     def __init__(self, filepath=None, part=0, work_dir=None, sort_no=2500,
#                  *args, **kwargs):
# 
#         super(NNTPMetaContent, self).__init__(
#             filepath=filepath,
#             part=part,
#             work_dir=work_dir, sort_no=sort_no, *args, **kwargs)
# 
#         self.content = list()
#         self._iter = None
# 
#     def key(self):
#         """
#         Returns a key that can be used for sorting with:
#             lambda x : x.key()
#         """
#         return '%.5d/MetaContent/%d' % (self.sort_no, id(self))
# 
#     def next(self):
#         """
#         Python 2 support
#         Support stream type functions and iterations
#         """
#         if not self._iter:
#             self._iter = iter(self.content)
# 
#         return next(self._iter)
# 
#     def __next__(self):
#         """
#         Python 3 support
#         Support iterating through list
#         """
#         if not self._iter:
#             self._iter = iter(self.content)
# 
#         return next(self._iter)
# 
#     def __iter__(self):
#         """
#         Mimic iter()
#         """
#         return iter(self.content)
# 
#     def __delitem__(self, key):
#         """
#         Mimic del action
#         """
#         del self.content[key]
# 
#     def __contains__(self, item):
#         """
#         Mimic 'in' directive
#         """
#         return item in self.content
# 
#     def __len__(self):
#         """
#         Support len() call
#         """
#         return len(self.content)
# 
#     def __repr__(self):
#         """
#         Keep it only possible to track 1 header
#         """
#         return '<NNTPMetaContent sort=%d content="%s" />' % (
#             self.sort_no, repr(self.content),
#         )


import re
from .NNTPSettings import NNTP_EOL
from .NNTPMetaContent import NNTPMetaContent
        # Initialize our header
        self.content = dict()

    def __setitem__(self, key, item):
        """
        Mimic Dictionary:  dict[key] = value
        """
        key = self.__fmt_key(key)
        self.content[key] = item

    def __getitem__(self, key):
        """
        Mimic Dictionary:  value = dict[key]
        """
        key = self.__fmt_key(key)
        return self.content[key]

    def post_iter(self):
        """
        Returns NNTP string as it would be required for posting
        """
        for k in HEADER_PRINT_SEQUENCE:
            if k in self.content:
                yield '%s: %s%s' % (k, self.content[k], NNTP_EOL)

        for k, v in self.content.iteritems():
            if k not in HEADER_PRINT_SEQUENCE:
                yield '%s: %s%s' % (k, v, NNTP_EOL)

        # Last entry

# Path: newsreap/NNTPSettings.py
# NNTP_EOL = '\r\n'
# 
# Path: newsreap/NNTPMetaContent.py
# class NNTPMetaContent(NNTPContent):
#     """
#     An NNTP Meta representation
#     """
#     def __init__(self, filepath=None, part=0, work_dir=None, sort_no=2500,
#                  *args, **kwargs):
# 
#         super(NNTPMetaContent, self).__init__(
#             filepath=filepath,
#             part=part,
#             work_dir=work_dir, sort_no=sort_no, *args, **kwargs)
# 
#         self.content = list()
#         self._iter = None
# 
#     def key(self):
#         """
#         Returns a key that can be used for sorting with:
#             lambda x : x.key()
#         """
#         return '%.5d/MetaContent/%d' % (self.sort_no, id(self))
# 
#     def next(self):
#         """
#         Python 2 support
#         Support stream type functions and iterations
#         """
#         if not self._iter:
#             self._iter = iter(self.content)
# 
#         return next(self._iter)
# 
#     def __next__(self):
#         """
#         Python 3 support
#         Support iterating through list
#         """
#         if not self._iter:
#             self._iter = iter(self.content)
# 
#         return next(self._iter)
# 
#     def __iter__(self):
#         """
#         Mimic iter()
#         """
#         return iter(self.content)
# 
#     def __delitem__(self, key):
#         """
#         Mimic del action
#         """
#         del self.content[key]
# 
#     def __contains__(self, item):
#         """
#         Mimic 'in' directive
#         """
#         return item in self.content
# 
#     def __len__(self):
#         """
#         Support len() call
#         """
#         return len(self.content)
# 
#     def __repr__(self):
#         """
#         Keep it only possible to track 1 header
#         """
#         return '<NNTPMetaContent sort=%d content="%s" />' % (
#             self.sort_no, repr(self.content),
#         )


# Path: newsreap/NNTPHeader.py
import re
from .NNTPSettings import NNTP_EOL
from .NNTPMetaContent import NNTPMetaContent

        # Initialize our header
        self.content = dict()

    def __setitem__(self, key, item):
        """
        Mimic Dictionary:  dict[key] = value
        """
        key = self.__fmt_key(key)
        self.content[key] = item

    def __getitem__(self, key):
        """
        Mimic Dictionary:  value = dict[key]
        """
        key = self.__fmt_key(key)
        return self.content[key]

    def post_iter(self):
        """
        Returns NNTP string as it would be required for posting
        """
        for k in HEADER_PRINT_SEQUENCE:
            if k in self.content:
                yield '%s: %s%s' % (k, self.content[k], NNTP_EOL)

        for k, v in self.content.iteritems():
            if k not in HEADER_PRINT_SEQUENCE:
                yield '%s: %s%s' % (k, v, NNTP_EOL)

        # Last entry

        yield NNTP_EOL