def load_site(srcdir, datadir, site_name=None):
if site_name is None:<EOL><INDENT>site_name = '<STR_LIT>'<EOL><DEDENT>if not validate.valid_name(site_name):<EOL><INDENT>raise DatacatsError('<STR_LIT>'.format(site_name))<EOL><DEDENT>cp = ConfigParser.SafeConfigParser()<EOL>try:<EOL><INDENT>cp.read([srcdir + '<STR_LIT>'])<EOL><DEDENT>except ConfigParser.Error:<EOL><INDENT>raise DatacatsError('<STR_LIT>')<EOL><DEDENT>site_section = '<STR_LIT>' + site_name<EOL>try:<EOL><INDENT>port = cp.getint(site_section, '<STR_LIT:port>')<EOL><DEDENT>except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):<EOL><INDENT>port = None<EOL><DEDENT>try:<EOL><INDENT>address = cp.get(site_section, '<STR_LIT:address>')<EOL><DEDENT>except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):<EOL><INDENT>address = None<EOL><DEDENT>try:<EOL><INDENT>site_url = cp.get(site_section, '<STR_LIT>')<EOL><DEDENT>except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):<EOL><INDENT>site_url = None<EOL><DEDENT>passwords = {}<EOL>cp = ConfigParser.SafeConfigParser()<EOL>cp.read(datadir + '<STR_LIT>' + site_name + '<STR_LIT>')<EOL>try:<EOL><INDENT>pw_options = cp.options('<STR_LIT>')<EOL><DEDENT>except ConfigParser.NoSectionError:<EOL><INDENT>pw_options = []<EOL><DEDENT>for n in pw_options:<EOL><INDENT>passwords[n.upper()] = cp.get('<STR_LIT>', n)<EOL><DEDENT>return port, address, site_url, passwords<EOL>
Load configuration values for a site.

Returns (port, address, site_url, passwords)