def makeTextNotes(replaceTxtNotes):
 def _replacer(s):
  outS = replaceTxtNotes
  if (not isinstance(s, (unicode, str))):
   return s
  ssplit = s.split('::', 1)
  text = ssplit[0]
  keysDict = {}
  if text:
   keysDict['text'] = True
  outS = outS.replace('%(text)s', text)
  if (len(ssplit) == 2):
   keysDict['notes'] = True
   outS = outS.replace('%(notes)s', ssplit[1])
  else:
   outS = outS.replace('%(notes)s', u'')
  def _excludeFalseConditionals(matchobj):
   if (matchobj.group(1) in keysDict):
    return matchobj.group(2)
   return u''
  while re_conditional.search(outS):
   outS = re_conditional.sub(_excludeFalseConditionals, outS)
  return outS
 return _replacer

def makeTextNotes ( replaceTxtNotes ) : def _replacer ( s ) : outS = replaceTxtNotes if ( not isinstance ( s , ( unicode , str ) ) ) : return s ssplit = s . split ( '::' , 1 ) text = ssplit [ 0 ] keysDict = { } if text : keysDict [ 'text' ] = True outS = outS . replace ( '%(text)s' , text ) if ( len ( ssplit ) == 2 ) : keysDict [ 'notes' ] = True outS = outS . replace ( '%(notes)s' , ssplit [ 1 ] ) else : outS = outS . replace ( '%(notes)s' , u'' ) def _excludeFalseConditionals ( matchobj ) : if ( matchobj . group ( 1 ) in keysDict ) : return matchobj . group ( 2 ) return u'' while re_conditional . search ( outS ) : outS = re_conditional . sub ( _excludeFalseConditionals , outS ) return outS return _replacer
create a function useful to handle text[::optional_note] values .