コード例 #1
0
ファイル: album.py プロジェクト: chrisrossi/edwin
    def __getitem__(self, fname):
        fpath = os.path.join(self.fspath, fname)
        if os.path.isfile(fpath):
            photo = Photo(fpath)
            photo.__name__ = fname
            photo.__parent__ = self
            return photo

        if os.path.isdir(fpath):
            album = Album(fpath)
            album.__name__ = fname
            album.__parent__ = self
            return album

        raise KeyError(fname)