#NEWLINE# def normalize_reference( bookname , chapter , verse = None , end_chapter = None , end_verse = None ) : #NEWLINE# #INDENT# '\n    Get a complete five value tuple scripture reference with full book name\n    from partial data\n    ' #NEWLINE# book = get_book ( bookname ) #NEWLINE# if ( ( chapter is not None ) and ( verse is None ) and ( end_chapter is None ) ) : #NEWLINE# #INDENT# if ( len ( book [ 3 ] ) == 1 ) : #NEWLINE# #INDENT# verse = chapter #NEWLINE# chapter = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if end_verse : #NEWLINE# #INDENT# verse = 1 #NEWLINE# end_chapter = end_verse #NEWLINE# end_verse = None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( chapter is not None ) and ( verse is None ) and ( end_chapter is not None ) ) : #NEWLINE# #INDENT# verse = 1 #NEWLINE# #UNINDENT# #UNINDENT# chapter = ( int ( chapter ) if chapter else None ) #NEWLINE# verse = ( int ( verse ) if verse else None ) #NEWLINE# end_chapter = ( int ( end_chapter ) if end_chapter else chapter ) #NEWLINE# end_verse = ( int ( end_verse ) if end_verse else None ) #NEWLINE# if ( ( not chapter ) or ( ( chapter is None ) or ( chapter < 1 ) or ( chapter > len ( book [ 3 ] ) ) ) or ( ( verse is not None ) and ( ( verse < 1 ) or ( verse > book [ 3 ] [ ( chapter - 1 ) ] ) ) ) or ( ( end_chapter is not None ) and ( ( end_chapter < 1 ) or ( end_chapter < chapter ) or ( end_chapter > len ( book [ 3 ] ) ) ) ) or ( ( end_verse is not None ) and ( ( end_verse < 1 ) or ( end_chapter and ( end_verse > book [ 3 ] [ ( end_chapter - 1 ) ] ) ) or ( ( chapter == end_chapter ) and ( end_verse < verse ) ) ) ) ) : #NEWLINE# #INDENT# raise InvalidReferenceException ( ) #NEWLINE# #UNINDENT# if ( not verse ) : #NEWLINE# #INDENT# return ( book [ 0 ] , chapter , 1 , chapter , book [ 3 ] [ ( chapter - 1 ) ] ) #NEWLINE# #UNINDENT# if ( not end_verse ) : #NEWLINE# #INDENT# if ( end_chapter and ( end_chapter != chapter ) ) : #NEWLINE# #INDENT# end_verse = book [ 3 ] [ ( end_chapter - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# end_verse = verse #NEWLINE# #UNINDENT# #UNINDENT# if ( not end_chapter ) : #NEWLINE# #INDENT# end_chapter = chapter #NEWLINE# #UNINDENT# return ( book [ 0 ] , chapter , verse , end_chapter , end_verse )