<commit_before>import praw
import json
import HTMLParser
import requests
from config import username, password, subreddit

def wikilog(r, subreddit, wikipage, error):
	r.edit_wiki_page(subreddit, wikipage, error, error)

if __name__ == "__main__":
	r = praw.Reddit("Twitch.tv sidebar bot for {} by /u/andygmb".format(subreddit))
	r.login(username=username, password=password)
	sub = r.get_subreddit(subreddit)

	with open("default_wiki_config.json", "r") as configjson:
		try:
			config = json.load(configjson)
		except ValueError:
			print "Invalid JSON in local file: default_wiki_config.json"
			wikilog(r, sub, "twitchbot_error_log", "Invalid JSON in local file: default_wiki_config.json")

	try:
		r.edit_wiki_page(
			sub, 
			"twitchbot_config", 
			json.dumps(config, indent=4), 
			"Initial commit from setup.py with default config values"
			)
	except requests.exceptions.HTTPError:
		print "Couldn't access wiki page, reddit may be down."
		wikilog(r, sub, config["wikipages"]["error_log"], "Couldn't access wiki page, reddit may be down.")<commit_msg>changing wikipages to use a loop<commit_after>import praw
import json
import HTMLParser
import requests
from config import username, password, subreddit

def wikilog(r, subreddit, wikipage, error):
	r.edit_wiki_page(subreddit, wikipage, error, error)

if __name__ == "__main__":
	r = praw.Reddit("Twitch.tv sidebar bot for {} by /u/andygmb".format(subreddit))
	r.login(username=username, password=password)
	sub = r.get_subreddit(subreddit)

	with open("default_wiki_config.json", "r") as configjson:
		try:
			config = json.load(configjson)
		except ValueError:
			print "Invalid JSON in local file: default_wiki_config.json"
			wikilog(r, sub, "twitchbot_error_log", "Invalid JSON in local file: default_wiki_config.json")

	try:
		r.edit_wiki_page(sub, "twitchbot_config", json.dumps(config, indent=4), "Initial setup from setup.py")
	except requests.exceptions.HTTPError:
		print "Couldn't access /wiki/{}, reddit may be down.".format("twitchbot_config")
		wikilog(r, sub, config["wikipages"]["error_log"], "Couldn't access wiki page, reddit may be down.")

	for wikipage in config["wikipages"].values():
		try:
			r.edit_wiki_page(sub, wikipage, " ", "Initial setup from setup.py")

	except requests.exceptions.HTTPError:
		print "Couldn't access /wiki/{}, reddit may be down.".format(wikipage)
		wikilog(r, sub, wikipage, "Couldn't access wiki page, reddit may be down.")
{'fraction_non_alphanumeric': 0.11967213114754098, 'fraction_numerical': 0.000819672131147541, 'mean_word_length': 5.3733681462141, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5667190', 'n_tokens_mistral': 868, 'n_tokens_neox': 844, 'n_words': 228}