<s> import re <EOL> from vint . ast . node_type import NodeType <EOL> from vint . linting . level import Level <EOL> from vint . linting . policy . abstract_policy import AbstractPolicy <EOL> from vint . linting . policy_registry import register_policy <EOL> from vint . ast . dictionary . abbreviations import ( <EOL> Abbreviations , <EOL> AbbreviationsIncludingInvertPrefix , <EOL> ) <EOL> SetCommandFamily = { <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> @ register_policy <EOL> class ProhibitAbbreviationOption ( AbstractPolicy ) : <EOL> def __init__ ( self ) : <EOL> super ( ProhibitAbbreviationOption , self ) . __init__ ( ) <EOL> self . description = '<STR_LIT>' <EOL> self . reference = '<STR_LIT>' <EOL> self . level = Level . STYLE_PROBLEM <EOL> self . was_scriptencoding_found = False <EOL> self . has_encoding_opt_after_scriptencoding = False <EOL> def listen_node_types ( self ) : <EOL> return [ NodeType . EXCMD , NodeType . OPTION ] <EOL> def is_valid ( self , node , lint_context ) : <EOL> """<STR_LIT>""" <EOL> node_type = NodeType ( node [ '<STR_LIT:type>' ] ) <EOL> if node_type is NodeType . OPTION : <EOL> option_name = node [ '<STR_LIT:value>' ] [ <NUM_LIT:1> : ] <EOL> is_valid = option_name not in Abbreviations <EOL> if not is_valid : <EOL> self . _make_description_by_option_name ( option_name ) <EOL> return is_valid <EOL> excmd_node = node <EOL> is_set_cmd = excmd_node [ '<STR_LIT>' ] [ '<STR_LIT>' ] . get ( '<STR_LIT:name>' ) in SetCommandFamily <EOL> if not is_set_cmd : <EOL> return True <EOL> option_expr = excmd_node [ '<STR_LIT:str>' ] . split ( ) [ <NUM_LIT:1> ] <EOL> option_name = re . match ( r'<STR_LIT>' , option_expr ) . group ( <NUM_LIT:0> ) <EOL> is_valid = option_name not in AbbreviationsIncludingInvertPrefix <EOL> if not is_valid : <EOL> self . _make_description_by_option_name ( option_name ) <EOL> return is_valid <EOL> def _make_description_by_option_name ( self , option_name ) : <EOL> param = { <EOL> '<STR_LIT>' : AbbreviationsIncludingInvertPrefix [ option_name ] , <EOL> '<STR_LIT>' : option_name , <EOL> } <EOL> self . description = ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( ** param ) ) </s>
