Commits

Manabu TERADA  committed 8a18fb4

modify metadata backup but no comment

  • Participants
  • Parent commits 7282803

Comments (0)

Files changed (1)

File c2/recipe/bitbucketbk/backuprunner.py

 ISSUES_LOCATION = "issues"
 ISSUE_HEADERS = [u'local_id', u'title', u'status', u'priority', u'content', u'created_on',
                  u'utc_last_updated',
-                 #u'metadata', u'reported_by', u'responsible',
-                 #u'comment'
                  ]
-
+ISSUE_HEADERS_DICT = [u'metadata', u'reported_by', u'responsible']
+ISSUE_COMMENT = [u'comment']
 
 def _get_json_from_api(user, passwd, api_url):
     authString = base64.encodestring('%s:%s' % (user, passwd))
     repo = hg.repository(ui.ui(), location)
     commands.pull(ui.ui(), repo, source=repo_url)
 
+def _get_issue_comment(schema):
+    return ""
+
 def _save_excel_data(issues_folder_location, repo_name, issues):
     wb = xlwt.Workbook(encoding='utf-8')
     sheet1 = wb.add_sheet('issues')
-    headers = ISSUE_HEADERS
+    headers = ISSUE_HEADERS + ISSUE_HEADERS_DICT + ISSUE_COMMENT
     for i, head in enumerate(headers):
         sheet1.write(0, i, head)
     for i, issue in enumerate(issues):
-        print issue
         raw = i + 1
         for j, head in enumerate(headers):
-            sheet1.write(raw, j, issue.get(head))
+            if head in ISSUE_HEADERS:
+                sheet1.write(raw, j, issue.get(head))
+            elif head in ISSUE_HEADERS_DICT:
+                data = u"\n".join((u":".join((k, v)) for k, v in issue.get(head, {}).items() if v))
+                sheet1.write(raw, j, data)
+            elif head in ISSUE_COMMENT:
+                if issue.get('comment_count') > 0:
+                    data = _get_issue_comment(head)
+                    sheet1.write(raw, j, data)
     with open(os.path.join(issues_folder_location, repo_name + ".xls"), 'wb') as f:
         wb.save(f)