Exemple #1
0
def getSummaryText(accountLines, originalReceiverLines, peerLines, suffixNumber):
	'Get the summary text.'
	cString = cStringIO.StringIO()
	suffixNumberPlusOne = suffixNumber + 1
	numberOfLines = len(originalReceiverLines)
	numberOfLinesFloat = float(numberOfLines)
	administratorPay = 0.0
	for accountLine in accountLines:
		if 'Administrator' in accountLine:
			administratorPay += Administrator(accountLine).pay
	percentPay = 0.1 * round(1000.0 * administratorPay / numberOfLinesFloat)
	cString.write('The round %s receiver files have been uploaded to:\n' % suffixNumber)
	for peerLine in peerLines:
		suffixedPeerLine = peerLine[: -len('.csv')] + ('_%s.csv' % suffixNumber)
		cString.write('%s\n' % suffixedPeerLine)
	cString.write('\nThe account file is at:\n')
	cString.write('http://galaxies.mygamesonline.org/account_%s.csv\n' % suffixNumber)
	devcoins = int(round(180000000.0 / numberOfLinesFloat))
	linesCommaString = almoner.getCommaNumberString(numberOfLines)
	cString.write('\nThere were %s original receiver lines, so the average number of devcoins per share is ' % linesCommaString)
	cString.write('180,000,000 dvc / %s = %s dvc.' % (linesCommaString, almoner.getCommaNumberString(devcoins)))
	cString.write(' Administrator pay is %s shares, %s percent of the total.\n' % (administratorPay, percentPay))
	cString.write('\nPeople on that list will start getting those coins in round %s, starting at block %s,000.' % (suffixNumber, 4 * suffixNumber))
	cString.write(' The procedure for generating the receiver files is at:\n')
	cString.write('http://devtome.com/doku.php?id=devcoin#generating_the_files\n')
	cString.write('\nThe next bounties will go into round %s:\n' % suffixNumberPlusOne)
	cString.write('http://devticker.pw/business_bounty/business_bounty_%s.csv\n' % suffixNumberPlusOne)
	cString.write('\nThe next ongoing payments will go into round %s:\n' % suffixNumberPlusOne)
	cString.write('http://dvccountdown.blisteringdevelopers.com/ongoing_%s.csv\n' % suffixNumberPlusOne)
	return cString.getvalue()
Exemple #2
0
def getSummaryText(accountLines, originalReceiverLines, peerLines, suffixNumber):
	'Get the summary text.'
	cString = cStringIO.StringIO()
	suffixNumberPlusOne = suffixNumber + 1
	numberOfLines = len(originalReceiverLines)
	numberOfLinesFloat = float(numberOfLines)
	administratorPay = 0.0
	for accountLine in accountLines:
		if 'Administrator' in accountLine:
			administratorPay += Administrator(accountLine).pay
	percentPay = 0.1 * round(1000.0 * administratorPay / numberOfLinesFloat)
	cString.write('The round %s receiver files have been uploaded to:\n' % suffixNumber)
	for peerLine in peerLines:
		suffixedPeerLine = peerLine[: -len('.csv')] + ('_%s.csv' % suffixNumber)
		cString.write('%s\n' % suffixedPeerLine)
	cString.write('\nThe account file is at:\n')
	cString.write('http://galaxies.mygamesonline.org/account_%s.csv\n' % suffixNumber)
	devcoins = int(round(180000000.0 / numberOfLinesFloat))
	linesCommaString = almoner.getCommaNumberString(numberOfLines)
	cString.write('\nThere were %s original receiver lines, so the average number of devcoins per share is ' % linesCommaString)
	cString.write('180,000,000 dvc / %s = %s dvc.' % (linesCommaString, almoner.getCommaNumberString(devcoins)))
	cString.write(' Administrator pay is %s shares, %s percent of the total.\n' % (administratorPay, percentPay))
	cString.write('\nPeople on that list will start getting those coins in round %s, starting at block %s,000.' % (suffixNumber, 4 * suffixNumber))
	cString.write(' The procedure for generating the receiver files is at:\n')
	cString.write('http://devtome.com/doku.php?id=devcoin#generating_the_files\n')
	cString.write('\nThe next bounties will go into round %s:\n' % suffixNumberPlusOne)
	cString.write('http://devticker.pw/business_bounty/business_bounty_%s.csv\n' % suffixNumberPlusOne)
	cString.write('\nThe next ongoing payments will go into round %s:\n' % suffixNumberPlusOne)
	cString.write('http://dvccountdown.blisteringdevelopers.com/ongoing_%s.csv\n' % suffixNumberPlusOne)
	return cString.getvalue()
