<s> import string <EOL> import sublime <EOL> import sublime_plugin <EOL> class Transformer ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> self . transform ( self . transformer [ <NUM_LIT:0> ] , self . view , edit ) <EOL> def transform ( self , f , view , edit ) : <EOL> for s in view . sel ( ) : <EOL> if s . empty ( ) : <EOL> s = view . word ( s ) <EOL> txt = f ( view . substr ( s ) ) <EOL> view . replace ( edit , s , txt ) <EOL> class SwapCaseCommand ( Transformer ) : <EOL> transformer = string . swapcase , <EOL> class UpperCaseCommand ( Transformer ) : <EOL> transformer = string . upper , <EOL> class LowerCaseCommand ( Transformer ) : <EOL> transformer = string . lower , <EOL> class TitleCaseCommand ( Transformer ) : <EOL> transformer = lambda s : string . capwords ( s , "<STR_LIT:U+0020>" ) , <EOL> def rot13 ( ch ) : <EOL> o = ord ( ch ) <EOL> if o >= ord ( '<STR_LIT:a>' ) and o <= ord ( '<STR_LIT:z>' ) : <EOL> return unichr ( ( o - ord ( '<STR_LIT:a>' ) + <NUM_LIT> ) % <NUM_LIT> + ord ( '<STR_LIT:a>' ) ) <EOL> if o >= ord ( '<STR_LIT:A>' ) and o <= ord ( '<STR_LIT>' ) : <EOL> return unichr ( ( o - ord ( '<STR_LIT:A>' ) + <NUM_LIT> ) % <NUM_LIT> + ord ( '<STR_LIT:A>' ) ) <EOL> return ch <EOL> class Rot13Command ( Transformer ) : <EOL> transformer = lambda s : "<STR_LIT>" . join ( [ rot13 ( ch ) for ch in s ] ) , </s>
