本文整理汇总了Python中election.Election.delete_value方法的典型用法代码示例。如果您正苦于以下问题:Python Election.delete_value方法的具体用法?Python Election.delete_value怎么用?Python Election.delete_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类election.Election
的用法示例。
在下文中一共展示了Election.delete_value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: purge_otp
# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import delete_value [as 别名]
def purge_otp(reg, otp):
otp_key = htscommon.get_verification_key(otp)
voter = reg.read_string_value(otp_key, "voter").value.rstrip()
voter_key = htscommon.get_user_key(voter)
elids = reg.read_string_value(otp_key, "elids").value.rstrip().split("\t")
for elid in elids:
sreg = Election().get_sub_reg(elid)
if sreg.check(voter_key + [htscommon.VOTE_VERIFICATION_ID_FILENAME]):
sreg.delete_value(voter_key, htscommon.VOTE_VERIFICATION_ID_FILENAME)
reg.ensure_no_key(otp_key)
示例2: __init__
# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import delete_value [as 别名]
class Rights:
def __init__(self, elid):
self.reg = Election().get_sub_reg(elid, ['common', 'rights'])
def descr(self, code):
"""
Tagastab tegelase kohta käiva kirjelduse
"""
if not formatutil.is_isikukood(code):
raise Exception('Vigane isikukood')
if self.reg.check([code, 'description']):
return self.reg.read_string_value([code], 'description').value
else:
return 'Andmed puuduvad'
def listall(self):
"""
Tagastab kõik volitused
"""
lst = self.reg.list_keys()
ret = ''
for ele in lst:
ret = ret + '\n' + self.listuser(ele)
return ret.strip()
def _create_user(self, code):
""" Loome kasutaja, kui teda veel pole
"""
if not formatutil.is_isikukood(code):
raise Exception('Vigane isikukood')
self.reg.ensure_key([code, 'rights'])
def add(self, code, right):
"""
Lisab uue volituse
"""
new_right = right.upper()
if not _proper_right(new_right):
raise Exception('Vigane volitus')
self._create_user(code)
if not self.has(code, new_right):
self.reg.create_value([code, 'rights'], new_right, '')
return True
return False
def adddesc(self, code, desc):
"""
Lisab kasutajale kirjelduse
"""
self._create_user(code)
self.reg.create_value([code], 'description', desc)
return True
def remove(self, code, right):
"""
Võtab kasutajalt volituse
"""
if not formatutil.is_isikukood(code):
raise Exception('Vigane isikukood')
new_right = right.upper()
if not _proper_right(new_right):
raise Exception('Vigane volitus')
if self.has(code, new_right):
self.reg.delete_value([code, 'rights'], new_right)
return True
return False
def remuser(self, code):
"""
Eemaldab ühe kasutaja volituste failist
"""
if not formatutil.is_isikukood(code):
raise Exception('Vigane isikukood')
return self.reg.ensure_no_key([code])
def remall(self):
"""
Eemaldab kõik volitused
"""
self.reg.reset_key([''])
return True
def has(self, code, right):
"""
Kas koodil on vastav volitus
"""
if not formatutil.is_isikukood(code):
#.........这里部分代码省略.........