#NEWLINE# def get_diff_options( req ) : #NEWLINE# #INDENT# 'Retrieve user preferences for diffs.\n\n    :return: ``(style, options, data)`` triple.\n\n      ``style``\n        can be ``\'inline\'`` or ``\'sidebyside\'``,\n      ``options``\n        a sequence of "diff" flags,\n      ``data``\n        the style and options information represented as\n        key/value pairs in dictionaries, for example::\n\n          {\'style\': u\'sidebyside\',\n           \'options\': {\'contextall\': 1, \'contextlines\': 2,\n                       \'ignorecase\': 0,  \'ignoreblanklines\': 0,\n                       \'ignorewhitespace\': 1}}\n\n    ' #NEWLINE# options_data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# data = { #NEWLINE# #INDENT# 'options' : options_data , #NEWLINE# #UNINDENT# } #NEWLINE# def get_bool_option( name , default = 0 ) : #NEWLINE# #INDENT# pref = req . session . as_int ( ( 'diff_' + name ) , default ) #NEWLINE# arg = int ( ( name in req . args ) ) #NEWLINE# if ( ( 'update' in req . args ) and ( arg != pref ) ) : #NEWLINE# #INDENT# req . session . set ( ( 'diff_' + name ) , arg , default ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arg = pref #NEWLINE# #UNINDENT# return arg #NEWLINE# #UNINDENT# pref = req . session . get ( 'diff_style' , 'inline' ) #NEWLINE# style = req . args . get ( 'style' , pref ) #NEWLINE# if ( ( 'update' in req . args ) and ( style != pref ) ) : #NEWLINE# #INDENT# req . session . set ( 'diff_style' , style , 'inline' ) #NEWLINE# #UNINDENT# data [ 'style' ] = style #NEWLINE# pref = req . session . as_int ( 'diff_contextlines' , 2 ) #NEWLINE# context = req . args . as_int ( 'contextlines' , pref ) #NEWLINE# if ( ( 'update' in req . args ) and ( context != pref ) ) : #NEWLINE# #INDENT# req . session . set ( 'diff_contextlines' , context , 2 ) #NEWLINE# #UNINDENT# options_data [ 'contextlines' ] = context #NEWLINE# arg = req . args . as_int ( 'contextall' , 0 ) #NEWLINE# options_data [ 'contextall' ] = arg #NEWLINE# options = [ ( '-U%d' % ( ( - 1 ) if arg else context ) ) ] #NEWLINE# arg = get_bool_option ( 'ignoreblanklines' ) #NEWLINE# if arg : #NEWLINE# #INDENT# options . append ( '-B' ) #NEWLINE# #UNINDENT# options_data [ 'ignoreblanklines' ] = arg #NEWLINE# arg = get_bool_option ( 'ignorecase' ) #NEWLINE# if arg : #NEWLINE# #INDENT# options . append ( '-i' ) #NEWLINE# #UNINDENT# options_data [ 'ignorecase' ] = arg #NEWLINE# arg = get_bool_option ( 'ignorewhitespace' ) #NEWLINE# if arg : #NEWLINE# #INDENT# options . append ( '-b' ) #NEWLINE# #UNINDENT# options_data [ 'ignorewhitespace' ] = req #NEWLINE# return ( style , options , data )