# Path: pygopherd/handlers/base.py
# class VFS_Real:
# class BaseHandler:
#     def __init__(self, config, chain = None):
#     def iswritable(self, selector):
#     def unlink(self, selector):
#     def stat(self, selector):
#     def isdir(self, selector):
#     def isfile(self, selector):
#     def exists(self, selector):
#     def open(self, selector, *args, **kwargs):
#     def listdir(self, selector):
#     def getrootpath(self):
#     def getfspath(self, selector):
#     def copyto(self, name, fd):
#     def __init__(self, selector, searchrequest, protocol, config, statresult,
#                  vfs = None):
#     def isrequestforme(self):
#     def isrequestsecure(self):
#     def canhandlerequest(self):
#     def getentry(self):
#     def getfspath(self):
#     def getselector(self):
#     def gethandler(self):
#     def prepare(self):
#     def isdir(self):
#     def write(self, wfile):
#     def getdirlist(self):


import re, time, stat, unittest, os.path, struct, types, shelve, marshal
import zipfile
        import dbm
from io import StringIO
from pygopherd.handlers import base
        from pygopherd import testutil
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.handlers import HandlerMultiplexer
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from configparser import ConfigParser
        from pygopherd.handlers import HandlerMultiplexer
        assert not s.zs.isdir('/symlinktest.zip/subdir/linkedrel.txt')
        assert s.zs.isdir('/symlinktest.zip')

    def test_symlink_isfile(s):
        assert s.zs.isfile('/symlinktest.zip/real.txt')
        assert not s.zs.isfile('/symlinktest.zip')
        assert not s.zs.isfile('/symlinktest.zip/subdir')
        assert not s.zs.isfile('/symlinktest.zip/linktosubdir')
        assert s.zs.isfile('/symlinktest.zip/linktosubdir/linkedrel.txt')
        assert s.zs.isfile('/symlinktest.zip/linktosubdir/linked2.txt')
        assert s.zs.isfile('/symlinktest.zip/subdir/linktoself/linktosubdir2/real2.txt')
        assert not s.zs.isfile('/symlinktest.zip/subdir/linktoself/linktosubdir2/real.txt')
        
    def test_open(s):
        s.assertRaises(IOError, s.z.open, '/testdata.zip/pygopherd')
        s.assertRaises(IOError, s.z2.open, '/testdata2.zip/pygopherd')
        s.assertRaises(IOError, s.z2.open, '/testdata.zip/pygopherd')

        assert s.z.open("/testdata.zip/.abstract")

        s.assertEqual(s.z.open('/testdata.zip/testfile.txt').read(),
                       b'Test\n')
        shouldbe = b"Word1\nWord2\nWord3\n"
        s.assertEqual(s.z.open('/testdata.zip/pygopherd/pipetestdata').read(),
                       shouldbe)
        s.assertEqual(s.z2.open('/testdata2.zip/pygopherd/pipetestdata').read(),
                       shouldbe)
        
        
        

# Path: pygopherd/handlers/base.py
# class VFS_Real:
# class BaseHandler:
#     def __init__(self, config, chain = None):
#     def iswritable(self, selector):
#     def unlink(self, selector):
#     def stat(self, selector):
#     def isdir(self, selector):
#     def isfile(self, selector):
#     def exists(self, selector):
#     def open(self, selector, *args, **kwargs):
#     def listdir(self, selector):
#     def getrootpath(self):
#     def getfspath(self, selector):
#     def copyto(self, name, fd):
#     def __init__(self, selector, searchrequest, protocol, config, statresult,
#                  vfs = None):
#     def isrequestforme(self):
#     def isrequestsecure(self):
#     def canhandlerequest(self):
#     def getentry(self):
#     def getfspath(self):
#     def getselector(self):
#     def gethandler(self):
#     def prepare(self):
#     def isdir(self):
#     def write(self, wfile):
#     def getdirlist(self):


# Path: pygopherd/handlers/ZIP.py
import re, time, stat, unittest, os.path, struct, types, shelve, marshal
import zipfile
        import dbm
from io import StringIO
from pygopherd.handlers import base
        from pygopherd import testutil
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.handlers import HandlerMultiplexer
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from pygopherd.protocols.rfc1436 import GopherProtocol
        from configparser import ConfigParser
        from pygopherd.handlers import HandlerMultiplexer

        assert not s.zs.isdir('/symlinktest.zip/subdir/linkedrel.txt')
        assert s.zs.isdir('/symlinktest.zip')

    def test_symlink_isfile(s):
        assert s.zs.isfile('/symlinktest.zip/real.txt')
        assert not s.zs.isfile('/symlinktest.zip')
        assert not s.zs.isfile('/symlinktest.zip/subdir')
        assert not s.zs.isfile('/symlinktest.zip/linktosubdir')
        assert s.zs.isfile('/symlinktest.zip/linktosubdir/linkedrel.txt')
        assert s.zs.isfile('/symlinktest.zip/linktosubdir/linked2.txt')
        assert s.zs.isfile('/symlinktest.zip/subdir/linktoself/linktosubdir2/real2.txt')
        assert not s.zs.isfile('/symlinktest.zip/subdir/linktoself/linktosubdir2/real.txt')
        
    def test_open(s):
        s.assertRaises(IOError, s.z.open, '/testdata.zip/pygopherd')
        s.assertRaises(IOError, s.z2.open, '/testdata2.zip/pygopherd')
        s.assertRaises(IOError, s.z2.open, '/testdata.zip/pygopherd')

        assert s.z.open("/testdata.zip/.abstract")

        s.assertEqual(s.z.open('/testdata.zip/testfile.txt').read(),
                       b'Test\n')
        shouldbe = b"Word1\nWord2\nWord3\n"
        s.assertEqual(s.z.open('/testdata.zip/pygopherd/pipetestdata').read(),
                       shouldbe)
        s.assertEqual(s.z2.open('/testdata2.zip/pygopherd/pipetestdata').read(),
                       shouldbe)
        
        
        

class ZIPHandler(base.BaseHandler):