# Path: xnb_parse/type_reader.py
# class TypeReaderPlugin(Plugin):
#     """
#     type reader plugins
#     """
# 
# class ValueTypeReader(BaseTypeReader):
#     is_value_type = True
# 
# class GenericTypeReader(BaseTypeReader):
#     generic_target_type = None
#     generic_reader_name = None
#     is_generic_type = True
#     generic_params = None
#     readers = None
# 
#     def init_reader(self, file_platform=None, file_version=None):
#         BaseTypeReader.init_reader(self, file_platform, file_version)
#         if self.readers is None:
#             self.readers = []
#         for arg in self.generic_params:
#             reader = self.stream.get_type_reader_by_type(arg)
#             reader.init_reader(file_platform, file_version)
#             self.readers.append(reader)
# 
#     @classmethod
#     def create_from_type(cls, type_spec):
#         # really need to figure out how to do this more cleanly
#         body = dict(cls.__dict__)
#         body['target_type'] = cls.generic_target_type + type_spec.suffix
#         body['reader_name'] = cls.generic_reader_name + type_spec.suffix
#         body['generic_params'] = [arg.full_name for arg in type_spec.generic_params]
#         class_ = type(cls.__name__, cls.__bases__, body)
#         return class_
# 
# class GenericValueTypeReader(GenericTypeReader):
#     is_value_type = True
# 
# class ReaderError(Error):
#     pass
# 
# Path: xnb_parse/xna_types/xna_system.py
# class XNAList(list):
#     __slots__ = ()
# 
#     def xml(self, parent=None, xml_tag='List', xml_entry='Entry', attrib=None):
#         if sys.version < '3':
#             conv = unicode
#         else:
#             conv = str
#         if parent is None:
#             root = ET.Element(xml_tag)
#         else:
#             root = ET.SubElement(parent, xml_tag)
#         for cur_value in self:
#             if hasattr(cur_value, 'xml'):
#                 cur_value.xml(root)
#             elif attrib is not None:
#                 cur_tag = ET.SubElement(root, xml_entry)
#                 cur_tag.set(attrib, conv(cur_value))
#             else:
#                 cur_tag = ET.SubElement(root, xml_entry)
#                 cur_tag.text = conv(cur_value)
#         return root
# 
# class XNADict(OrderedDict):
#     __slots__ = ()
# 
#     def xml(self, parent=None, xml_tag='Dict', xml_entry='Entry', attrib=None):
#         if sys.version < '3':
#             conv = unicode
#         else:
#             conv = str
#         if parent is None:
#             root = ET.Element(xml_tag)
#         else:
#             root = ET.SubElement(parent, xml_tag)
#         for cur_key, cur_value in self.items():
#             cur_tag = ET.SubElement(root, xml_entry)
#             if hasattr(cur_key, 'xml') and not isinstance(cur_key, Enum):
#                 cur_key.xml(cur_tag)
#             else:
#                 cur_tag.set('key', conv(cur_key))
#             if hasattr(cur_value, 'xml'):
#                 cur_value.xml(cur_tag)
#             elif attrib is not None:
#                 cur_tag.set(attrib, conv(cur_value))
#             else:
#                 cur_tag.text = conv(cur_value)
#         return root


from xnb_parse.type_reader import (TypeReaderPlugin, ValueTypeReader, GenericTypeReader, GenericValueTypeReader,
                                   ReaderError)
from xnb_parse.xna_types.xna_system import XNAList, XNADict
"""
system type readers
"""

from __future__ import print_function



class EnumReader(GenericValueTypeReader, TypeReaderPlugin):
    generic_target_type = 'System.Enum`1'
    generic_reader_name = 'Microsoft.Xna.Framework.Content.EnumReader`1'

    def init_reader(self, file_platform=None, file_version=None):
        GenericValueTypeReader.init_reader(self, file_platform, file_version)
        if not self.readers[0].is_enum_type:

