def getMemberList(self): """Return list of (direct) collection member names (UTF-8 byte strings). See DAVResource.getMemberList() """ members = [] conn = self.provider._initConnection() try: tableName, primKey = self.provider._splitPath(self.path) if tableName is None: retlist = self.provider._listTables(conn) for name in retlist: members.append( MySQLBrowserResource(self.provider, util.joinUri(self.path, name), True, self.environ)) elif primKey is None: pri_key = self.provider._findPrimaryKey(conn, tableName) if pri_key is not None: retlist = self.provider._listFields( conn, tableName, pri_key) for name in retlist: members.append( MySQLBrowserResource(self.provider, util.joinUri(self.path, name), False, self.environ)) members.insert( 0, MySQLBrowserResource( self.provider, util.joinUri(self.path, "_ENTIRE_CONTENTS"), False, self.environ)) finally: conn.close() return members
def getMemberList(self): """Return list of (direct) collection member names (UTF-8 byte strings). See DAVResource.getMemberList() """ members = [] conn = self.provider._initConnection() try: tableName, primKey = self.provider._splitPath(self.path) if tableName is None: retlist = self.provider._listTables(conn) for name in retlist: members.append(MySQLBrowserResource(self.provider, util.joinUri(self.path, name), True, self.environ)) elif primKey is None: pri_key = self.provider._findPrimaryKey(conn, tableName) if pri_key is not None: retlist = self.provider._listFields(conn, tableName, pri_key) for name in retlist: members.append(MySQLBrowserResource(self.provider, util.joinUri(self.path, name), False, self.environ)) members.insert(0, MySQLBrowserResource(self.provider, util.joinUri(self.path, "_ENTIRE_CONTENTS"), False, self.environ)) finally: conn.close() return members
def getMember(self, name): if name in self._artifactNames: return VirtualArtifact(joinUri(self.path, name), self.environ, self.data) for filePath in self.data["resPathList"]: fname = os.path.basename(filePath) if fname == name: return VirtualResFile(joinUri(self.path, name), self.environ, self.data, filePath) return None
def getMember(self, name): if self.name == "by_key": data = _getResByKey(name) if data: return VirtualResource(joinUri(self.path, name), self.environ, data) else: return None return CategoryCollection(joinUri(self.path, name), self.environ, self.name)
def getMember(self, name): # Handle visible categories and also /by_key/... if name == "by_alphabet": return AlphabetCollection(joinUri(self.path, name), self.environ) elif name == "by_genre": return GenreCollection(joinUri(self.path, name), self.environ) _logger.error("unexpected member name, " + name) return None
def getMember(self, name): if self.episodes is None: self.extractInfo() try: url = self.episodes[name] except: return None if '/archives/' in url: return EpisodeCollection(joinUri(self.path, name), self.environ, url) return SeriesCollection(joinUri(self.path, name), self.environ, url)
def getMember(self, name): if name in self.genres: genre = name.lower().replace(' ', '-') return DirectoryPageCollection(joinUri(self.path, name), self.environ, genre) _logger.error("unexpected member name, " + name) return None
def getMember(self, name): if name in self.items: pname = '9' if name == '#' else name.lower() return DirectoryPageCollection(joinUri(self.path, name), self.environ, pname) _logger.error("unexpected member name, " + name) return None
def getMember(self, name): if name.isdigit(): url = self.url + "/" + name return ChapterCollection(joinUri(self.path, name), self.environ, url) _logger.error("unexpected chapter name, " + name) return None
def getMember(self, name): """ Return child resource with a given name (None, if not found). """ assert self.isCollection return self.provider.getResourceInst(util.joinUri(self.path, name), self.environ)
def getMember(self, name): if self.series is None: self.extractInfo() try: return SeriesCollection(joinUri(self.path, name), self.environ, self.series[name]) except: return None
def getMember(self, name): if self.mangas is None: self.extractInfo() try: url = ROOT_URL + "/" + self.mangas[name] return MangaCollection(joinUri(self.path, name), self.environ, url) except: return None
def getMember(self, name): """Return direct collection member (DAVResource or derived). See DAVCollection.getMember() """ path = util.joinUri(self.path, name) return self.provider.getResourceInst(path, self.environ)
def getMember(self, name): if name.isdigit(): startid = int(name) url = ROOT_URL + "/popular/%s/%d" % (self.genre, startid) return DirectoryCollection(joinUri(self.path, name), self.environ, url) _logger.error("unexpected member name, " + name) return None
def getMember(self, name): if name.isdigit(): pg = int(name) url = ROOT_URL + "/directory/%s/%d.htm" % (self.pname, pg) return DirectoryCollection(joinUri(self.path, name), self.environ, url) _logger.error("unexpected member name, " + name) return None
def createResourceInst(self, parent, name, environ): self._count_getResourceInst += 1 try: res = VDOM_resource(util.joinUri(parent, name), False, environ, self.application.id, self.obj.id,None) res.name = name #res.parent = parent return res except: raise DAVError(HTTP_FORBIDDEN)
def getMember(self, name): for tname, tid in self.btable: if tname == name: url = ROOT_URL + "/?c=1/%d" % tid url += "&sort=gid" #url += "&sort=subject" return ListPageCollection(joinUri(self.path, name), self.environ, url) _logger.error("unexpected member name, " + name) return None
def getMember(self, name): if self.galleries is None: self.extractInfo() for gid, gname in self.galleries: if self.name_clean(gname) == name: url = ROOT_URL + "/galleries/%s.html" % gid return GalleryCollection(joinUri(self.path, name), self.environ, url) _logger.warning("unexpected name, %s" % name) return []
def createCollection(self, name): """Create a new collection as member of self. See DAVResource.createCollection() """ if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) self.nibbler.mkdir(path)
def createCollection(self, name): """Create a new collection as member of self. See DAVResource.createCollection() """ assert "/" not in name if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) fp = self.provider._locToFilePath(path, self.environ) os.mkdir(fp)
def getMember(self, name): assert compat.is_native(name), "%r" % name fp = os.path.join(self._filePath, compat.to_unicode(name)) path = util.joinUri(self.path, name) if os.path.isdir(fp): res = WTFolderResource(path, self.environ, fp, self.pathMapper) elif os.path.isfile(fp): res = WTFileResource(path, self.environ, fp, self.pathMapper) else: res = None return res
def createCollection(self, name): assert self.isCollection func_name = "createCollection" xml_data = """{"path": "%s", "name": "%s"}""" % (self.path, name) ret = managers.dispatcher.dispatch_action(self._app_id, self._obj_id, func_name, "",xml_data) if ret: res = self.provider.getResourceInst(util.joinUri(self.path, name), self.environ) if res: #get_properties.invalidate(self._app_id, self._obj_id, self.path) return res raise DAVError(HTTP_FORBIDDEN)
def createEmptyResource(self, name): """Create an empty (length-0) resource. See DAVResource.createEmptyResource() """ assert "/" not in name if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) fp = self.provider._locToFilePath(path, self.environ) f = open(fp, "wb") f.close() return self.provider.getResourceInst(path, self.environ)
def getMember(self, name): """Return direct collection member (DAVResource or derived). See DAVCollection.getMember() """ r_obj = self.dir_obj.get(name.decode("utf8")) path = util.joinUri(self.path, name) if r_obj.is_dir(): res = FolderResource(self.nibbler, path, self.environ, r_obj) else: res = FileResource(self.nibbler, path, self.environ, r_obj) return res
def getMember(self, name): if self.imgurls is None: self.extractInfo() """ basename as image file name for url in self.imgurls: fname = self.basename(url) if fname == name: return ImageFile(joinUri(self.path, name), self.environ, url, self.url, self.cookie) return None """ """ counter as image file name """ idx = int(name.split('.')[0]) - 1 url = self.imgurls[idx] return ImageFile(joinUri(self.path, name), self.environ, url, self.url, self.cookie)
def createEmptyResource(self, name): """Create an empty (length-0) resource. See DAVResource.createEmptyResource() """ if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) #if name.startswith('.'): # raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) f_obj = FSItem(name, is_dir=False) self.provider.cache_fs.put(path, f_obj) return self.provider.getResourceInst(path, self.environ)
def createEmptyResource(self, name): """Create an empty (length-0) resource. See DAVResource.createEmptyResource() """ if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) if name.startswith('.'): raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) file_md = FileMD(name.decode('utf8')) self.dir_obj.append(file_md) return self.provider.getResourceInst(path, self.environ)
def getMember(self, name): # Handle visible categories and also /by_key/... path = joinUri(self.path, name) if name == "by_language": return LanguageCollection(path, self.environ) elif name == "by_date": return PageCollection(path, self.environ, "index-" + self.environ['hitomi.language']) elif name == "by_popularity": return PageCollection(path, self.environ, "popular-" + self.environ['hitomi.language']) elif name == "by_artist": return ArtistCollection(path, self.environ) elif name == "by_tag": return TagCollection(path, self.environ) return []
def get_children(app_id, obj_id, path): cache.last_access = datetime.now() cnames = [] func_name = "getMembers" xml_data = """{"path": "%s"}""" % path ret = managers.dispatcher.dispatch_action(app_id, obj_id, func_name, "",xml_data) or {} #if ret: # cnames = list(ret.keys()) if isinstance(ret, dict) else ret parent = cache.get((app_id, obj_id, path)) if parent and parent[1] == 1: with lock: cache.pop((app_id, obj_id, path)) for name,child in ret.iteritems(): cache[(app_id, obj_id, util.joinUri(path, name))] = (child,0) cache[(app_id, obj_id, path)] = (parent[0], 0) return ret
def getMember(self, name): """Return direct collection member (DAVResource or derived). See DAVCollection.getMember() """ assert compat.is_native(name), "%r" % name fp = os.path.join(self._filePath, compat.to_unicode(name)) # name = name.encode("utf8") path = util.joinUri(self.path, name) if os.path.isdir(fp): res = FolderResource(path, self.environ, fp) elif os.path.isfile(fp): res = FileResource(path, self.environ, fp) else: _logger.debug("Skipping non-file %s" % fp) res = None return res
def getMember(self, name): if self.nlist is None: self.nlist = pcs.list_dir_all(self.environ['bdyun.cookie'], self.environ['bdyun.tokens'], self.path) _dircache[self.abspath] = self.nlist global _video_fmts for item in self.nlist: bname = item['server_filename'].encode('utf-8') if bname == name: path = item['path'].encode('utf-8') if item['isdir']: return BdyunCollection(path, self.environ) else: return BdyunFile(path, self.environ, item) if name.endswith('.m3u8'): rname, ext = os.path.splitext(bname) if name.startswith(rname) and ext[1:].lower() in _video_fmts: return BdyunStreamFile(joinUri(self.path, name), self.environ, item) return None
def testBasics(self): """Test basic tool functions.""" assert joinUri("/a/b", "c") == "/a/b/c" assert joinUri("/a/b/", "c") == "/a/b/c" assert joinUri("/a/b", "c", "d") == "/a/b/c/d" assert joinUri("a/b", "c", "d") == "a/b/c/d" assert joinUri("/", "c") == "/c" assert joinUri("", "c") == "/c" assert not isChildUri("/a/b", "/a/") assert not isChildUri("/a/b", "/a/b") assert not isChildUri("/a/b", "/a/b/") assert not isChildUri("/a/b", "/a/bc") assert not isChildUri("/a/b", "/a/bc/") assert isChildUri("/a/b", "/a/b/c") assert isChildUri("/a/b", "/a/b/c") assert not isEqualOrChildUri("/a/b", "/a/") assert isEqualOrChildUri("/a/b", "/a/b") assert isEqualOrChildUri("/a/b", "/a/b/") assert not isEqualOrChildUri("/a/b", "/a/bc") assert not isEqualOrChildUri("/a/b", "/a/bc/") assert isEqualOrChildUri("/a/b", "/a/b/c") assert isEqualOrChildUri("/a/b", "/a/b/c") assert lstripstr("/dav/a/b", "/dav") == "/a/b" assert lstripstr("/dav/a/b", "/DAV") == "/dav/a/b" assert lstripstr("/dav/a/b", "/DAV", True) == "/a/b" assert popPath("/a/b/c") == ("a", "/b/c") assert popPath("/a/b/") == ("a", "/b/") assert popPath("/a/") == ("a", "/") assert popPath("/a") == ("a", "/") assert popPath("/") == ("", "") assert popPath("") == ("", "") self.assertEqual(shiftPath("", "/a/b/c"), ("a", "/a", "/b/c")) self.assertEqual(shiftPath("/a", "/b/c"), ("b", "/a/b", "/c")) self.assertEqual(shiftPath("/a/b", "/c"), ("c", "/a/b/c", "")) self.assertEqual(shiftPath("/a/b/c", "/"), ("", "/a/b/c", "")) self.assertEqual(shiftPath("/a/b/c", ""), ("", "/a/b/c", ""))
def getMember(self, name): # Rely on provider to get member oinstances assert self.isCollection return self.provider.getResourceInst(util.joinUri(self.path, name), self.environ)
def getMember(self, name): for data in _getResListByAttr(self.catType, self.name): if data["title"] == name: return VirtualResource(joinUri(self.path, name), self.environ, data) return None
def getMember(self, name): # Handle visible categories and also /by_key/... if name in self._validMemberNames: return CategoryTypeCollection(joinUri(self.path, name), self.environ) return None
def getMember(self, name, preloaded = None): assert self.isCollection return self.provider.getResourceInst(util.joinUri(self.path, name), self.environ,preloaded)
def getMember(self, name): doc = self.coll.find_one(ObjectId(name)) return DocResource(joinUri(self.path, name), self.environ, doc)
def getMember(self, name): coll = self.db[name] return CollCollection(joinUri(self.path, name), self.environ, coll)
def getMember(self, name): # raise NotImplementedError() return self.provider.getResourceInst(util.joinUri(self.path, name), self.environ)
def getMember(self, name): return DbCollection(joinUri(self.path, name), self.environ)