<s> from django . conf import settings <EOL> def get_settings_value ( name ) : <EOL> """<STR_LIT>""" <EOL> return getattr ( settings , name , None ) <EOL> def parse_ports ( ports_text ) : <EOL> """<STR_LIT>""" <EOL> ports_set = set ( ) <EOL> for bit in ports_text . split ( '<STR_LIT:U+002C>' ) : <EOL> if '<STR_LIT:->' in bit : <EOL> low , high = bit . split ( '<STR_LIT:->' , <NUM_LIT:1> ) <EOL> ports_set = ports_set . union ( range ( int ( low ) , int ( high ) + <NUM_LIT:1> ) ) <EOL> else : <EOL> ports_set . add ( int ( bit ) ) <EOL> return sorted ( list ( ports_set ) ) <EOL> def import_class ( class_path ) : <EOL> from importlib import import_module <EOL> pieces = class_path . split ( '<STR_LIT:.>' ) <EOL> module = '<STR_LIT:.>' . join ( pieces [ : - <NUM_LIT:1> ] ) <EOL> cls = pieces [ - <NUM_LIT:1> ] <EOL> module = import_module ( module ) <EOL> return getattr ( module , cls ) <EOL> def make_server ( <EOL> server_class , handler_class , authorizer_class , host_port , <EOL> file_access_user = None , ** handler_options ) : <EOL> """<STR_LIT>""" <EOL> from . import compat <EOL> if isinstance ( handler_class , compat . string_type ) : <EOL> handler_class = import_class ( handler_class ) <EOL> if isinstance ( authorizer_class , compat . string_type ) : <EOL> authorizer_class = import_class ( authorizer_class ) <EOL> authorizer = authorizer_class ( file_access_user ) <EOL> handler = handler_class <EOL> for key , value in handler_options . items ( ) : <EOL> setattr ( handler , key , value ) <EOL> handler . authorizer = authorizer <EOL> return server_class ( host_port , handler ) </s>
