Exemplo n.º 1
0
 def test_accountFileLoads(self):
   actualAccountMaps = funcs.readAccountsFile("accounts_mock.txt")
   expectedAccountMaps = [
     {'bnet': '1234567/1/FirstTester/', 'region': 'EU', 'redditName': 'redditguy1'},
     {'bnet': '2345678/1/SecondTester/', 'region': 'AM', 'redditName': 'redditguy2'}
   ]
   self.assertEqual(actualAccountMaps, expectedAccountMaps)
Exemplo n.º 2
0
import praw
import re

import settings as settings
import funcs

allAccountMaps = funcs.readAccountsFile("accounts.txt")

r = praw.Reddit(user_agent='ATZ flair script! Pipe Battle.Net data to Reddit')
r.login(settings.reddituser, settings.redditpass, disable_warning=True)
subreddit = r.get_subreddit("AllThingsZerg")

def runBatch(accountMaps):
  def getCurrentLeagueForAccountMap(accountMap):
    def getLeagueForRedditUser(redditName):
      return r.get_flair(subreddit, redditName)
    return getLeagueForRedditUser(accountMap['redditName'])

  currentLeagues = map(getCurrentLeagueForAccountMap, accountMaps)

  print '\ncurrentLeagues'
  print currentLeagues

  def getNewLeagueForAccountMap(accountMap):
    league = funcs.getLeague(settings.regions[accountMap['region']], accountMap['bnet'])
    return (accountMap['redditName'], league)

  newLeagues = map(getNewLeagueForAccountMap, accountMaps)
  zipped = zip(accountMaps, currentLeagues, newLeagues)

  print '\nzipped'
import praw
import re

import settings as settings
import funcs

allAccountMaps = funcs.readAccountsFile('accounts.txt')

r = funcs.GetPraw()
subreddit = r.subreddit('AllThingsZerg')

def accountRowToWiki(accountRow):
  return '    ' + accountRow['bnet'] + ',' + accountRow['redditName'] + ',' + accountRow['region']

wikiContent = '\n'.join(map(accountRowToWiki, allAccountMaps))

subreddit.wiki['flairlist'].edit(wikiContent, 'beep boop - backing up account data')