bugzilla_bitbucket / create_issues.py

# read in the xml, and create the issues.
issues API:

	    title: The title of the new issue.
	    content: The content of the new issue.
	    component: The component associated with the issue.
	    milestone: The milestone associated with the issue.
	    version: The version associated with the issue.
	    responsible: The username of the person responsible for the issue.
	    status: The status of the issue (new, open, resolved, on hold, invalid, duplicate, or wontfix).
	    kind: The kind of issue (bug, enhancement, or proposal).

How to delete an issue:
	curl X DELETE https://api.bitbucket.org/1.0/repositories/pygame/pygame/issues/3

Add --user username:password afterwards to authenticate, otherwise it does not work.


import os,sys,urllib

issue_keys = "title content component milestone version responsible status kind".split()
valid_status = "new open resolved hold invalid duplicate wontfix".split()
valid_kind = "bug enhancement proposal".split()

def validate_issue(issue):
	for k in issue_keys:
		if k not in issue:
			raise ValueError("%s not in issue" % k)
	if issue.get('status') not in valid_status:
		raise ValueError(":%s: status is not one of %s" % (issue.get('status'), valid_status))
	if issue.get('kind') not in valid_kind:
		raise ValueError(":%s: kind is not one of %s" % (issue.get('kind'), valid_kind))

def create_issue(issue):

	# create http post data from issue
	issue_data = urllib.urlencode(issue)
	return issue_data

def test_create_issue():
	i = dict(title="just a test issue", content="some content to test", component="pygameissues", milestone="bitbucketmigration", version="1.9.2", responsible="illume", status="new", kind="bug")
	print create_issue(i)

# read bugzilla xml data.

#convert the bugzilla data to an issue.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.