本文整理汇总了Python中election.Election.create_string_value方法的典型用法代码示例。如果您正苦于以下问题:Python Election.create_string_value方法的具体用法?Python Election.create_string_value怎么用?Python Election.create_string_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类election.Election
的用法示例。
在下文中一共展示了Election.create_string_value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: issue_vote_id
# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import create_string_value [as 别名]
def issue_vote_id(self):
vote_id = self.__create_vote_key()
rreg = Election().get_root_reg()
key = htscommon.get_verification_key(vote_id)
rreg.create_string_value(key, "voter", self.signercode)
rreg.create_integer_value(key, "timestamp", int(time.time()))
rreg.create_integer_value(key, "count", \
Election().get_verification_count())
# Store the election IDs and include a backreference in the
# corresponding questions' subregistries.
elids = ""
for elid in [quest[0] for quest in self.questions]:
elids += elid + "\t"
sreg = Election().get_sub_reg(elid)
skey = htscommon.get_user_key(self.signercode)
sreg.ensure_key(skey)
sreg.create_string_value(skey, \
htscommon.VOTE_VERIFICATION_ID_FILENAME, vote_id)
rreg.create_string_value(key, "elids", elids)
return vote_id
示例2: do_change_election_description
# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import create_string_value [as 别名]
def do_change_election_description(elid):
description = uiutil.ask_string("Sisesta valimiste kirjeldus")
el_reg = Election().get_sub_reg(elid)
el_reg.create_string_value(['common'], 'description', description)
示例3: __init__
# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import create_string_value [as 别名]
class HTSBase:
def __init__(self, elid):
self._elid = elid
self._errmsg = None
self._reg = Election().get_sub_reg(self._elid)
self._revlog = evlog.Logger()
self._revlog.set_format(evlog.RevLogFormat())
self._revlog.set_logs(self._reg.path(['common', evcommon.REVLOG_FILE]))
def haaletanud(self, isikukood):
latest = self.get_latest_vote(isikukood)
return latest is not None
def get_revoked_path(self, pc):
user_key = htscommon.get_user_key(pc)
return self._reg.path(user_key + ['reason'])
def get_latest_vote(self, pc):
user_key = htscommon.get_user_key(pc)
if self._reg.check(user_key):
files = self._reg.list_keys(user_key)
votes = []
for el in files:
if htscommon.VALID_VOTE_PATTERN.match(el):
votes.append(el)
votes.sort()
latest = votes.pop()
if latest:
return htscommon.get_votefile_time(latest)
return None
def restore_vote(self, revline, operator):
timest = self.get_latest_vote(revline[0])
os.unlink(self.get_revoked_path(revline[0]))
self._revlog.log_info(
tegevus='ennistamine',
isikukood=revline[0],
nimi=revline[1],
timestamp=timest,
operaator=operator,
pohjus=revline[2])
def revoke_vote(self, revline, operator):
timest = self.get_latest_vote(revline[0])
nowstr = time.strftime("%Y%m%d%H%M%S", time.localtime())
self._reg.create_string_value(
htscommon.get_user_key(revline[0]), 'reason',
"%s\t%s" % (nowstr, revline[2]))
self._revlog.log_info(
tegevus='tühistamine',
testtime=nowstr,
isikukood=revline[0],
nimi=revline[1],
timestamp=timest,
operaator=operator,
pohjus=revline[2])
def is_user_revoked(self, pc):
user_key = htscommon.get_user_key(pc)
if self._reg.check(user_key + ['reason']):
line = self._reg.read_string_value(user_key, 'reason').value
data = line.split('\t')
return True, data[1], data[0]
return False, '', ''
def save_log(self, lines, log):
fn = self._reg.path(['common', 'log%s' % log])
lf = htscommon.LoggedFile(fn)
lf.open('w')
lf.write(evcommon.VERSION + "\n")
lf.write(self._elid + "\n")
lf.write("%s\n" % log)
for el in lines:
lf.write(el + '\n')
lf.close()
def save_revocation_report(self, report):
fn = self._reg.path(['hts', 'output', evcommon.REVREPORT_FILE])
outfile = htscommon.LoggedFile(fn)
outfile.open('a')
for el in report:
outfile.write("\t".join(el) + "\n")
outfile.close()
def talletaja(self, ik):
vl = None
try:
vl = inputlists.VotersList('hts', self._reg)
if not vl.has_voter(ik):
return None
ret = vl.get_voter(ik)
return ret
finally:
if vl is not None:
vl.close()
#.........这里部分代码省略.........