lib/folder.py
changeset 23 10841abbc01f
parent 14 4b5478da5850
child 26 81d6679d50d0
equal deleted inserted replaced
22:72696ca68c34 23:10841abbc01f
    33     if not count :
    33     if not count :
    34         return '.'
    34         return '.'
    35 
    35 
    36     return os.path.join(*(['..']*count))
    36     return os.path.join(*(['..']*count))
    37     
    37     
    38 def isImage (fname) :
       
    39     """
       
    40         Is the given filename likely to be an image file?
       
    41     """
       
    42 
       
    43     fname = fname.lower()
       
    44     base, ext = os.path.splitext(fname)
       
    45     ext = ext.lstrip('.')
       
    46 
       
    47     return ext in settings.IMAGE_EXTS
       
    48 
       
    49 class Folder (object) :
    38 class Folder (object) :
    50     def __init__ (self, name='.', parent=None) :
    39     def __init__ (self, name='.', parent=None) :
    51         # the directory name, no trailing /
    40         # the directory name, no trailing /
    52         self.name = name.rstrip(os.sep)
    41         self.name = name.rstrip(os.sep)
    53 
    42 
   137                 if f.index(next_filter) :   # recursion
   126                 if f.index(next_filter) :   # recursion
   138                     # if a subdir is alive, we are alive as well
   127                     # if a subdir is alive, we are alive as well
   139                     self.alive = True
   128                     self.alive = True
   140 
   129 
   141             # handle images
   130             # handle images
   142             elif os.path.isfile(fpath) and isImage(fname) :
   131             elif os.path.isfile(fpath) and utils.isImage(fname) :
   143                 index.debug("Found image %s", fname)
   132                 index.debug("Found image %s", fname)
   144                 self.images[fname] = image.Image(self, fname)
   133                 self.images[fname] = image.Image(self, fname)
   145 
   134 
   146             # ignore everything else
   135             # ignore everything else
   147             else :
   136             else :