<s> from copy import copy <EOL> import silk . utils . six as six <EOL> from silk . singleton import Singleton <EOL> def default_permissions ( user ) : <EOL> if user : <EOL> return user . is_staff <EOL> return False <EOL> class SilkyConfig ( six . with_metaclass ( Singleton , object ) ) : <EOL> defaults = { <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : default_permissions , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : False , <EOL> } <EOL> def _setup ( self ) : <EOL> from django . conf import settings <EOL> options = { option : getattr ( settings , option ) for option in dir ( settings ) if option . startswith ( '<STR_LIT>' ) } <EOL> self . attrs = copy ( self . defaults ) <EOL> self . attrs . update ( options ) <EOL> def __init__ ( self ) : <EOL> super ( SilkyConfig , self ) . __init__ ( ) <EOL> self . _setup ( ) <EOL> def __getattr__ ( self , item ) : <EOL> return self . attrs . get ( item , None ) <EOL> def __setattribute__ ( self , key , value ) : <EOL> self . attrs [ key ] = value </s>
