<commit_before>import requests
import csv
import sys


class Repodata(object):

	def __init__(self):
		self.api_url = 'https://' + domain + '/rest/api/1.0/projects/' + project_key
		# start page for inital data load at 0
		self.page_range = [0]
		self.repodata = {}

	def main(self):
		# Counter for bitbucket's pageing setup.. Grabs the nextPageStart number and adds it to list...
		for page_num in self.page_range:
			call = requests.get(self.api_url + '/repos?start={}'.format(page_num), auth=(username, password)).json()
			for repo in call['values']:
				print(repo)
				self.repodata[repo['name']]=repo['public']
				with open('data.csv', 'w') as csvfile:
					fieldnames = ['repo name', 'public']
					writer = csv.DictWriter(csvfile, fieldnames)
					writer.writeheader()
					for key, value in self.repodata.items():
						writer.writerow({'repo name': key, 'public': value})

			## If we hit the last page end the loop for appending to page_range value.
			if call['isLastPage'] is False:
				self.page_range.append(call['nextPageStart'])
			break


args = {}
for item in sys.argv[1:]:
	key, val = item.split('=')
	args[key] = val

domain=args['domain']
project_key = args['project_key']
username = args['username']
password = args['password']
if __name__ == '__main__':
	start = Repodata()
	start.main()

<commit_msg>fixed spelling and typos, Fixed DictWriter source for key, value. setup a proper init to make this modular and callable from another program or from command line as source..<commit_after>import requests
import csv
import sys

# Primary work data class that's callable if used in module format.
class Repodata(object):
	# initializes variables to zero and sets the proper project URL
	def __init__(self):
		self.api_url = 'https://' + domain + '/rest/api/1.0/projects/' + project_key
		# start page for inital data load at 0
		self.page_range = [0]
		self.repodata = {}

# does the pagination calls to retrieve all data for repos including nextpage to the next list.
	def main(self):
		# Counter for bitbucket's paging setup.. Grabs the nextPageStart number and adds it to list...
		for page_num in self.page_range:
			call = requests.get(self.api_url + '/repos?start={}'.format(page_num), auth=(username, password)).json()
			for repo in call['values']:
				# sets only the data I need, repo name and public status
				self.repodata[repo['name']]=repo['public']
				# writes out the CVS file
				with open('data.csv', 'w') as csvfile:
					fieldnames = ['repo name', 'public']
					writer = csv.DictWriter(csvfile, fieldnames)
					writer.writeheader()
					#Pairs the Dictonary items into seperate namespaces
					for key, value in self.repodata.items():
						writer.writerow({'repo name': key, 'public': value})

			## If we hit the last page end the loop for appending to page_range value.
			if call['isLastPage'] is False:
				self.page_range.append(call['nextPageStart'])
			break

# setup for called as direct source and not as module
if __name__ == '__main__':
	args = {}
	for item in sys.argv[1:]:
		key, val = item.split('=')
		args[key] = val

	domain = args['domain']
	project_key = args['project_key']
	username = args['username']
	password = args['password']
	Repodata().main()


{'fraction_non_alphanumeric': 0.1281812538795779, 'fraction_numerical': 0.0031036623215394167, 'mean_word_length': 3.9432515337423313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '236371', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1010, 'n_words': 342}