def do_add( self, args ): """ add an issue bgz add [type] where type is: (b)ug | (t)ask | (f)eature """ self._check_status() # default type if len(args) < 1: args = ['bug'] if len(args) and args[0][0] in Issue.types.keys() or args[0][0] == 'p': type = args[0][0] else: type = self._read_input( 'Type: (b)ug, (f)eature, (t)ask | (p)roject?', 'b', ('b','t','f','p')) if type =='p': self._add_project( self.BGZ_DIR ) return print 'Adding new ' + Issue.types[type].lower() title = self._read_input('Title') author = self._read_input('Author',self.opts['user.name']) #desc = self._read_multiline('Descr') desc = self._external_edit('\n\n### ' + title ) issue = Issue( self.BGZ_DIR ) issue['Title'] = title issue['Description'] = desc issue['Type'] = type issue['Author'] = author issue.save() self._log( 'Added: ' + str(issue) )
def _find_issue( self, uid ): """ find an issue with a partial uid """ if uid.startswith('g'): if not os.path.exists(os.path.join(self.BGZ_DIR,'general.' + self.opts['user.name'])): gen = Issue(self.BGZ_DIR) gen['Id'] = 'general.' + self.opts['user.name'] gen['Title'] = 'General Project Catchall' gen['Author'] = self.opts['user.name'] gen['Type'] = 'task' gen['Status'] = 'open' gen.save() flist = self._find_issues( uid ) if len(flist) == 1: iss = Issue(self.BGZ_DIR) if not iss.load( flist[0] ): return None return iss elif len(flist) > 1: print 'Please be more specific: ' for f in flist: print f return None