# Path: statirator/core/utils.py
# def find_readers():
#     """Auto discover readers in installed apps.
# 
#     Each readers.py should have the READERS list with reader classes
#     """
# 
#     from django.conf import settings
#     from django.utils.importlib import import_module
#     from django.utils.module_loading import module_has_submodule
# 
#     readers = []
#     for app in settings.INSTALLED_APPS:
#         mod = import_module(app)
#         # Attempt to import the app's admin module.
#         try:
#             walk_mod = import_module('%s.readers' % app)
#             if hasattr(walk_mod, 'READERS'):
#                 readers.extend(walk_mod.READERS)
#             else:
#                 logging.warn(
#                     'readers found in app %s, but has no READERS attrib',
#                     app)
#         except:
#             # Decide whether to bubble up this error. If the app just
#             # doesn't have an readers module, we can ignore the error
#             # attempting to import it, otherwise we want it to bubble up.
#             if module_has_submodule(mod, 'readers'):
#                 raise
# 
#     return readers
# 
# Path: statirator/core/readers.py
# def dummy_reader():
#     "Just for tests"
# 
# Path: statirator/core/parsers.py
# def parse_rst(content):
#     """Parse multilingual rst document. Content should contain a metadata
#     section which is the same for all languages, and sections for each
#     language. the sections should be separated by comment of "--"". e.g::
# 
#         :slug: some-post-title-slugified
#         :draft: 1
#         :datetime: 2012-09-12 16:03:15
#         :excerpt: Short description
#         :image: /img/some_image.png
# 
#         This will be ignored in main meta section
# 
#         .. --
# 
#         =================
#         English title
#         =================
# 
#         :lang: en
#         :tags: Tag1, Tag2
# 
#         The content of the English post
# 
#         And another paragraph
# 
#         .. --
# 
#         ====================
#         כותרת עברית
#         ====================
# 
#         :lang: he
#         :tags: פייתון|python, Heb Tag2|slug
# 
#         The content of the post in Hebrew
# 
#     Returned value is a genearator::
# 
#         (common metadata, '', content),
#         (metadata, title, content),
#         (metadata, title, content) ...
#     """
# 
#     parts = re.split(r'^\.\.\s+--\s*$', content, flags=re.M)
# 
#     for part in parts:
#         content = ''
#         title = ''
#         metadata = {}
# 
#         tree = publish_doctree(part, settings_overrides=DEFAULTS)
# 
#         for info in tree.traverse(docinfo):
#             for field in info.children:
#                     name_el, body_el = field.children
#                     name = name_el.astext().lower()
#                     if name in FIELDS:
#                         body = body_el.astext()
#                         transform = FIELDS[name]
# 
#                         metadata[name] = transform(body) if transform else body
# 
#         writer = html5writer.SemanticHTML5Writer()
#         publish_from_doctree(tree, writer=writer)
#         content = writer.parts['body']
#         title = writer.parts['title']
#         yield metadata, title, content


import datetime
from django.utils import unittest
from statirator.core.utils import find_readers
from statirator.core.readers import dummy_reader
from statirator.core.parsers import parse_rst

=================
English title
=================

:lang: en
:tags: Tag1, Tag2

The content of the English post

And another paragraph

.. --

====================
כותרת עברית
====================

:lang: he
:tags: פייתון|python, Heb Tag2|slug

The content of the post in Hebrew
""".decode('utf-8')


class CoreTestCase(unittest.TestCase):

    def test_find_readers(self):
        "Correctly find readers"


# Path: statirator/core/utils.py
# def find_readers():
#     """Auto discover readers in installed apps.
# 
#     Each readers.py should have the READERS list with reader classes
#     """
# 
#     from django.conf import settings
#     from django.utils.importlib import import_module
#     from django.utils.module_loading import module_has_submodule
# 
#     readers = []
#     for app in settings.INSTALLED_APPS:
#         mod = import_module(app)
#         # Attempt to import the app's admin module.
#         try:
#             walk_mod = import_module('%s.readers' % app)
#             if hasattr(walk_mod, 'READERS'):
#                 readers.extend(walk_mod.READERS)
#             else:
#                 logging.warn(
#                     'readers found in app %s, but has no READERS attrib',
#                     app)
#         except:
#             # Decide whether to bubble up this error. If the app just
#             # doesn't have an readers module, we can ignore the error
#             # attempting to import it, otherwise we want it to bubble up.
#             if module_has_submodule(mod, 'readers'):
#                 raise
# 
#     return readers
# 
# Path: statirator/core/readers.py
# def dummy_reader():
#     "Just for tests"
# 
# Path: statirator/core/parsers.py
# def parse_rst(content):
#     """Parse multilingual rst document. Content should contain a metadata
#     section which is the same for all languages, and sections for each
#     language. the sections should be separated by comment of "--"". e.g::
# 
#         :slug: some-post-title-slugified
#         :draft: 1
#         :datetime: 2012-09-12 16:03:15
#         :excerpt: Short description
#         :image: /img/some_image.png
# 
#         This will be ignored in main meta section
# 
#         .. --
# 
#         =================
#         English title
#         =================
# 
#         :lang: en
#         :tags: Tag1, Tag2
# 
#         The content of the English post
# 
#         And another paragraph
# 
#         .. --
# 
#         ====================
#         כותרת עברית
#         ====================
# 
#         :lang: he
#         :tags: פייתון|python, Heb Tag2|slug
# 
#         The content of the post in Hebrew
# 
#     Returned value is a genearator::
# 
#         (common metadata, '', content),
#         (metadata, title, content),
#         (metadata, title, content) ...
#     """
# 
#     parts = re.split(r'^\.\.\s+--\s*$', content, flags=re.M)
# 
#     for part in parts:
#         content = ''
#         title = ''
#         metadata = {}
# 
#         tree = publish_doctree(part, settings_overrides=DEFAULTS)
# 
#         for info in tree.traverse(docinfo):
#             for field in info.children:
#                     name_el, body_el = field.children
#                     name = name_el.astext().lower()
#                     if name in FIELDS:
#                         body = body_el.astext()
#                         transform = FIELDS[name]
# 
#                         metadata[name] = transform(body) if transform else body
# 
#         writer = html5writer.SemanticHTML5Writer()
#         publish_from_doctree(tree, writer=writer)
#         content = writer.parts['body']
#         title = writer.parts['title']
#         yield metadata, title, content


# Path: statirator/core/tests.py
import datetime
from django.utils import unittest
from statirator.core.utils import find_readers
from statirator.core.readers import dummy_reader
from statirator.core.parsers import parse_rst


=================
English title
=================

:lang: en
:tags: Tag1, Tag2

The content of the English post

And another paragraph

.. --

====================
כותרת עברית
====================

:lang: he
:tags: פייתון|python, Heb Tag2|slug

The content of the post in Hebrew
""".decode('utf-8')


class CoreTestCase(unittest.TestCase):

    def test_find_readers(self):
        "Correctly find readers"


        readers = find_readers()