コード例 #1
0
def rmsnippet(tag: str, user: str) -> None:
    """
	To remove a command into the database.
	Params:
	- `tag` : `str` , unique tag of the command to be removed
	- `user` : `str` , the user who takes the action, for verification use.

	Returns: `None`
	Raises:
	
	- `TagNotFound` if tag is not found.
	- `TagNotOwned` if tag is not owned by the user.
	"""
    if not tagexists(tag):
        raise TagNotFound

    if not isauthed(user, tag):
        raise TagNotOwned

    credit = Redis.hget(CRDT_GBL, tag).decode('utf-8')
    Redis.srem(TAGS_GBL, tag)
    Redis.hdel(CMDS_GBL, tag)
    Redis.hdel(DESC_GBL, tag)
    Redis.srem(CREATEDBY.format(credit), tag)
    Redis.hdel(CRDT_GBL, tag)
コード例 #2
0
def rmreport(tag):
    """
	Remove a recorded report.
	This is not related to tag itself, whether the snippet was deleted or not.
	"""
    Redis.srem('reported:global', tag)
    Redis.hdel('repreason:global', tag)
    Redis.hdel('reportedby:global', tag)
    Redis.hdel('reportedfrom:global', tag)