def revision_info(self, revision): revision = str(revision) tree = self.svn("log", "-r", revision) author = tree.find(".//author").text comment = text.strip(tree.find(".//msg").text, truncate=True) url = self.changeset_url(revision) return (revision, author, comment, url)
def parse(self, entry): m = re.search(r'^(.*/([0-9]+))', entry.id) if not m: log.error("bad entry, %s" % (entry.id, )) return None url = m.group(1) issue = int(m.group(2)) author = text.abbrevs(entry.author_detail.name) assignments = [] details = entry.content[0].value assignment_phrases = [ r"""(?x) (?P<property> [^,>]+ ) \s set \s to \s (?P<value> [^,<]+ \w ) """, r"""(?x) (?P<property> [^,>]+ ) \s changed \s from \s (?P<previous_value> [^,<]+ ) \s to \s (?P<value> [^,<]+ \w ) """, ] for pattern in assignment_phrases: for m in re.finditer(pattern, details): normal_form = None date_re = r'\d{4}/\d{2}/\d{2}|\(not set\)' if re.match(date_re, m.group('value')): pass elif re.match(r'Planning - Sprint', m.group('property')): n = re.search(r'(Sprint \d+)', m.group('value')) if n: normal_form = "->" + n.group(1) elif 'Deployed' == m.group('value'): normal_form = "*Deployed*" else: normal_form = text.abbrevs("{prop} : {value}".format( prop=m.group('property'), value=m.group('value') )) if normal_form: assignments.append(normal_form) summary = '|'.join(assignments) assignment_re = r'(?P<property>[^:>]+): (?P<value>[^<]+)' for m in re.finditer(assignment_re, details): if m.group('property') == 'Comment added': summary = m.group('value')+" "+summary for m in re.finditer(r'Description changed', details): summary += " " + m.group(0) summary = text.strip(summary, truncate=True) if summary: return "#%d: (%s) %s -- %s" % (issue, author, summary, url)
def parse(self, entry): m = re.search(r'(CRM-[0-9]+)$', entry.link) if (not m) or (entry.generator_detail.href != self.base_url): return issue = m.group(1) if 'content' in entry: details = entry.content[0].value assignment_phrases = [ r"Changed the (?P<property>[^']+) to '(?P<value>[^']+)'", r"Added the (?P<property>[^']+) '(?P<value>[^']+)'", r"Removed the (?P<property>[^']+) '(?P<previous_value>[^']+)'", ] assignments = dict() to_strip = [] for pattern in assignment_phrases: for m in re.finditer(pattern, details): # if 'previous_value' in m.groupdict(): # normal_form = "%s:%s->%s" % # (text.abbrevs(m.group('property')), # m.group("previous_value"), m.group('value')) # else: if 'value' in m.groupdict(): prop = text.abbrevs(m.group('property')) assignments[prop] = m.group('value') to_strip.append(m.group(0)) revs = set() for m in re.finditer(r'r=(\d+)', details): revs.add(", r"+m.group(1)) pairs = ["%s:%s" % (k, v) for k, v in assignments.items()] normal_form_assignments = "|".join(pairs) for p in to_strip: details = details.replace(p, "") summary = "{assignments} {revs} {details}".format( assignments=normal_form_assignments, revs="".join(revs), details=details ) else: summary = entry.summary summary = text.strip(summary, truncate=True) url = "%s/browse/%s" % (self.base_url, issue) return "%s: %s %s -- %s" % (entry.usr_username, issue, summary, url)
def process(self): self.clearCheckResult() self.clearResults() text = self.query.getText() query = text.strip() if query: self.query.setCursorPos(len(text)) self.goButton.setEnabled(False) checkWidget = results.ResultHandler(query, self, self.tabName, titleMaker) remote = server.TickeryService() f = getattr(remote, self.goButtonRemoteMethod) id = f(self.topPanel.loginPanel.oauthCookie, self.tabName, query, checkWidget) if id < 0: self.checkResult.add(Label("oops!", StyleName="userlist-error-title")) else: self.checkResult.add(Label("Try a non-empty query!", StyleName="userlist-error-title"))
def parse(self, entry): m = re.search(r'^(.*/([0-9]+))', entry.id) if not m: print "bad entry, %s" % (entry.id, ) return None url = m.group(1) issue = int(m.group(2)) author = text.abbrevs(entry.author_detail.name) assignments = [] details = entry.content[0].value assignment_phrases = [ r'(?P<property>[^,>]+) set to (?P<value>[^,<]+\w)', r'(?P<property>[^,>]+) changed from (?P<previous_value>[^,<]+) to (?P<value>[^,<]+\w)', ] for pattern in assignment_phrases: for m in re.finditer(pattern, details): normal_form = None if re.match(r'\d{4}/\d{2}/\d{2}|\(not set\)', m.group('value')): pass elif re.match(r'Planning - Sprint', m.group('property')): n = re.search(r'(Sprint \d+)', m.group('value')) if n: normal_form = "->" + n.group(1) elif 'Deployed' == m.group('value'): normal_form = "*Deployed*" else: normal_form = text.abbrevs( m.group('property') + " : " + m.group('value')) if normal_form: assignments.append(normal_form) summary = '|'.join(assignments) for m in re.finditer(r'(?P<property>[^:>]+): (?P<value>[^<]+)', details): if m.group('property') == 'Comment added': summary = m.group('value') + " " + summary for m in re.finditer(r'Description changed', details): summary += " " + m.group(0) summary = text.strip(summary, truncate=True) if summary: return "#%d: (%s) %s -- %s" % (issue, author, summary, url)
def parse(self, entry): m = re.search(r'(CRM-[0-9]+)$', entry.link) if (not m) or (entry.generator_detail.href != self.base_url): return issue = m.group(1) if 'content' in entry: details = entry.content[0].value assignment_phrases = [ r"Changed the (?P<property>[^']+) to '(?P<value>[^']+)'", r"Added the (?P<property>[^']+) '(?P<value>[^']+)'", r"Removed the (?P<property>[^']+) '(?P<previous_value>[^']+)'", ] assignments = dict() to_strip = [] for pattern in assignment_phrases: for m in re.finditer(pattern, details): #if 'previous_value' in m.groupdict(): # normal_form = "%s:%s->%s" % (text.abbrevs(m.group('property')), m.group("previous_value"), m.group('value')) #else: if 'value' in m.groupdict(): assignments[text.abbrevs( m.group('property'))] = m.group('value') to_strip.append(m.group(0)) revs = set() for m in re.finditer(r'r=(\d+)', details): revs.add(", r" + m.group(1)) normal_form_assignments = "|".join( ["%s:%s" % (k, v) for k, v in assignments.items()]) for p in to_strip: details = details.replace(p, "") summary = "%s %s %s" % (normal_form_assignments, "".join(revs), details) else: summary = entry.summary summary = text.strip(summary, truncate=True) url = "%s/browse/%s" % (self.base_url, issue) return "%s: %s %s -- %s" % (entry.usr_username, issue, summary, url)
def parse(self, entry): m = re.search(r"^(.*/([0-9]+))", entry.id) if not m: print "bad entry, %s" % (entry.id,) return None url = m.group(1) issue = int(m.group(2)) author = text.abbrevs(entry.author_detail.name) assignments = [] details = entry.content[0].value assignment_phrases = [ r"(?P<property>[^,>]+) set to (?P<value>[^,<]+\w)", r"(?P<property>[^,>]+) changed from (?P<previous_value>[^,<]+) to (?P<value>[^,<]+\w)", ] for pattern in assignment_phrases: for m in re.finditer(pattern, details): normal_form = None if re.match(r"\d{4}/\d{2}/\d{2}|\(not set\)", m.group("value")): pass elif re.match(r"Planning - Sprint", m.group("property")): n = re.search(r"(Sprint \d+)", m.group("value")) if n: normal_form = "->" + n.group(1) elif "Deployed" == m.group("value"): normal_form = "*Deployed*" else: normal_form = text.abbrevs(m.group("property") + " : " + m.group("value")) if normal_form: assignments.append(normal_form) summary = "|".join(assignments) for m in re.finditer(r"(?P<property>[^:>]+): (?P<value>[^<]+)", details): if m.group("property") == "Comment added": summary = m.group("value") + " " + summary for m in re.finditer(r"Description changed", details): summary += " " + m.group(0) summary = text.strip(summary, truncate=True) if summary: return "#%d: (%s) %s -- %s" % (issue, author, summary, url)
def parse_text(text): text = text.strip(" ") return GracefulList(text.lower().replace("\\", "").replace("\n", " ").split(" "))