<s> '''<STR_LIT>''' <EOL> import os <EOL> from util import * <EOL> from collections import deque <EOL> class SolrFieldType ( BaseSolrXMLElement ) : <EOL> tag = "<STR_LIT>" <EOL> required = { '<STR_LIT>' : '<STR_LIT:class>' , <EOL> '<STR_LIT>' : '<STR_LIT:name>' } <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> class String ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT:string>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> class UniqueId ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> class Boolean ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> class Date ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT:date>' <EOL> class Random ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> class Integer ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT:int>' <EOL> omit_norms = True <EOL> class Long ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> class Float ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT:float>' <EOL> omit_norms = True <EOL> class Double ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> class SortableInteger ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> class SortableLong ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> class SortableDouble ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> class SortableFloat ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> """<STR_LIT>""" <EOL> class Tokenizer ( BaseSolrXMLElement ) : <EOL> solr_class = None <EOL> tag = "<STR_LIT>" <EOL> required = { '<STR_LIT>' : '<STR_LIT:class>' } <EOL> class WhitespaceTokenizer ( Tokenizer ) : <EOL> solr_class = '<STR_LIT>' <EOL> class StandardTokenizer ( Tokenizer ) : <EOL> solr_class = '<STR_LIT>' <EOL> class KeywordTokenizer ( Tokenizer ) : <EOL> solr_class = '<STR_LIT>' <EOL> class LetterTokenizer ( Tokenizer ) : <EOL> solr_class = '<STR_LIT>' <EOL> class HTMLStripWhitespaceTokenizer ( Tokenizer ) : <EOL> solr_class = '<STR_LIT>' <EOL> class HTMLStripStandardTokenizer ( Tokenizer ) : <EOL> solr_class = '<STR_LIT>' <EOL> class PatternTokenizer ( Tokenizer ) : <EOL> """<STR_LIT>""" <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> """<STR_LIT>""" <EOL> class Filter ( BaseSolrXMLElement ) : <EOL> solr_class = None <EOL> tag = "<STR_LIT>" <EOL> options = [ ] <EOL> required = { '<STR_LIT>' : '<STR_LIT:class>' } <EOL> class LowerCaseFilter ( Filter ) : <EOL> solr_class = "<STR_LIT>" <EOL> class StandardFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> class TrimFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' ] <EOL> class LengthFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class RemoveDuplicatesFilter ( Filter ) : <EOL> """<STR_LIT>""" <EOL> solr_class = '<STR_LIT>' <EOL> class ISOLatin1AccentFilter ( Filter ) : <EOL> """<STR_LIT>""" <EOL> solr_class = '<STR_LIT>' <EOL> class CapitalizationFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> class PatternReplaceFilter ( Filter ) : <EOL> """<STR_LIT>""" <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:replace>' ] <EOL> """<STR_LIT>""" <EOL> class MappingCharFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> class PatternReplaceCharFilter ( Filter ) : <EOL> """<STR_LIT>""" <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:replace>' ] <EOL> class HTMLStripCharFilter ( Filter ) : <EOL> """<STR_LIT>""" <EOL> solr_class = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> class WordDelimiterFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> class EnglishPorterFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' ] <EOL> class SnowballPorterFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' ] <EOL> class SynonymFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class StopFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> """<STR_LIT>""" <EOL> class DoubleMetaphoneFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class PhoneticFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class MetaphoneFilter ( PhoneticFilter ) : <EOL> encoder = '<STR_LIT>' <EOL> class SoundexFilter ( PhoneticFilter ) : <EOL> encoder = '<STR_LIT>' <EOL> class RefinedSoundexFilter ( PhoneticFilter ) : <EOL> encoder = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> class NGramFilter ( Filter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> min_gram_size = <NUM_LIT:2> <EOL> max_gram_size = <NUM_LIT:15> <EOL> class EdgeNGramFilter ( NGramFilter ) : <EOL> solr_class = '<STR_LIT>' <EOL> options = NGramFilter . options + [ '<STR_LIT>' ] <EOL> """<STR_LIT>""" <EOL> class Analyzer ( BaseSolrXMLElement ) : <EOL> INDEX = '<STR_LIT:index>' <EOL> QUERY = '<STR_LIT>' <EOL> tag = '<STR_LIT>' <EOL> options = [ '<STR_LIT:type>' ] <EOL> tokenizer = WhitespaceTokenizer <EOL> filters = ( ) <EOL> """<STR_LIT>""" <EOL> class BaseText ( SolrFieldType ) : <EOL> solr_class = '<STR_LIT>' <EOL> position_increment_gap = <NUM_LIT:100> <EOL> class SimpleTokenizedText ( BaseText ) : <EOL> type_name = '<STR_LIT>' <EOL> anaylzer = Analyzer ( tokenizer = WhitespaceTokenizer ) <EOL> class Text ( BaseText ) : <EOL> type_name = '<STR_LIT:text>' <EOL> index_analyzer = Analyzer ( type = Analyzer . INDEX , <EOL> tokenizer = WhitespaceTokenizer , <EOL> filters = ( StopFilter ( ignore_case = True , words = '<STR_LIT>' , enable_position_increments = True ) , <EOL> WordDelimiterFilter ( generate_word_parts = <NUM_LIT:1> , generate_number_parts = <NUM_LIT:1> , catenate_words = <NUM_LIT:1> , <EOL> catenate_numbers = <NUM_LIT:1> , catenate_all = <NUM_LIT:0> , split_on_case_change = <NUM_LIT:1> ) , <EOL> LowerCaseFilter , <EOL> ISOLatin1AccentFilter , <EOL> EnglishPorterFilter ( protected = '<STR_LIT>' ) , <EOL> RemoveDuplicatesFilter <EOL> ) <EOL> ) <EOL> query_analyzer = Analyzer ( type = Analyzer . QUERY , <EOL> tokenizer = WhitespaceTokenizer , <EOL> filters = ( SynonymFilter ( synonyms = '<STR_LIT>' , ignore_case = True , expand = True ) , <EOL> StopFilter ( ignore_case = True , words = '<STR_LIT>' ) , <EOL> WordDelimiterFilter ( generate_word_parts = <NUM_LIT:1> , generate_number_parts = <NUM_LIT:1> , catenate_words = <NUM_LIT:1> , <EOL> catenate_numbers = <NUM_LIT:0> , catenate_all = <NUM_LIT:0> , split_on_case_change = <NUM_LIT:1> ) , <EOL> LowerCaseFilter , <EOL> ISOLatin1AccentFilter , <EOL> EnglishPorterFilter ( protected = '<STR_LIT>' ) , <EOL> RemoveDuplicatesFilter <EOL> ) <EOL> ) <EOL> class TextTight ( BaseText ) : <EOL> type_name = '<STR_LIT>' <EOL> analyzer = Analyzer ( tokenizer = WhitespaceTokenizer , <EOL> filters = ( SynonymFilter ( synonyms = '<STR_LIT>' , ignore_case = True , expand = False ) , <EOL> StopFilter ( ignore_case = True , words = '<STR_LIT>' ) , <EOL> WordDelimiterFilter ( generate_word_parts = <NUM_LIT:0> , generate_number_parts = <NUM_LIT:0> , catenate_words = <NUM_LIT:1> , catenate_numbers = <NUM_LIT:1> , catenate_all = <NUM_LIT:0> ) , <EOL> LowerCaseFilter , <EOL> EnglishPorterFilter ( protected = '<STR_LIT>' ) , <EOL> RemoveDuplicatesFilter <EOL> ) <EOL> ) <EOL> class Title ( BaseText ) : <EOL> type_name = '<STR_LIT:title>' <EOL> analyzer = Analyzer ( tokenizer = WhitespaceTokenizer , <EOL> filters = ( StopFilter ( ignore_case = True , words = '<STR_LIT>' ) , <EOL> WordDelimiterFilter ( generate_word_parts = <NUM_LIT:0> , generate_number_parts = <NUM_LIT:0> , catenate_words = <NUM_LIT:1> , catenate_numbers = <NUM_LIT:1> , catenate_all = <NUM_LIT:0> ) , <EOL> LowerCaseFilter , <EOL> ISOLatin1AccentFilter , <EOL> RemoveDuplicatesFilter <EOL> ) <EOL> ) <EOL> class TextSpell ( BaseText ) : <EOL> type_name = '<STR_LIT>' <EOL> stored = False <EOL> multi_valued = True <EOL> index_analyzer = Analyzer ( type = Analyzer . INDEX , <EOL> tokenizer = StandardTokenizer , <EOL> filters = ( LowerCaseFilter , <EOL> SynonymFilter ( synonyms = '<STR_LIT>' , ignore_case = True , expand = True ) , <EOL> StopFilter ( ignore_case = True , words = '<STR_LIT>' ) , <EOL> StandardFilter , <EOL> RemoveDuplicatesFilter <EOL> ) <EOL> ) <EOL> query_analyzer = Analyzer ( type = Analyzer . QUERY , <EOL> tokenizer = StandardTokenizer , <EOL> filters = ( LowerCaseFilter , <EOL> StopFilter ( ignore_case = True , words = '<STR_LIT>' ) , <EOL> StandardFilter , <EOL> RemoveDuplicatesFilter <EOL> ) <EOL> ) <EOL> class TextSpellPhrase ( BaseText ) : <EOL> type_name = '<STR_LIT>' <EOL> analyzer = Analyzer ( tokenizer = KeywordTokenizer , <EOL> filters = ( LowerCaseFilter , <EOL> ) <EOL> ) <EOL> class AlphaOnlySort ( BaseText ) : <EOL> type_name = '<STR_LIT>' <EOL> omit_norms = True <EOL> sort_missing_last = True <EOL> analyzer = Analyzer ( tokenizer = KeywordTokenizer , <EOL> filters = ( LowerCaseFilter , <EOL> TrimFilter , <EOL> PatternReplaceFilter ( pattern = '<STR_LIT>' , replacement = '<STR_LIT>' , replace = '<STR_LIT:all>' ) <EOL> ) <EOL> ) <EOL> class Ignored ( SolrFieldType ) : <EOL> type_name = '<STR_LIT>' <EOL> solr_class = '<STR_LIT>' <EOL> indexed = False <EOL> stored = False <EOL> class SolrFieldTypes ( BaseSolrXMLElement ) : <EOL> tag = '<STR_LIT>' <EOL> types = ( String , Boolean , UniqueId , <EOL> Integer , Long , Float , Double , <EOL> SortableInteger , SortableLong , <EOL> SortableFloat , SortableDouble , <EOL> Date , Random , SimpleTokenizedText , <EOL> Text , TextTight , Title , TextSpell , <EOL> TextSpellPhrase , AlphaOnlySort , Ignored ) <EOL> def __init__ ( self , * args ) : <EOL> self . types = tuple ( args ) <EOL> class SolrSchemaField ( BaseSolrXMLElement ) : <EOL> tag = '<STR_LIT>' <EOL> required = dict ( [ ( attr , attr ) <EOL> for attr in [ '<STR_LIT:name>' , '<STR_LIT:type>' ] ] ) <EOL> options = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> def __init__ ( self , name , type ) : <EOL> super ( SolrSchemaField , self ) . __init__ ( name = name , type = type . type_name ) <EOL> class SolrSchemaFields ( BaseSolrXMLElement ) : <EOL> tag = '<STR_LIT>' <EOL> fields = ( ) <EOL> dependency = SolrFieldTypes <EOL> def __init__ ( self , * args ) : <EOL> super ( SolrSchemaFields , self ) . __init__ ( fields = args ) <EOL> class UniqueKey ( BaseSolrXMLElement ) : <EOL> tag = '<STR_LIT>' <EOL> dependency = SolrSchemaFields <EOL> value = None <EOL> def __init__ ( self , name = None ) : <EOL> self . value = name <EOL> class SolrSchema ( BaseSolrXMLElement ) : <EOL> tag = '<STR_LIT>' <EOL> required = dict ( [ ( attr , attr ) <EOL> for attr in [ '<STR_LIT:name>' , '<STR_LIT:version>' ] ] ) <EOL> def __init__ ( self , name , version = '<STR_LIT>' , <EOL> field_types = SolrFieldTypes ( ) , <EOL> fields = SolrSchemaFields ( ) , ** kw ) : <EOL> self . name = name <EOL> self . version = version <EOL> self . field_types = field_types <EOL> self . names_to_fields = dict ( [ ( field_type . type_name , field_type ) <EOL> for field_type in field_types . types ] ) <EOL> self . fields = fields <EOL> super ( SolrSchema , self ) . __init__ ( ** kw ) <EOL> def generate_schema ( schema , path = '<STR_LIT>' ) : <EOL> ensure_dir ( os . path . dirname ( path ) ) <EOL> tree = etree . ElementTree ( schema . to_xml ( ) ) <EOL> tree . write ( path , encoding = '<STR_LIT:utf-8>' , xml_declaration = True , pretty_print = True ) </s>
