Next / Previous / Contents / TCC Help System / NM Tech homepage

29. AccessSummary.__extFilter(): Ignore certain files by extension

This method checks a PageGet to see if it refers to a file type that is not considered a page fetch, such as image or CSS files. See Section 24.5, “AccessSummary.IGNORED_EXTENSIONS: File extensions to be ignored”.

webstats.py
# - - -   A c c e s s S u m m a r y . _ _ e x t F i l t e r

    def __extFilter ( self, pageGet ):
        '''Filter out selected file extensions.

          [ pageGet is a PageGet instance ->
              if the file extension of pageGet.url is not
              found in self.IGNORED_EXTENSIONS ->
                return True
              else -> return False ]
        '''
        #-- 1 --
        # [ ext  :=  file extension from pageGet.url, lowercased ]
        front, back  =  os.path.splitext ( pageGet.url )
        ext  =  back.lower()

        #-- 2 --
        # [ if ext is in self.IGNORED_EXTENSIONS ->
        #     return False
        #   else -> return True ]
        return ext not in self.IGNORED_EXTENSIONS