Exemple #3
0
	def __init__(self, backupFolder, titles, words):
		'Initialize.'
		self.tomecount = Tomecount()
		self.parameterDictionary = {}
		for wordIndex, word in enumerate(words):
			self.parameterDictionary[titles[wordIndex]] = word
		if 'Cumulative Payout' in self.parameterDictionary:
			self.tomecount.previousPayout = int(self.parameterDictionary['Cumulative Payout'])
		name = self.parameterDictionary['Name']
		self.sourceAddress = 'http://devtome.com/doku.php?id=wiki:user:%s&do=edit' % name
		print('Loading articles from %s' % name)
		sourceText = getSourceText(self.sourceAddress)
		almoner.writeFileText(os.path.join(backupFolder, 'wiki:user:'******'==' in lineStrippedLower:
				isCollated = False
				isOriginal = False
				if 'collated' in lineStrippedLower:
					isCollated = True
				elif 'original' in lineStrippedLower:
					isOriginal = True
			if isCollated:
				linkText = getLinkText(lineStrippedLower)
				self.tomecount.imageCount += getImageCount(linkText)
				wordCount = getWordCount(linkText)
				self.tomecount.collatedWordCount += wordCount
				if wordCount > 0:
					print('Collated article: %s, Word Count: %s' % (lineStrippedLower, almoner.getCommaNumberString(wordCount)))
					almoner.writeFileText(os.path.join(backupFolder, getLinkName(lineStrippedLower)[1 :]), linkText)
			if isOriginal:
				linkText = getLinkText(lineStrippedLower)
				self.tomecount.imageCount += getImageCount(linkText)
				wordCount = getWordCount(linkText)
				self.tomecount.originalWordCount += wordCount
				if wordCount > 0:
					print('Original article: %s, Word Count: %s' % (lineStrippedLower, almoner.getCommaNumberString(wordCount)))
					almoner.writeFileText(os.path.join(backupFolder, getLinkName(lineStrippedLower)[1 :]), linkText)
		self.tomecount.collatedWeightedWordCount = self.tomecount.collatedWordCount * 3 / 10
		self.tomecount.wordCount = self.tomecount.collatedWordCount + self.tomecount.originalWordCount
		self.tomecount.weightedWordCount = self.tomecount.collatedWeightedWordCount + self.tomecount.originalWordCount
		self.tomecount.weightedWordCount += 10 * self.tomecount.imageCount
		if self.tomecount.weightedWordCount >= 1000:
			self.tomecount.cumulativePayout = int(round(float(self.tomecount.weightedWordCount) * 0.001))
		print('Weighted Word Count: %s' % almoner.getCommaNumberString(self.tomecount.weightedWordCount))
		self.tomecount.payout = max(self.tomecount.cumulativePayout - self.tomecount.previousPayout, 0)
		maximumPayout = 80
		if self.tomecount.payout > maximumPayout:
			self.tomecount.payout = maximumPayout
			self.tomecount.cumulativePayout = self.tomecount.previousPayout + maximumPayout
Exemple #4
0
def getPackedReceiverLines(denominatorSequences, originalReceiverLines, suffixNumber):
	"""
	A devcoin round has 4,000 blocks, if there are more than 4,000 receiver lines, the lines after the four thousandth row will not get
	generation devcoins. To get devcoins to every line, the receiver lines are packed by the denominatorMultiplier:
	denominatorMultiplier = (len(originalReceiverLines) + maximumReceivers) / (maximumReceivers + 1 - len(denominatorSequences))

	The denominator in each denominator sequence is multiplied by the denominatorMultiplier. When the receiver lines are then generated by the
	denominator sequences, the column width of the line will be up to the denominator, in effect reducing the number of rows by the
	denominatorMultiplier and increasing the number of columns by the denominatorMultiplier.

	Because this changes the number of rows, the 'Average devcoins per share' is calculated from the original number of lines.
	"""
	maximumReceivers = 4000
	originalReceiverLineLength = len(originalReceiverLines)
	denominatorMultiplier = 1
	if len(originalReceiverLines) > maximumReceivers:
		denominatorMultiplier = (len(originalReceiverLines) + maximumReceivers) / (maximumReceivers + 1 - len(denominatorSequences))
		originalReceiverLines = getGroupedReceiverLines(denominatorMultiplier, denominatorSequences)
		if len(originalReceiverLines) > maximumReceivers:
			print('Warning, denominatorMultiplier math is wrong, the receiver lines will be grouped by another factor of two.')
			originalReceiverLines = getGroupedReceiverLines(2, denominatorSequences)
	originalDevcoinBlocksPerShareFloat = float(maximumReceivers) / originalReceiverLineLength
	averageDevcoinsPerShare = int(round(originalDevcoinBlocksPerShareFloat * 45000.0))
	print('Average devcoins per share: %s' % almoner.getCommaNumberString(averageDevcoinsPerShare))
	print('Number of original receiver lines lines: %s' % originalReceiverLineLength)
	print('Number of receiver lines lines: %s' % len(originalReceiverLines))
	print('')
	return getCutLines(originalReceiverLines, suffixNumber)
Exemple #5
0
def getPackedReceiverLines(denominatorSequences, originalReceiverLines, suffixNumber):
	"""
	A devcoin round has 4,000 blocks, if there are more than 4,000 receiver lines, the lines after the four thousandth row will not get
	generation devcoins. To get devcoins to every line, the receiver lines are packed by the denominatorMultiplier:
	denominatorMultiplier = (len(originalReceiverLines) + maximumReceivers) / (maximumReceivers + 1 - len(denominatorSequences))

	The denominator in each denominator sequence is multiplied by the denominatorMultiplier. When the receiver lines are then generated by the
	denominator sequences, the column width of the line will be up to the denominator, in effect reducing the number of rows by the
	denominatorMultiplier and increasing the number of columns by the denominatorMultiplier.

	Because this changes the number of rows, the 'Average devcoins per share' is calculated from the original number of lines.
	"""
	maximumReceivers = 4000
	originalReceiverLineLength = len(originalReceiverLines)
	denominatorMultiplier = 1
	if len(originalReceiverLines) > maximumReceivers:
		denominatorMultiplier = (len(originalReceiverLines) + maximumReceivers) / (maximumReceivers + 1 - len(denominatorSequences))
		originalReceiverLines = getGroupedReceiverLines(denominatorMultiplier, denominatorSequences)
		if len(originalReceiverLines) > maximumReceivers:
			print('Warning, denominatorMultiplier math is wrong, the receiver lines will be grouped by another factor of two.')
			originalReceiverLines = getGroupedReceiverLines(2, denominatorSequences)
	originalDevcoinBlocksPerShareFloat = float(maximumReceivers) / originalReceiverLineLength
	averageDevcoinsPerShare = int(round(originalDevcoinBlocksPerShareFloat * 45000.0))
	print('Average devcoins per share: %s' % almoner.getCommaNumberString(averageDevcoinsPerShare))
	print('Number of original receiver lines lines: %s' % originalReceiverLineLength)
	print('Number of receiver lines lines: %s' % len(originalReceiverLines))
	print('')
	return getCutLines(originalReceiverLines, suffixNumber)
Exemple #6
0
def getSummaryText(earningsText, round, totalTomecount):
	'Get the summary text.'
	cString = cStringIO.StringIO()
	cString.write('The round %s devtome word earnings are pasted below and at:\n' % round)
	cString.write('https://raw.github.com/Unthinkingbit/charity/master/devtome_earnings_%s.csv\n\n' % round)
	cString.write('%s\n' % earningsText)
	cString.write('They are generated by devtome.py:\n')
	cString.write('https://raw.github.com/Unthinkingbit/charity/master/devtome.py\n\n')
	cString.write('The word counts for each writer are at:\n')
	cString.write('https://raw.github.com/Unthinkingbit/charity/master/devtome_%s.csv\n\n' % round)
	cString.write('The word earnings were generated on %s, and the total word counts follow below.\n\n' % date.today().isoformat())
	cString.write('Collated Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.collatedWordCount))
	cString.write('Collated Weighted Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.collatedWeightedWordCount))
	cString.write('Images: %s\n' % almoner.getCommaNumberString(totalTomecount.imageCount))
	cString.write('Original Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.originalWordCount))
	cString.write('Total Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.wordCount))
	cString.write('Total Weighted Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.weightedWordCount))
	return cString.getvalue()
Exemple #7
0
def getSummaryText(earningsText, round, totalTomecount):
	'Get the summary text.'
	cString = cStringIO.StringIO()
	cString.write('The round %s devtome word earnings are pasted below and at:\n' % round)
	cString.write('https://raw.github.com/devcoin/accounting/master/devtome_earnings_%s.csv\n\n' % round)
	cString.write('%s\n' % earningsText)
	cString.write('They are generated by devtome.py:\n')
	cString.write('https://raw.github.com/devcoin/accounting/master/devtome.py\n\n')
	cString.write('The word counts for each writer are at:\n')
	cString.write('https://raw.github.com/devcoin/accounting/master/devtome_%s.csv\n\n' % round)
	cString.write('The word earnings were generated on %s, and the total word counts follow below.\n\n' % date.today().isoformat())
	cString.write('Collated Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.collatedWordCount))
	cString.write('Collated Weighted Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.collatedWeightedWordCount))
	cString.write('Images: %s\n' % almoner.getCommaNumberString(totalTomecount.imageCount))
	cString.write('Original Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.originalWordCount))
	cString.write('Total Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.wordCount))
	cString.write('Total Weighted Word Count: %s\n' % almoner.getCommaNumberString(totalTomecount.weightedWordCount))
	return cString.getvalue()
Exemple #8
0
 def __init__(self, averageRating, backupFolder, backupFileSet,
              categoryDictionary, ratingDictionary, titles, viewDictionary,
              words):
     'Initialize.'
     self.backupFolder = backupFolder
     self.backupFileSet = backupFileSet
     identicalCollatedCount = 0
     identicalOriginalCount = 0
     self.newArticles = []
     self.tomecount = Tomecount()
     self.parameterDictionary = {}
     self.sentenceSet = set([])
     self.warnings = []
     for wordIndex, word in enumerate(words):
         self.parameterDictionary[titles[wordIndex]] = word
     if 'Cumulative Payout' in self.parameterDictionary:
         self.tomecount.previousPayout = int(
             self.parameterDictionary['Cumulative Payout'])
     self.name = self.parameterDictionary['Name']
     self.sourceAddress = 'http://devtome.com/doku.php?id=wiki:user:%s&do=edit' % self.name
     tipAddress = ''
     print('Loading articles from %s' % self.name)
     sourceText = almoner.getSourceText(self.sourceAddress)
     almoner.writeFileText(
         os.path.join(backupFolder, 'wiki:user:'******'==' in lineStrippedLower:
             if '===' not in lineStrippedLower:
                 isCollated = False
                 isOriginal = False
                 isTip = False
         if isCollated:
             linkName = getLinkName(line, self.name)
             underscoredLinkName = linkName.lower().replace(' ', '_')
             linkText = getSourceTextIfByAuthor(self, linkName)
             if linkName != '' and linkText == '':
                 self.printWarning(
                     'Warning, could not invoice article link: %s' %
                     linkName)
             if linkText not in linkTexts:
                 linkTexts.add(linkText)
                 self.tomecount.imageCount += getImageCount(linkText)
                 wordCount = getWordCount(linkText)
                 if underscoredLinkName in viewDictionary:
                     self.tomecount.pageViews += viewDictionary[
                         underscoredLinkName]
                 if wordCount > 0:
                     print('Collated article: %s, Word Count: %s' %
                           (lineStrippedLower,
                            almoner.getCommaNumberString(wordCount)))
                     self.saveArticle(categoryDictionary, linkName,
                                      linkText, underscoredLinkName)
                     identicalCollatedCount += self.getIdenticalWordCount(
                         linkText)
                     self.tomecount.collatedWordCount += wordCount
         if isOriginal:
             linkName = getLinkName(line, self.name)
             underscoredLinkName = linkName.lower().replace(' ', '_')
             linkText = getSourceTextIfByAuthor(self, linkName)
             if linkName != '' and linkText == '':
                 self.printWarning(
                     'Warning, could not invoice article link: %s' %
                     linkName)
             if linkText not in linkTexts:
                 linkTexts.add(linkText)
                 self.tomecount.imageCount += getImageCount(linkText)
                 wordCount = getWordCount(linkText)
                 if underscoredLinkName in viewDictionary:
                     self.tomecount.pageViews += viewDictionary[
                         underscoredLinkName]
                 if wordCount > 0:
                     print('Original article: %s, Word Count: %s' %
                           (lineStrippedLower,
                            almoner.getCommaNumberString(wordCount)))
                     self.saveArticle(categoryDictionary, linkName,
                                      linkText, underscoredLinkName)
                     identicalOriginalCount += self.getIdenticalWordCount(
                         linkText)
                     self.tomecount.originalWordCount += wordCount
         if isTip:
             tipLine = line.strip().replace("'", '')
             colonIndex = tipLine.find(':')
             if colonIndex >= 0:
                 addressName = tipLine[:colonIndex].strip().lower()
                 if 'dvc' in addressName or 'devcoin' in addressName or 'coin address' in addressName:
                     tipAddress = tipLine[colonIndex + 1:].strip()
         if '==' in lineStrippedLower:
             if 'collated' in lineStrippedLower:
                 isCollated = True
             elif 'original' in lineStrippedLower:
                 isOriginal = True
             elif 'tip' in lineStrippedLower:
                 isTip = True
     if identicalCollatedCount > 0:
         self.tomecount.collatedWeightedWordCount -= identicalCollatedCount
         print('Identical Collated Word Count: %s' %
               almoner.getCommaNumberString(identicalCollatedCount))
     if identicalOriginalCount > 0:
         self.tomecount.originalWordCount -= identicalOriginalCount
         print('Identical Original Word Count: %s' %
               almoner.getCommaNumberString(identicalOriginalCount))
     self.tomecount.collatedWeightedWordCount = self.tomecount.collatedWordCount * 3 / 10
     self.tomecount.wordCount = self.tomecount.collatedWordCount + self.tomecount.originalWordCount
     self.tomecount.weightedWordCount = self.tomecount.collatedWeightedWordCount + self.tomecount.originalWordCount
     self.tomecount.weightedWordCount += 10 * self.tomecount.imageCount
     if self.tomecount.weightedWordCount >= 1000:
         self.tomecount.cumulativePayout = int(
             round(float(self.tomecount.weightedWordCount) * 0.001))
     print('Weighted Word Count: %s' %
           almoner.getCommaNumberString(self.tomecount.weightedWordCount))
     self.tomecount.payout = max(
         self.tomecount.cumulativePayout - self.tomecount.previousPayout, 0)
     maximumPayout = 50
     if tipAddress != self.parameterDictionary[
             'Coin Address'] and self.name != 'Mosinnagant':
         self.printWarning(
             'Warning, the coin address is not the same as the tip address, so nothing will be paid.'
         )
         maximumPayout = 0
     if self.tomecount.payout > maximumPayout:
         self.tomecount.payout = maximumPayout
         self.tomecount.cumulativePayout = self.tomecount.previousPayout + maximumPayout
     if self.tomecount.cumulativePayout > 0:
         self.tomecount.categorization = float(
             self.tomecount.categorizedArticleCount) / float(
                 self.tomecount.articleCount)
         self.tomecount.ratingMedian = averageRating
         lowerName = self.name.lower()
         if lowerName in ratingDictionary:
             self.tomecount.ratingMedian = ratingDictionary[lowerName]
         weightedPageViews = self.tomecount.pageViews
         if self.tomecount.previousPayout == 0:
             weightedPageViews += weightedPageViews
         self.tomecount.viewsPerThousandWords = 1000.0 * float(
             weightedPageViews) / float(self.tomecount.weightedWordCount)
         self.tomecount.normalizedCategorization = self.tomecount.categorization
         self.tomecount.normalizedPopularity = self.tomecount.viewsPerThousandWords
         self.tomecount.normalizedRatingMedian = self.tomecount.ratingMedian
         self.tomecount.popularityTimesRating = int(
             round(self.tomecount.pageViews *
                   float(self.tomecount.ratingMedian) / 99.0))
Exemple #9
0
	def __init__(self, backupFolder, titles, viewDictionary, words):
		'Initialize.'
		self.tomecount = Tomecount()
		self.parameterDictionary = {}
		self.warnings = []
		for wordIndex, word in enumerate(words):
			self.parameterDictionary[titles[wordIndex]] = word
		if 'Cumulative Payout' in self.parameterDictionary:
			self.tomecount.previousPayout = int(self.parameterDictionary['Cumulative Payout'])
		self.name = self.parameterDictionary['Name']
		self.sourceAddress = 'http://devtome.com/doku.php?id=wiki:user:%s&do=edit' % self.name
		tipAddress = ''
		print('Loading articles from %s' % self.name)
		sourceText = getSourceText(self.sourceAddress)
		almoner.writeFileText(os.path.join(backupFolder, 'wiki:user:'******'==' in lineStrippedLower:
				isCollated = False
				isOriginal = False
				isTip = False
			if isCollated:
				lowerLinkName = getLinkName(line).lower()
				linkText = getLinkText(lowerLinkName, self.name)
				if linkText not in linkTexts:
					linkTexts.add(linkText)
					self.tomecount.imageCount += getImageCount(linkText)
					wordCount = getWordCount(linkText)
					self.tomecount.collatedWordCount += wordCount
					if lowerLinkName in viewDictionary:
						self.tomecount.pageViews += int(viewDictionary[lowerLinkName])
					if wordCount > 0:
						print('Collated article: %s, Word Count: %s' % (lineStrippedLower, almoner.getCommaNumberString(wordCount)))
						almoner.writeFileText(os.path.join(backupFolder, lowerLinkName), linkText)
			if isOriginal:
				lowerLinkName = getLinkName(line).lower()
				linkText = getLinkText(lowerLinkName, self.name)
				if lowerLinkName != '' and linkText == '':
					self.printWarning('Warning, could not invoice article link: %s' % lowerLinkName)
				if linkText not in linkTexts:
					linkTexts.add(linkText)
					self.tomecount.imageCount += getImageCount(linkText)
					wordCount = getWordCount(linkText)
					self.tomecount.originalWordCount += wordCount
					if lowerLinkName in viewDictionary:
						self.tomecount.pageViews += int(viewDictionary[lowerLinkName])
					if wordCount > 0:
						print('Original article: %s, Word Count: %s' % (lineStrippedLower, almoner.getCommaNumberString(wordCount)))
						almoner.writeFileText(os.path.join(backupFolder, lowerLinkName), linkText)
			if isTip:
				tipAddress = line.strip()
				if ':' in tipAddress:
					tipAddress = tipAddress[tipAddress.find(':') + 1 :].strip()
			if '==' in lineStrippedLower:
				if 'collated' in lineStrippedLower:
					isCollated = True
				elif 'original' in lineStrippedLower:
					isOriginal = True
				elif 'tip' in lineStrippedLower:
					isTip = True
		self.tomecount.collatedWeightedWordCount = self.tomecount.collatedWordCount * 3 / 10
		self.tomecount.wordCount = self.tomecount.collatedWordCount + self.tomecount.originalWordCount
		self.tomecount.weightedWordCount = self.tomecount.collatedWeightedWordCount + self.tomecount.originalWordCount
		self.tomecount.weightedWordCount += 10 * self.tomecount.imageCount
		if self.tomecount.weightedWordCount >= 1000:
			self.tomecount.cumulativePayout = int(round(float(self.tomecount.weightedWordCount) * 0.001))
		print('Weighted Word Count: %s' % almoner.getCommaNumberString(self.tomecount.weightedWordCount))
		self.tomecount.payout = max(self.tomecount.cumulativePayout - self.tomecount.previousPayout, 0)
		maximumPayout = 80
		if tipAddress != self.parameterDictionary['Coin Address'] and self.name != 'Mosinnagant':
			self.printWarning('Warning, the coin address is not the same as the tip address, so nothing will be paid.')
			maximumPayout = 0
		if self.tomecount.payout > maximumPayout:
			self.tomecount.payout = maximumPayout
			self.tomecount.cumulativePayout = self.tomecount.previousPayout + maximumPayout
		if self.tomecount.cumulativePayout > 0:
			worthRatio = float(self.tomecount.pageViews) / float(self.tomecount.weightedWordCount)
			self.tomecount.normalizedRootWorth = math.sqrt(math.sqrt(worthRatio))
Exemple #10
0
 def __init__(self, backupFolder, titles, words):
     'Initialize.'
     self.tomecount = Tomecount()
     self.parameterDictionary = {}
     for wordIndex, word in enumerate(words):
         self.parameterDictionary[titles[wordIndex]] = word
     if 'Cumulative Payout' in self.parameterDictionary:
         self.tomecount.previousPayout = int(
             self.parameterDictionary['Cumulative Payout'])
     name = self.parameterDictionary['Name']
     self.sourceAddress = 'http://devtome.com/doku.php?id=wiki:user:%s&do=edit' % name
     print('Loading articles from %s' % name)
     sourceText = getSourceText(self.sourceAddress)
     almoner.writeFileText(os.path.join(backupFolder, 'wiki:user:'******'==' in lineStrippedLower:
             isCollated = False
             isOriginal = False
             if 'collated' in lineStrippedLower:
                 isCollated = True
             elif 'original' in lineStrippedLower:
                 isOriginal = True
         if isCollated:
             linkText = getLinkText(lineStrippedLower)
             self.tomecount.imageCount += getImageCount(linkText)
             wordCount = getWordCount(linkText)
             self.tomecount.collatedWordCount += wordCount
             if wordCount > 0:
                 print('Collated article: %s, Word Count: %s' %
                       (lineStrippedLower,
                        almoner.getCommaNumberString(wordCount)))
                 almoner.writeFileText(
                     os.path.join(backupFolder,
                                  getLinkName(lineStrippedLower)[1:]),
                     linkText)
         if isOriginal:
             linkText = getLinkText(lineStrippedLower)
             self.tomecount.imageCount += getImageCount(linkText)
             wordCount = getWordCount(linkText)
             self.tomecount.originalWordCount += wordCount
             if wordCount > 0:
                 print('Original article: %s, Word Count: %s' %
                       (lineStrippedLower,
                        almoner.getCommaNumberString(wordCount)))
                 almoner.writeFileText(
                     os.path.join(backupFolder,
                                  getLinkName(lineStrippedLower)[1:]),
                     linkText)
     self.tomecount.collatedWeightedWordCount = self.tomecount.collatedWordCount * 3 / 10
     self.tomecount.wordCount = self.tomecount.collatedWordCount + self.tomecount.originalWordCount
     self.tomecount.weightedWordCount = self.tomecount.collatedWeightedWordCount + self.tomecount.originalWordCount
     self.tomecount.weightedWordCount += 10 * self.tomecount.imageCount
     if self.tomecount.weightedWordCount >= 1000:
         self.tomecount.cumulativePayout = int(
             round(float(self.tomecount.weightedWordCount) * 0.001))
     print('Weighted Word Count: %s' %
           almoner.getCommaNumberString(self.tomecount.weightedWordCount))
     self.tomecount.payout = max(
         self.tomecount.cumulativePayout - self.tomecount.previousPayout, 0)
     maximumPayout = 80
     if self.tomecount.payout > maximumPayout:
         self.tomecount.payout = maximumPayout
         self.tomecount.cumulativePayout = self.tomecount.previousPayout + maximumPayout
Exemple #11
0
	def __init__(self, averageRating, backupFolder, backupFileSet, categoryDictionary, ratingDictionary, titles, viewDictionary, words):
		'Initialize.'
		self.backupFolder = backupFolder
		self.backupFileSet = backupFileSet
		identicalCollatedCount = 0
		identicalOriginalCount = 0
		self.newArticles = []
		self.tomecount = Tomecount()
		self.parameterDictionary = {}
		self.sentenceSet = set([])
		self.warnings = []
		for wordIndex, word in enumerate(words):
			self.parameterDictionary[titles[wordIndex]] = word
		if 'Cumulative Payout' in self.parameterDictionary:
			self.tomecount.previousPayout = int(self.parameterDictionary['Cumulative Payout'])
		self.name = self.parameterDictionary['Name']
		self.sourceAddress = 'http://devtome.com/doku.php?id=wiki:user:%s&do=edit' % self.name
		tipAddress = ''
		print('Loading articles from %s' % self.name)
		sourceText = almoner.getSourceText(self.sourceAddress)
		almoner.writeFileText(os.path.join(backupFolder, 'wiki:user:'******'==' in lineStrippedLower:
				if '===' not in lineStrippedLower:
					isCollated = False
					isOriginal = False
					isTip = False
			if isCollated:
				linkName = getLinkName(line, self.name)
				underscoredLinkName = linkName.lower().replace(' ', '_')
				linkText = getSourceTextIfByAuthor(self, linkName)
				if linkName != '' and linkText == '':
					self.printWarning('Warning, could not invoice article link: %s' % linkName)
				if linkText not in linkTexts:
					linkTexts.add(linkText)
					self.tomecount.imageCount += getImageCount(linkText)
					wordCount = getWordCount(linkText)
					if underscoredLinkName in viewDictionary:
						self.tomecount.pageViews += viewDictionary[underscoredLinkName]
					if wordCount > 0:
						print('Collated article: %s, Word Count: %s' % (lineStrippedLower, almoner.getCommaNumberString(wordCount)))
						self.saveArticle(categoryDictionary, linkName, linkText, underscoredLinkName)
						identicalCollatedCount += self.getIdenticalWordCount(linkText)
						self.tomecount.collatedWordCount += wordCount
			if isOriginal:
				linkName = getLinkName(line, self.name)
				underscoredLinkName = linkName.lower().replace(' ', '_')
				linkText = getSourceTextIfByAuthor(self, linkName)
				if linkName != '' and linkText == '':
					self.printWarning('Warning, could not invoice article link: %s' % linkName)
				if linkText not in linkTexts:
					linkTexts.add(linkText)
					self.tomecount.imageCount += getImageCount(linkText)
					wordCount = getWordCount(linkText)
					if underscoredLinkName in viewDictionary:
						self.tomecount.pageViews += viewDictionary[underscoredLinkName]
					if wordCount > 0:
						print('Original article: %s, Word Count: %s' % (lineStrippedLower, almoner.getCommaNumberString(wordCount)))
						self.saveArticle(categoryDictionary, linkName, linkText, underscoredLinkName)
						identicalOriginalCount += self.getIdenticalWordCount(linkText)
						self.tomecount.originalWordCount += wordCount
			if isTip:
				tipLine = line.strip().replace("'", '')
				colonIndex = tipLine.find(':')
				if colonIndex >= 0:
					addressName = tipLine[: colonIndex].strip().lower()
					if 'dvc' in addressName or 'devcoin' in addressName or 'coin address' in addressName:
						tipAddress = tipLine[colonIndex + 1 :].strip()
			if '==' in lineStrippedLower:
				if 'collated' in lineStrippedLower:
					isCollated = True
				elif 'original' in lineStrippedLower:
					isOriginal = True
				elif 'tip' in lineStrippedLower:
					isTip = True
		if identicalCollatedCount > 0:
			self.tomecount.collatedWeightedWordCount -= identicalCollatedCount
			print('Identical Collated Word Count: %s' % almoner.getCommaNumberString(identicalCollatedCount))
		if identicalOriginalCount > 0:
			self.tomecount.originalWordCount -= identicalOriginalCount
			print('Identical Original Word Count: %s' % almoner.getCommaNumberString(identicalOriginalCount))
		self.tomecount.collatedWeightedWordCount = self.tomecount.collatedWordCount * 3 / 10
		self.tomecount.wordCount = self.tomecount.collatedWordCount + self.tomecount.originalWordCount
		self.tomecount.weightedWordCount = self.tomecount.collatedWeightedWordCount + self.tomecount.originalWordCount
		self.tomecount.weightedWordCount += 10 * self.tomecount.imageCount
		if self.tomecount.weightedWordCount >= 1000:
			self.tomecount.cumulativePayout = int(round(float(self.tomecount.weightedWordCount) * 0.001))
		print('Weighted Word Count: %s' % almoner.getCommaNumberString(self.tomecount.weightedWordCount))
		self.tomecount.payout = max(self.tomecount.cumulativePayout - self.tomecount.previousPayout, 0)
		maximumPayout = 50
		if tipAddress != self.parameterDictionary['Coin Address'] and self.name != 'Mosinnagant':
			self.printWarning('Warning, the coin address is not the same as the tip address, so nothing will be paid.')
			maximumPayout = 0
		if self.tomecount.payout > maximumPayout:
			self.tomecount.payout = maximumPayout
			self.tomecount.cumulativePayout = self.tomecount.previousPayout + maximumPayout
		if self.tomecount.cumulativePayout > 0:
			self.tomecount.categorization = float(self.tomecount.categorizedArticleCount) / float(self.tomecount.articleCount)
			self.tomecount.ratingMedian = averageRating
			lowerName = self.name.lower()
			if lowerName in ratingDictionary:
				self.tomecount.ratingMedian = ratingDictionary[lowerName]
			weightedPageViews = self.tomecount.pageViews
			if self.tomecount.previousPayout == 0:
				weightedPageViews += weightedPageViews
			self.tomecount.viewsPerThousandWords = 1000.0 * float(weightedPageViews) / float(self.tomecount.weightedWordCount)
			self.tomecount.normalizedCategorization = self.tomecount.categorization
			self.tomecount.normalizedPopularity = self.tomecount.viewsPerThousandWords
			self.tomecount.normalizedRatingMedian = self.tomecount.ratingMedian
			self.tomecount.popularityTimesRating = int(round(self.tomecount.pageViews * float(self.tomecount.ratingMedian) / 99.0))