Ejemplo n.º 1
0
def writeOutput(arguments):
	'Write output.'
	if '-h' in arguments or '-help' in arguments:
		print(__doc__)
		return
	suffixNumberString = almoner.getParameter(arguments, '24', 'round')
	suffixNumber = int(suffixNumberString)
	outputAccountTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'account.csv', 'account'), suffixNumberString)
	accountLines = getAccountLines(arguments, suffixNumberString)
	peerLines = getPeerLines(arguments)
	peerText = '_beginpeers\n%s_endpeers\n' % almoner.getTextByLines(peerLines)
	accountText = getPluribusunumText(peerText, accountLines)
	if almoner.sendOutputTo(outputAccountTo, accountText):
		print('The account file has been written to:\n%s\n' % outputAccountTo)
	outputReceiverTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'receiver.csv', 'receiver'), suffixNumberString)
	outputSummaryTo = almoner.getParameter(arguments, 'receiver_summary.txt', 'summary')
	denominatorSequences = getDenominatorSequencesByAccountLines(accountLines)
	originalReceiverLines = getReceiverLinesByDenominatorSequences(denominatorSequences)
	receiverLines = getPackedReceiverLines(denominatorSequences, originalReceiverLines, suffixNumber)
	receiverText = getPluribusunumText(peerText, receiverLines)
	if almoner.sendOutputTo(outputReceiverTo, receiverText):
		print('The receiver file has been written to:\n%s\n' % outputReceiverTo)
		shaOutputPrefix = almoner.getParameter(arguments, '', 'sha')
		if len(shaOutputPrefix) != 0:
			sha256FileName = almoner.getSuffixedFileName(outputReceiverTo, shaOutputPrefix)
			almoner.writeFileText(sha256FileName, hashlib.sha256(receiverText).hexdigest())
			print('The sha256 receiver file has been written to:\n%s\n' % sha256FileName)
	if almoner.sendOutputTo(outputSummaryTo, getSummaryText(accountLines, originalReceiverLines, peerLines, suffixNumber)):
		print('The summary file has been written to:\n%s\n' % outputSummaryTo)
Ejemplo n.º 2
0
def writeOutput(arguments):
	'Write output.'
	if '-h' in arguments or '-help' in arguments:
		print(__doc__)
		return
	suffixNumberString = almoner.getParameter(arguments, '24', 'round')
	suffixNumber = int(suffixNumberString)
	outputAccountTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'account.csv', 'account'), suffixNumberString)
	accountLines = getAccountLines(arguments, suffixNumberString)
	peerLines = getPeerLines(arguments)
	peerText = '_beginpeers\n%s_endpeers\n' % almoner.getTextByLines(peerLines)
	accountText = getPluribusunumText(peerText, accountLines)
	if almoner.sendOutputTo(outputAccountTo, accountText):
		print('The account file has been written to:\n%s\n' % outputAccountTo)
	outputReceiverTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'receiver.csv', 'receiver'), suffixNumberString)
	outputSummaryTo = almoner.getParameter(arguments, 'receiver_summary.txt', 'summary')
	denominatorSequences = getDenominatorSequencesByAccountLines(accountLines)
	originalReceiverLines = getReceiverLinesByDenominatorSequences(denominatorSequences)
	receiverLines = getPackedReceiverLines(denominatorSequences, originalReceiverLines, suffixNumber)
	receiverText = getPluribusunumText(peerText, receiverLines)
	if almoner.sendOutputTo(outputReceiverTo, receiverText):
		print('The receiver file has been written to:\n%s\n' % outputReceiverTo)
		shaOutputPrefix = almoner.getParameter(arguments, '', 'sha')
		if len(shaOutputPrefix) != 0:
			sha256FileName = almoner.getSuffixedFileName(outputReceiverTo, shaOutputPrefix)
			almoner.writeFileText(sha256FileName, hashlib.sha256(receiverText).hexdigest())
			print('The sha256 receiver file has been written to:\n%s\n' % sha256FileName)
	if almoner.sendOutputTo(outputSummaryTo, getSummaryText(accountLines, originalReceiverLines, peerLines, suffixNumber)):
		print('The summary file has been written to:\n%s\n' % outputSummaryTo)
Ejemplo n.º 3
0
def writeWidenedFile(folderName, peerRootAddress, peerTextUntilCoins, widenRound):
    "Write widened file."
    title = almoner.getSuffixedFileName("receiver.csv", str(widenRound))
    widenPath = os.path.join(folderName, title)
    receiverAddress = almoner.getSuffixedFileName(peerRootAddress, str(widenRound))
    receiverText = almoner.getLocationText(receiverAddress)
    receiverTextFromCoins = receiverText[receiverText.find("_begincoins") :]
    widenText = peerTextUntilCoins + receiverTextFromCoins
    almoner.writeFileText(widenPath, widenText)
Ejemplo n.º 4
0
def writeWidenedFile(folderName, peerRootAddress, peerTextUntilCoins,
                     widenRound):
    'Write widened file.'
    title = almoner.getSuffixedFileName('receiver.csv', str(widenRound))
    widenPath = os.path.join(folderName, title)
    receiverAddress = almoner.getSuffixedFileName(peerRootAddress,
                                                  str(widenRound))
    receiverText = almoner.getLocationText(receiverAddress)
    receiverTextFromCoins = receiverText[receiverText.find('_begincoins'):]
    widenText = peerTextUntilCoins + receiverTextFromCoins
    almoner.writeFileText(widenPath, widenText)
Ejemplo n.º 5
0
def writeFolder(folderName, peerRootAddress, round):
    "Write zip file."
    print("Making directory:")
    print(folderName)
    print("")
    almoner.makeDirectory(folderName)
    peerAddress = almoner.getSuffixedFileName(peerRootAddress, str(round))
    print("Getting peer:")
    print(peerAddress)
    print("")
    peerText = almoner.getLocationText(peerAddress)
    peerTextUntilCoins = peerText[: peerText.find("_begincoins")]
    unthinkingbitString = "https://raw.github.com/Unthinkingbit/charity/master/receiver.csv"
    fuzzyString = "http://devcoinpool.btc-music.com/receiver/receiver.csv"
    peerTextUntilCoins = peerTextUntilCoins.replace(unthinkingbitString, fuzzyString)
    print("Peer text until coins:")
    print(peerTextUntilCoins)
    print("")
    print("Writing widened files:")
    for widenRound in xrange(round + 1):
        writeWidenedFile(folderName, peerRootAddress, peerTextUntilCoins, widenRound)
    print("")
Ejemplo n.º 6
0
def writeFolder(folderName, peerRootAddress, round):
    'Write zip file.'
    print('Making directory:')
    print(folderName)
    print('')
    almoner.makeDirectory(folderName)
    peerAddress = almoner.getSuffixedFileName(peerRootAddress, str(round))
    print('Getting peer:')
    print(peerAddress)
    print('')
    peerText = almoner.getLocationText(peerAddress)
    peerTextUntilCoins = peerText[:peerText.find('_begincoins')]
    unthinkingbitString = 'https://raw.github.com/Unthinkingbit/charity/master/receiver.csv'
    fuzzyString = 'http://devcoinpool.btc-music.com/receiver/receiver.csv'
    peerTextUntilCoins = peerTextUntilCoins.replace(unthinkingbitString,
                                                    fuzzyString)
    print('Peer text until coins:')
    print(peerTextUntilCoins)
    print('')
    print('Writing widened files:')
    for widenRound in xrange(round + 1):
        writeWidenedFile(folderName, peerRootAddress, peerTextUntilCoins,
                         widenRound)
    print('')