def _got(children): kids = {} for name, (childnode, metadata) in children.iteritems(): assert IFilesystemNode.providedBy(childnode), childnode rw_uri = childnode.get_write_uri() ro_uri = childnode.get_readonly_uri() if IFileNode.providedBy(childnode): kiddata = ("filenode", { 'size': childnode.get_size(), 'mutable': childnode.is_mutable(), }) if childnode.is_mutable(): mutable_type = childnode.get_version() assert mutable_type in (SDMF_VERSION, MDMF_VERSION) if mutable_type == MDMF_VERSION: file_format = "MDMF" else: file_format = "SDMF" else: file_format = "CHK" kiddata[1]['format'] = file_format elif IDirectoryNode.providedBy(childnode): kiddata = ("dirnode", {'mutable': childnode.is_mutable()}) else: kiddata = ("unknown", {}) kiddata[1]["metadata"] = metadata if rw_uri: kiddata[1]["rw_uri"] = rw_uri if ro_uri: kiddata[1]["ro_uri"] = ro_uri verifycap = childnode.get_verify_cap() if verifycap: kiddata[1]['verify_uri'] = verifycap.to_string() kids[name] = kiddata drw_uri = dirnode.get_write_uri() dro_uri = dirnode.get_readonly_uri() contents = {'children': kids} if dro_uri: contents['ro_uri'] = dro_uri if drw_uri: contents['rw_uri'] = drw_uri verifycap = dirnode.get_verify_cap() if verifycap: contents['verify_uri'] = verifycap.to_string() contents['mutable'] = dirnode.is_mutable() data = ("dirnode", contents) json = simplejson.dumps(data, indent=1) + "\n" return json
def _got(children): kids = {} for name, (childnode, metadata) in children.iteritems(): assert IFilesystemNode.providedBy(childnode), childnode rw_uri = childnode.get_write_uri() ro_uri = childnode.get_readonly_uri() if IFileNode.providedBy(childnode): kiddata = ("filenode", {'size': childnode.get_size(), 'mutable': childnode.is_mutable(), }) if childnode.is_mutable(): mutable_type = childnode.get_version() assert mutable_type in (SDMF_VERSION, MDMF_VERSION) if mutable_type == MDMF_VERSION: file_format = "MDMF" else: file_format = "SDMF" else: file_format = "CHK" kiddata[1]['format'] = file_format elif IDirectoryNode.providedBy(childnode): kiddata = ("dirnode", {'mutable': childnode.is_mutable()}) else: kiddata = ("unknown", {}) kiddata[1]["metadata"] = metadata if rw_uri: kiddata[1]["rw_uri"] = rw_uri if ro_uri: kiddata[1]["ro_uri"] = ro_uri verifycap = childnode.get_verify_cap() if verifycap: kiddata[1]['verify_uri'] = verifycap.to_string() kids[name] = kiddata drw_uri = dirnode.get_write_uri() dro_uri = dirnode.get_readonly_uri() contents = { 'children': kids } if dro_uri: contents['ro_uri'] = dro_uri if drw_uri: contents['rw_uri'] = drw_uri verifycap = dirnode.get_verify_cap() if verifycap: contents['verify_uri'] = verifycap.to_string() contents['mutable'] = dirnode.is_mutable() data = ("dirnode", contents) json = simplejson.dumps(data, indent=1) + "\n" return json
def _got(children): kids = {} for name, (childnode, metadata) in children.iteritems(): assert IFilesystemNode.providedBy(childnode), childnode rw_uri = childnode.get_write_uri() ro_uri = childnode.get_readonly_uri() if IFileNode.providedBy(childnode): kiddata = ("filenode", get_filenode_metadata(childnode)) elif IDirectoryNode.providedBy(childnode): kiddata = ("dirnode", {'mutable': childnode.is_mutable()}) else: kiddata = ("unknown", {}) kiddata[1]["metadata"] = metadata if rw_uri: kiddata[1]["rw_uri"] = rw_uri if ro_uri: kiddata[1]["ro_uri"] = ro_uri verifycap = childnode.get_verify_cap() if verifycap: kiddata[1]['verify_uri'] = verifycap.to_string() kids[name] = kiddata drw_uri = dirnode.get_write_uri() dro_uri = dirnode.get_readonly_uri() contents = { 'children': kids } if dro_uri: contents['ro_uri'] = dro_uri if drw_uri: contents['rw_uri'] = drw_uri verifycap = dirnode.get_verify_cap() if verifycap: contents['verify_uri'] = verifycap.to_string() contents['mutable'] = dirnode.is_mutable() data = ("dirnode", contents) json = simplejson.dumps(data, indent=1) + "\n" return json
def DirectoryReadonlyURI(ctx, dirnode): return text_plain(dirnode.get_readonly_uri(), ctx)