<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> class Param ( object ) : <EOL> def __init__ ( self , name = "<STR_LIT>" , value = None , group = "<STR_LIT>" , help = "<STR_LIT>" , units = "<STR_LIT>" , ** kwargs ) : <EOL> self . name = name <EOL> self . value = value <EOL> self . group = group <EOL> self . help = help . strip ( ) <EOL> self . units = units <EOL> if ( len ( kwargs ) > <NUM_LIT:0> ) : <EOL> warnings . warn ( "<STR_LIT>" + "<STR_LIT:U+002CU+0020>" . join ( kwargs . keys ( ) ) ) <EOL> @ property <EOL> def key ( self ) : <EOL> "<STR_LIT>" <EOL> return ( self . group , self . name ) <EOL> def __eq__ ( self , other ) : <EOL> return self . key == other . key <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . group , self . name , self . value ) <EOL> class Params ( list ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args ) : <EOL> list . __init__ ( self , * args ) <EOL> for p in self : <EOL> if not isinstance ( p , Param ) : <EOL> print ( type ( p ) , "<STR_LIT::>" , p ) <EOL> raise TypeError ( "<STR_LIT>" . format ( type ( p ) ) ) <EOL> def append ( self , param ) : <EOL> if not isinstance ( param , Param ) : <EOL> raise TypeError ( "<STR_LIT>" . format ( type ( param ) ) ) <EOL> list . append ( self , param ) <EOL> def to_nml ( self ) : <EOL> return Namelist ( self ) <EOL> def to_json ( self , ** kwargs ) : <EOL> import json <EOL> return json . dumps ( [ vars ( p ) for p in self ] , ** kwargs ) <EOL> @ classmethod <EOL> def from_json ( cls , string ) : <EOL> import json <EOL> return cls ( [ Param ( ** p ) for p in json . loads ( string ) ] ) <EOL> parse = from_json <EOL> format = to_json <EOL> def write ( self , filename , mode = '<STR_LIT:w>' , ** kwargs ) : <EOL> with open ( filename , mode ) as f : <EOL> f . write ( self . format ( ** kwargs ) ) <EOL> @ classmethod <EOL> def read ( cls , filename ) : <EOL> with open ( filename ) as f : <EOL> params = cls . parse ( f . read ( ) ) <EOL> return params <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( cls = self . __class__ . __name__ , list = list . __repr__ ( self ) ) </s>
