Mercurial > libervia-backend
comparison sat/memory/memory.py @ 2909:90146552cde5
core (memory), plugin XEP-0329, plugin invitation: minor style improvments
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Apr 2019 08:21:51 +0200 |
parents | 003b8b4b56a7 |
children | 59aea54e74a8 |
comparison
equal
deleted
inserted
replaced
2908:695fc440c3b8 | 2909:90146552cde5 |
---|---|
1415 files.remove(file_data) | 1415 files.remove(file_data) |
1416 defer.returnValue(files) | 1416 defer.returnValue(files) |
1417 | 1417 |
1418 @defer.inlineCallbacks | 1418 @defer.inlineCallbacks |
1419 def setFile( | 1419 def setFile( |
1420 self, | 1420 self, client, name, file_id=None, version=u"", parent=None, path=None, |
1421 client, | 1421 type_=C.FILE_TYPE_FILE, file_hash=None, hash_algo=None, size=None, |
1422 name, | 1422 namespace=None, mime_type=None, created=None, modified=None, owner=None, |
1423 file_id=None, | 1423 access=None, extra=None, peer_jid=None, perms_to_check=(C.ACCESS_PERM_WRITE,) |
1424 version=u"", | 1424 ): |
1425 parent=None, | |
1426 path=None, | |
1427 type_=C.FILE_TYPE_FILE, | |
1428 file_hash=None, | |
1429 hash_algo=None, | |
1430 size=None, | |
1431 namespace=None, | |
1432 mime_type=None, | |
1433 created=None, | |
1434 modified=None, | |
1435 owner=None, | |
1436 access=None, | |
1437 extra=None, | |
1438 peer_jid=None, | |
1439 perms_to_check=(C.ACCESS_PERM_WRITE,), | |
1440 ): | |
1441 """set a file metadata | 1425 """set a file metadata |
1442 | 1426 |
1443 @param name(unicode): basename of the file | 1427 @param name(unicode): basename of the file |
1444 @param file_id(unicode): unique id of the file | 1428 @param file_id(unicode): unique id of the file |
1445 @param version(unicode): version of this file | 1429 @param version(unicode): version of this file |
1446 empty string for current version or when there is no versioning | 1430 empty string for current version or when there is no versioning |
1447 @param parent(unicode, None): id of the directory containing the files | 1431 @param parent(unicode, None): id of the directory containing the files |
1448 @param path(unicode, None): virtual path of the file in the namespace | 1432 @param path(unicode, None): virtual path of the file in the namespace |
1449 if set, parent must be None. All intermediate directories will be created if needed, | 1433 if set, parent must be None. All intermediate directories will be created |
1450 using current access. | 1434 if needed, using current access. |
1451 @param file_hash(unicode): unique hash of the payload | 1435 @param file_hash(unicode): unique hash of the payload |
1452 @param hash_algo(unicode): algorithm used for hashing the file (usually sha-256) | 1436 @param hash_algo(unicode): algorithm used for hashing the file (usually sha-256) |
1453 @param size(int): size in bytes | 1437 @param size(int): size in bytes |
1454 @param namespace(unicode, None): identifier (human readable is better) to group files | 1438 @param namespace(unicode, None): identifier (human readable is better) to group |
1455 for instance, namespace could be used to group files in a specific photo album | 1439 files |
1440 For instance, namespace could be used to group files in a specific photo album | |
1456 @param mime_type(unicode): MIME type of the file, or None if not known/guessed | 1441 @param mime_type(unicode): MIME type of the file, or None if not known/guessed |
1457 @param created(int): UNIX time of creation | 1442 @param created(int): UNIX time of creation |
1458 @param modified(int,None): UNIX time of last modification, or None to use created date | 1443 @param modified(int,None): UNIX time of last modification, or None to use |
1459 @param owner(jid.JID, None): jid of the owner of the file (mainly useful for component) | 1444 created date |
1445 @param owner(jid.JID, None): jid of the owner of the file (mainly useful for | |
1446 component) | |
1460 will be used to check permission (only bare jid is used, don't use with MUC). | 1447 will be used to check permission (only bare jid is used, don't use with MUC). |
1461 Use None to ignore permission (perms_to_check must be None too) | 1448 Use None to ignore permission (perms_to_check must be None too) |
1462 @param access(dict, None): serialisable dictionary with access rules. | 1449 @param access(dict, None): serialisable dictionary with access rules. |
1463 None (or empty dict) to use private access, i.e. allow only profile's jid to access the file | 1450 None (or empty dict) to use private access, i.e. allow only profile's jid to |
1451 access the file | |
1464 key can be on on C.ACCESS_PERM_*, | 1452 key can be on on C.ACCESS_PERM_*, |
1465 then a sub dictionary with a type key is used (one of C.ACCESS_TYPE_*). | 1453 then a sub dictionary with a type key is used (one of C.ACCESS_TYPE_*). |
1466 According to type, extra keys can be used: | 1454 According to type, extra keys can be used: |
1467 - C.ACCESS_TYPE_PUBLIC: the permission is granted for everybody | 1455 - C.ACCESS_TYPE_PUBLIC: the permission is granted for everybody |
1468 - C.ACCESS_TYPE_WHITELIST: the permission is granted for jids (as unicode) in the 'jids' key | 1456 - C.ACCESS_TYPE_WHITELIST: the permission is granted for jids (as unicode) |
1457 in the 'jids' key | |
1469 will be encoded to json in database | 1458 will be encoded to json in database |
1470 @param extra(dict, None): serialisable dictionary of any extra data | 1459 @param extra(dict, None): serialisable dictionary of any extra data |
1471 will be encoded to json in database | 1460 will be encoded to json in database |
1472 @param perms_to_check(tuple[unicode],None): permission to check | 1461 @param perms_to_check(tuple[unicode],None): permission to check |
1473 must be a tuple of C.ACCESS_PERM_* or None | 1462 must be a tuple of C.ACCESS_PERM_* or None |
1474 if None, permission will no be checked (peer_jid must be None too in this case) | 1463 if None, permission will no be checked (peer_jid must be None too in this |
1464 case) | |
1475 @param profile(unicode): profile owning the file | 1465 @param profile(unicode): profile owning the file |
1476 """ | 1466 """ |
1477 if "/" in name: | 1467 if "/" in name: |
1478 raise ValueError('name must not contain a slash ("/")') | 1468 raise ValueError('name must not contain a slash ("/")') |
1479 if file_id is None: | 1469 if file_id is None: |