def __init__(self, filename):
     self.set_file(filename)
     self.current_path = path.getcwd()
     self.dirstack = Stack()
     self.set_parser()
     self._start_methods = dict(catalog=self.start_catalog,
                                media=self.start_media,
                                directory=self.start_directory,
                                file=self.start_file)
     self._end_methods = dict(catalog=self.end_catalog,
                              media=self.end_media,
                              directory=self.end_directory)
        self.current_path = self.current_path.dirname()
        print

    def start_directory(self, attrs):
        dirname = attrs['name']
        #print 'starting directory', dirname
        self.dirstack.push(dirname)
        self.current_path = self.current_path / dirname
        self.current_path.mkdir()
        
        
    def end_directory(self):
        print 'ending directory', self.dirstack.top()
        self.dirstack.pop()
        self.current_path = self.current_path.dirname()
        print self.current_path
        
    def start_file(self, attrs):
        filename = attrs['name']
        file(self.current_path / filename, 'w')
        
if __name__ == '__main__':
    roname = 'ro-media-catalog.hcf'
    ro = GzipFile(roname)
    #data = ro.read()
    #p = parse_file(ro)
    here = path.getcwd()
    #ph = HCFParser(roname)
    p = HCFSplitter(roname)