def prep_entriesappend(self, file, handler, fileentry): """Overridden to process .cap files and modify extensions. This is called by the parent's prepare to append an entry to the list. Here, we check to see if there's a .cap file right before adding it.""" global extstrip if extstrip == None: extstrip = self.config.get("handlers.UMN.UMNDirHandler", "extstrip") if extstrip != 'none' and \ isinstance(handler, FileHandler): if extstrip == 'full' or \ (extstrip == 'nonencoded' and not fileentry.getencoding()): # If it's a file, has a MIME type, and we know about it.. fileentry.setname( pygopherd.fileext.extstrip(file, fileentry.getencodedmimetype() or fileentry.getmimetype())) capfilename = self.selectorbase + '/.cap/' + file try: capinfo = self.processLinkFile(capfilename, fileentry.getselector()) if len(capinfo) >= 1: # We handle one and only one entry. if capinfo[0].gettype() == 'X' or capinfo[0].gettype() == '-': return # Type X -- don't append. else: self.mergeentries(fileentry, capinfo[0]) except IOError: # Ignore no capfile situation pass DirHandler.prep_entriesappend(self, file, handler, fileentry)
def prep_entriesappend(self, file, handler, fileentry): """Overridden to process .cap files and modify extensions. This is called by the parent's prepare to append an entry to the list. Here, we check to see if there's a .cap file right before adding it.""" global extstrip if extstrip == None: extstrip = self.config.get("handlers.UMN.UMNDirHandler", "extstrip") if extstrip != 'none' and \ isinstance(handler, FileHandler): if extstrip == 'full' or \ (extstrip == 'nonencoded' and not fileentry.getencoding()): # If it's a file, has a MIME type, and we know about it.. fileentry.setname( pygopherd.fileext.extstrip( file, fileentry.getencodedmimetype() or fileentry.getmimetype())) capfilename = self.selectorbase + '/.cap/' + file try: capinfo = self.processLinkFile(capfilename, fileentry.getselector()) if len(capinfo) >= 1: # We handle one and only one entry. if capinfo[0].gettype() == 'X' or capinfo[0].gettype() == '-': return # Type X -- don't append. else: self.mergeentries(fileentry, capinfo[0]) except IOError: # Ignore no capfile situation pass DirHandler.prep_entriesappend(self, file, handler, fileentry)