# Path: flatland/schema/scalars.py
# class String(Scalar):
#     """A regular old Unicode string."""
# 
#     strip = True
#     """If true, strip leading and trailing whitespace during conversion."""
# 
#     def adapt(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return None
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     def serialize(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``u'' if *value* is ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return u''
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     @property
#     def is_empty(self):
#         """True if the String is missing or has no value."""
#         return True if (not self.value and self.u == u'') else False
# 
# Path: flatland/schema/containers.py
# class Array(Sequence):
#     """A transparent homogeneous Container, for multivalued form elements.
# 
#     Arrays hold a collection of values under a single name, allowing
#     all values of a repeated `(key, value)` pair to be captured and
#     used.  Elements are sequence-like.
# 
#     """
# 
#     prune_empty = True
#     flattenable = False
# 
#     def _set_flat(self, pairs, sep):
#         del self[:]
#         prune = self.prune_empty
#         child_name = self.member_schema.name
# 
#         # TODO: some complexity snuck in below with the thought of supporting
#         # arrays of containers.  they're *not* working yet.
#         assert not issubclass(self.member_schema, Container), \
#                "Flattened Arrays are only supported for scalar child types."
# 
#         if not self.name:
#             child_prefix = child_name or u''
#             for key, value in pairs:
#                 if prune and value == u'' and key == child_prefix:
#                     continue
#                 if key == u'':
#                     key = None
#                 if child_name and key != child_name:
#                     continue
#                 member = self.member_schema.from_flat([(key, value)])
#                 self.append(member)
#         else:
#             regex = re.compile(ur'^(%s(?:%s|$))' % (
#                 re_uescape(self.name), re_uescape(sep)), re.UNICODE)
#             for key, value in pairs:
#                 m = regex.match(key)
#                 if not m:
#                     continue
#                 remainder = key[m.end():] or None
#                 if child_name and not remainder:
#                     continue
#                 elif prune and value == u'' and remainder == child_name:
#                     continue
#                 member = self.member_schema.from_flat([(remainder, value)])
#                 self.append(member)
# 
# Path: tests/markup/_util.py
# class desired_output(object):
# 
#     def __init__(self, language, schema, **kw):
#         self.language = language
#         self.schema = schema
#         self.expected = None
#         self.alternate_expectations = {}
#         self.render_context = kw
# 
#     def __call__(self, fn):
#         self.expected = fn.__doc__.strip()
#         self.alternate_expectations = getattr(fn, 'alternates', {})
#         return self
# 
#     def expectation_for(self, backend):
#         try:
#             return self.alternate_expectations[backend]
#         except KeyError:
#             return self.expected
# 
#     @property
#     def genshi_06(self):
#         def decorator(fn):
#             markup = _wrap_with_xmlns(fn.__doc__, self.language)
#             fn.__doc__ = None
#             @wraps(fn)
#             def runner():
#                 if not have['genshi_06']:
#                     raise SkipTest
#                 got = _render_genshi_06(markup, self.language, self.schema,
#                                         **self.render_context)
#                 expected = self.expectation_for('genshi_06')
#                 if expected != got:
#                     print "\n" + fn.__name__
#                     print "Expected:\n" + expected
#                     print "Got:\n" + got
#                 assert expected == got
#             return runner
#         return decorator
# 
#     @property
#     def genshi_05(self):
#         def decorator(fn):
#             markup = _wrap_with_xmlns(fn.__doc__, self.language)
#             fn.__doc__ = None
#             @wraps(fn)
#             def runner():
#                 if not have['genshi_05']:
#                     raise SkipTest
#                 got = _render_genshi_05(markup, self.language, self.schema,
#                                         **self.render_context)
#                 expected = self.expectation_for('genshi_05')
#                 if expected != got:
#                     print "\n" + fn.__name__
#                     print "Expected:\n" + expected
#                     print "Got:\n" + got
#                 assert expected == got
#             return runner
#         return decorator
# 
#     @property
#     def markup(self):
#         def decorator(fn):
#             @wraps(fn)
#             def runner():
#                 got = _render_markup_fn(fn, self.language, self.schema,
#                                         **self.render_context)
#                 expected = self.expectation_for('markup')
#                 if expected != got:
#                     print "\n" + fn.__name__
#                     print "Expected:\n" + expected
#                     print "Got:\n" + got
#                 assert expected == got
#             return runner
#         return decorator


from flatland import Array, String
from tests._util import fails
from tests.markup._util import desired_output



def scalar_schema():
    schema = String.named(u'scalar')
    return schema(u'abc')


def multivalue_schema():

# Path: flatland/schema/scalars.py
# class String(Scalar):
#     """A regular old Unicode string."""
# 
#     strip = True
#     """If true, strip leading and trailing whitespace during conversion."""
# 
#     def adapt(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return None
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     def serialize(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``u'' if *value* is ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return u''
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     @property
#     def is_empty(self):
#         """True if the String is missing or has no value."""
#         return True if (not self.value and self.u == u'') else False
# 
# Path: flatland/schema/containers.py
# class Array(Sequence):
#     """A transparent homogeneous Container, for multivalued form elements.
# 
#     Arrays hold a collection of values under a single name, allowing
#     all values of a repeated `(key, value)` pair to be captured and
#     used.  Elements are sequence-like.
# 
#     """
# 
#     prune_empty = True
#     flattenable = False
# 
#     def _set_flat(self, pairs, sep):
#         del self[:]
#         prune = self.prune_empty
#         child_name = self.member_schema.name
# 
#         # TODO: some complexity snuck in below with the thought of supporting
#         # arrays of containers.  they're *not* working yet.
#         assert not issubclass(self.member_schema, Container), \
#                "Flattened Arrays are only supported for scalar child types."
# 
#         if not self.name:
#             child_prefix = child_name or u''
#             for key, value in pairs:
#                 if prune and value == u'' and key == child_prefix:
#                     continue
#                 if key == u'':
#                     key = None
#                 if child_name and key != child_name:
#                     continue
#                 member = self.member_schema.from_flat([(key, value)])
#                 self.append(member)
#         else:
#             regex = re.compile(ur'^(%s(?:%s|$))' % (
#                 re_uescape(self.name), re_uescape(sep)), re.UNICODE)
#             for key, value in pairs:
#                 m = regex.match(key)
#                 if not m:
#                     continue
#                 remainder = key[m.end():] or None
#                 if child_name and not remainder:
#                     continue
#                 elif prune and value == u'' and remainder == child_name:
#                     continue
#                 member = self.member_schema.from_flat([(remainder, value)])
#                 self.append(member)
# 
# Path: tests/markup/_util.py
# class desired_output(object):
# 
#     def __init__(self, language, schema, **kw):
#         self.language = language
#         self.schema = schema
#         self.expected = None
#         self.alternate_expectations = {}
#         self.render_context = kw
# 
#     def __call__(self, fn):
#         self.expected = fn.__doc__.strip()
#         self.alternate_expectations = getattr(fn, 'alternates', {})
#         return self
# 
#     def expectation_for(self, backend):
#         try:
#             return self.alternate_expectations[backend]
#         except KeyError:
#             return self.expected
# 
#     @property
#     def genshi_06(self):
#         def decorator(fn):
#             markup = _wrap_with_xmlns(fn.__doc__, self.language)
#             fn.__doc__ = None
#             @wraps(fn)
#             def runner():
#                 if not have['genshi_06']:
#                     raise SkipTest
#                 got = _render_genshi_06(markup, self.language, self.schema,
#                                         **self.render_context)
#                 expected = self.expectation_for('genshi_06')
#                 if expected != got:
#                     print "\n" + fn.__name__
#                     print "Expected:\n" + expected
#                     print "Got:\n" + got
#                 assert expected == got
#             return runner
#         return decorator
# 
#     @property
#     def genshi_05(self):
#         def decorator(fn):
#             markup = _wrap_with_xmlns(fn.__doc__, self.language)
#             fn.__doc__ = None
#             @wraps(fn)
#             def runner():
#                 if not have['genshi_05']:
#                     raise SkipTest
#                 got = _render_genshi_05(markup, self.language, self.schema,
#                                         **self.render_context)
#                 expected = self.expectation_for('genshi_05')
#                 if expected != got:
#                     print "\n" + fn.__name__
#                     print "Expected:\n" + expected
#                     print "Got:\n" + got
#                 assert expected == got
#             return runner
#         return decorator
# 
#     @property
#     def markup(self):
#         def decorator(fn):
#             @wraps(fn)
#             def runner():
#                 got = _render_markup_fn(fn, self.language, self.schema,
#                                         **self.render_context)
#                 expected = self.expectation_for('markup')
#                 if expected != got:
#                     print "\n" + fn.__name__
#                     print "Expected:\n" + expected
#                     print "Got:\n" + got
#                 assert expected == got
#             return runner
#         return decorator


# Path: tests/markup/test_tag_rendering.py
from flatland import Array, String
from tests._util import fails
from tests.markup._util import desired_output




def scalar_schema():
    schema = String.named(u'scalar')
    return schema(u'abc')


def multivalue_schema():

    schema = Array.named(u'multi').of(String)