-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* random voting in bot-community * democracy bot fixes * fmt * cosmetics * add cli export-secret and help tester with the mnemonic of an account which will skip voting. randomize turnout too * fix ci * fix ci * fix ci^3
- Loading branch information
Showing
11 changed files
with
176 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import re | ||
from datetime import datetime | ||
|
||
|
||
class Proposal: | ||
def __init__(self, id, action, started, ends, start_cindex, electorate, turnout, approval, state): | ||
self.id = id | ||
self.action = action | ||
self.started = started | ||
self.ends = ends | ||
self.start_cindex = start_cindex | ||
self.electorate = electorate | ||
self.turnout = turnout | ||
self.approval = approval | ||
self.state = state | ||
|
||
|
||
def parse_proposals(text): | ||
proposals = text.split("Proposal id:") | ||
proposal_objects = [] | ||
|
||
for proposal in proposals[1:]: # Skip the first split result as it will be an empty string | ||
proposal = "Proposal id:" + proposal # Add back the identifier | ||
lines = proposal.split("\n") | ||
id = int(re.search(r'\d+', lines[0]).group()) | ||
action = re.search(r'ProposalAction::\w+\([\w, .]+\)', lines[1]).group() | ||
started = datetime.strptime(re.search(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}', lines[2]).group(), | ||
'%Y-%m-%d %H:%M:%S') | ||
ends = datetime.strptime(re.search(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}', lines[3]).group(), | ||
'%Y-%m-%d %H:%M:%S') | ||
start_cindex = int(re.search(r'\d+', lines[4]).group()) | ||
electorate = int(re.search(r'\d+', lines[5]).group()) | ||
turnout = int(re.search(r'\d+', lines[6]).group()) | ||
approval = int(re.search(r'\d+', lines[7]).group()) | ||
state = re.search(r'ProposalState::(\w+)', lines[8]).group(1) | ||
|
||
proposal_objects.append(Proposal(id, action, started, ends, start_cindex, electorate, turnout, approval, state)) | ||
|
||
return proposal_objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.