# Path: pygopherd/initialization.py
# def initconffile(conffile):
# def initlogger(config, conffile):
# def initexceptions(config):
# def initmimetypes(config):
#     def handle(self):
# def getserverobject(config):
#         def server_bind(self):
# def initsecurity(config):
# def initconditionaldetach(config):
# def initpidfile(config):
# def initpgrp(config):
# def initsighandlers(config, pgrp):
# def initeverything(conffile):
# class GopherRequestHandler(socketserver.StreamRequestHandler):
#     class MyServer(servertype):
# 
# Path: pygopherd/logger.py
# def log_file(message):
# def setlogfile(file):
# def log_syslog(message):
# def log_none(message):
# def init(config):


from pygopherd import initialization, logger
from pygopherd.protocols import ProtocolMultiplexer
from io import StringIO
import os
    config.set('logger', 'logmethod', 'file')
    logger.init(config)
    stringfile = StringIO()
    logger.setlogfile(stringfile)
    return stringfile

def gettestingserver(config = None):
    config = config or getconfig()
    config.set('pygopherd', 'port', '64777')
    s = initialization.getserverobject(config)
    s.server_close()
    return s

def gettestinghandler(rfile, wfile, config = None):
    """Creates a testing handler with input from rfile.  Fills in
    other stuff with fake values."""

    config = config or getconfig()

    # Kludge to pass to the handler init.
    
    class requestClass:
        def __init__(self, rfile, wfile):
            self.rfile = rfile
            self.wfile = wfile
        def makefile(self, mode, bufsize):
            if mode[0] == 'r':
                return self.rfile
            return self.wfile


# Path: pygopherd/initialization.py
# def initconffile(conffile):
# def initlogger(config, conffile):
# def initexceptions(config):
# def initmimetypes(config):
#     def handle(self):
# def getserverobject(config):
#         def server_bind(self):
# def initsecurity(config):
# def initconditionaldetach(config):
# def initpidfile(config):
# def initpgrp(config):
# def initsighandlers(config, pgrp):
# def initeverything(conffile):
# class GopherRequestHandler(socketserver.StreamRequestHandler):
#     class MyServer(servertype):
# 
# Path: pygopherd/logger.py
# def log_file(message):
# def setlogfile(file):
# def log_syslog(message):
# def log_none(message):
# def init(config):


# Path: pygopherd/testutil.py
from pygopherd import initialization, logger
from pygopherd.protocols import ProtocolMultiplexer
from io import StringIO
import os

    config.set('logger', 'logmethod', 'file')
    logger.init(config)
    stringfile = StringIO()
    logger.setlogfile(stringfile)
    return stringfile

def gettestingserver(config = None):
    config = config or getconfig()
    config.set('pygopherd', 'port', '64777')
    s = initialization.getserverobject(config)
    s.server_close()
    return s

def gettestinghandler(rfile, wfile, config = None):
    """Creates a testing handler with input from rfile.  Fills in
    other stuff with fake values."""

    config = config or getconfig()

    # Kludge to pass to the handler init.
    
    class requestClass:
        def __init__(self, rfile, wfile):
            self.rfile = rfile
            self.wfile = wfile
        def makefile(self, mode, bufsize):
            if mode[0] == 'r':
                return self.rfile
            return self.wfile


    class handlerClass(initialization.GopherRequestHandler):