#NEWLINE# def quote_id( name ) : #NEWLINE# #INDENT# 'Quotes an identifier if necessary.\n\n    :param name: string to be quoted\n\n    :return: possibly quoted string\n    ' #NEWLINE# regular_id = True #NEWLINE# if ( ( not ( name [ 0 ] in VALID_FIRST_CHARS ) ) or ( name in RESERVED_WORDS ) ) : #NEWLINE# #INDENT# regular_id = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for ltr in name [ 1 : ] : #NEWLINE# #INDENT# if ( ltr not in VALID_CHARS ) : #NEWLINE# #INDENT# regular_id = False #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( ( regular_id and name ) or ( '"%s"' % name ) )