# Path: xnb_parse/type_reader.py
# class TypeReaderPlugin(Plugin):
#     """
#     type reader plugins
#     """
# 
# class ValueTypeReader(BaseTypeReader):
#     is_value_type = True
# 
# class GenericTypeReader(BaseTypeReader):
#     generic_target_type = None
#     generic_reader_name = None
#     is_generic_type = True
#     generic_params = None
#     readers = None
# 
#     def init_reader(self, file_platform=None, file_version=None):
#         BaseTypeReader.init_reader(self, file_platform, file_version)
#         if self.readers is None:
#             self.readers = []
#         for arg in self.generic_params:
#             reader = self.stream.get_type_reader_by_type(arg)
#             reader.init_reader(file_platform, file_version)
#             self.readers.append(reader)
# 
#     @classmethod
#     def create_from_type(cls, type_spec):
#         # really need to figure out how to do this more cleanly
#         body = dict(cls.__dict__)
#         body['target_type'] = cls.generic_target_type + type_spec.suffix
#         body['reader_name'] = cls.generic_reader_name + type_spec.suffix
#         body['generic_params'] = [arg.full_name for arg in type_spec.generic_params]
#         class_ = type(cls.__name__, cls.__bases__, body)
#         return class_
# 
# class GenericValueTypeReader(GenericTypeReader):
#     is_value_type = True
# 
# class ReaderError(Error):
#     pass
# 
# Path: xnb_parse/xna_types/xna_system.py
# class XNAList(list):
#     __slots__ = ()
# 
#     def xml(self, parent=None, xml_tag='List', xml_entry='Entry', attrib=None):
#         if sys.version < '3':
#             conv = unicode
#         else:
#             conv = str
#         if parent is None:
#             root = ET.Element(xml_tag)
#         else:
#             root = ET.SubElement(parent, xml_tag)
#         for cur_value in self:
#             if hasattr(cur_value, 'xml'):
#                 cur_value.xml(root)
#             elif attrib is not None:
#                 cur_tag = ET.SubElement(root, xml_entry)
#                 cur_tag.set(attrib, conv(cur_value))
#             else:
#                 cur_tag = ET.SubElement(root, xml_entry)
#                 cur_tag.text = conv(cur_value)
#         return root
# 
# class XNADict(OrderedDict):
#     __slots__ = ()
# 
#     def xml(self, parent=None, xml_tag='Dict', xml_entry='Entry', attrib=None):
#         if sys.version < '3':
#             conv = unicode
#         else:
#             conv = str
#         if parent is None:
#             root = ET.Element(xml_tag)
#         else:
#             root = ET.SubElement(parent, xml_tag)
#         for cur_key, cur_value in self.items():
#             cur_tag = ET.SubElement(root, xml_entry)
#             if hasattr(cur_key, 'xml') and not isinstance(cur_key, Enum):
#                 cur_key.xml(cur_tag)
#             else:
#                 cur_tag.set('key', conv(cur_key))
#             if hasattr(cur_value, 'xml'):
#                 cur_value.xml(cur_tag)
#             elif attrib is not None:
#                 cur_tag.set(attrib, conv(cur_value))
#             else:
#                 cur_tag.text = conv(cur_value)
#         return root


# Path: xnb_parse/type_readers/xna_system.py
from xnb_parse.type_reader import (TypeReaderPlugin, ValueTypeReader, GenericTypeReader, GenericValueTypeReader,
                                   ReaderError)
from xnb_parse.xna_types.xna_system import XNAList, XNADict

"""
system type readers
"""

from __future__ import print_function



class EnumReader(GenericValueTypeReader, TypeReaderPlugin):
    generic_target_type = 'System.Enum`1'
    generic_reader_name = 'Microsoft.Xna.Framework.Content.EnumReader`1'

    def init_reader(self, file_platform=None, file_version=None):
        GenericValueTypeReader.init_reader(self, file_platform, file_version)
        if not self.readers[0].is_enum_type:

            ReaderError("Not enum type reader: '{}'".format(self.readers[0]))