#NEWLINE# def main( ) : #NEWLINE# #INDENT# init_app ( set_backends = True , routes = False ) #NEWLINE# CitationStyle . remove ( ) #NEWLINE# total = 0 #NEWLINE# for style_file in get_style_files ( settings . CITATION_STYLES_PATH ) : #NEWLINE# #INDENT# with open ( root , 'r' ) as f : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# root = etree . parse ( f ) . getroot ( ) #NEWLINE# #UNINDENT# except etree . XMLSyntaxError : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# total += 1 #NEWLINE# namespace = root . nsmap . get ( None ) #NEWLINE# selector = '{{{ns}}}info/{{{ns}}}' . format ( ns = namespace ) #NEWLINE# fields = { #NEWLINE# #INDENT# '_id' : os . path . splitext ( os . path . basename ( style_file ) ) [ 0 ] , #NEWLINE# 'title' : root . find ( ( selector + 'title' ) ) . text , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# fields [ 'short_title' ] = root . find ( ( selector + 'title-short' ) ) . text #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# fields [ 'summary' ] = root . find ( ( selector + 'summary' ) ) . text #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# style = CitationStyle ( ** fields ) #NEWLINE# style . save ( ) #NEWLINE# #UNINDENT# #UNINDENT# return total