import lxml.etree

class solr_date(object):
    pass


class SolrSchema(object):
    solr_data_types = {
        'solr.StrField':str,
        'solr.TextField':str,
        'solr.BoolField':bool,
        'solr.IntField':int,
        'solr.SortableIntField':int,
        'solr.LongField':long,
        'solr.SortableLongField':long,
        'solr.FloatField':float,
        'solr.SortableFloatField':float,
        'solr.DoubleField':float,
        'solr.SortableDoubleField':float,
        'solr.DateField':solr_date
        }

    def __init__(self, f):
        """initialize a schema object from a
        filename or file-like object."""
        self.fields = self.schema_parse(f)

    def schema_parse(self, f):
        schemadoc = lxml.etree.parse(f)

        field_types = {}
        for data_type, t in self.solr_data_types.items():
            for field_type in schemadoc.xpath("/schema/types/fieldType[@class='%s']/@name" % data_type):
                field_types[field_type] = t
        schema_fields = {}
        for field in schemadoc.xpath("/schema/fields/field"):
            schema_fields[field.attrib['name']] = field_types.get(field.attrib['type'], 'UNKNOWN')

        return schema_fields


s = SolrSchema("/Users/tow/dl/solr/apache-solr-1.3.0/example/solr/conf/schema.xml")

print s.fields

@@ -744,25 +744,24 @@
 ee.parse(f)%0A
-%0A
         fiel
@@ -992,138 +992,63 @@
     
-schema_fields = %7B%7D%0A        for field in schemadoc.xpath(%22/schema/fields/field%22):%0A            schema_fields%5Bfield.attrib%5B'name'%5D%5D =
+return dict((field.attrib%5B'name'%5D,%0A                    
  fie
@@ -1092,17 +1092,17 @@
 NKNOWN')
-%0A
+)
 %0A       
@@ -1106,127 +1106,70 @@
     
-return schema_fields%0A%0A%0As = SolrSchema(%22/Users/tow/dl/solr/apache-solr-1.3.0/example/solr/conf/schema.xml%22)%0A%0Aprint s.
+            for field in schemadoc.xpath(%22/schema/fields/
 field
-s
+%22))
 %0A

Tidy up schema manipulation some more