def decode_subject_text(subject): ret = { 'n': 1, 'm': 1, 'version': 1, 'patch': False, 'rfc': False } patch_tags = [] while len(subject) and subject[0] == '[': bracket, subject = find_and_split(subject[1:], ']') subject = subject.lstrip() if bracket: words = map(unicode.upper, bracket.split(' ')) for word in words: if not word: continue if word.startswith('PATCH') and word != 'PATCH': # It's pretty common for people to do PATCHv2 or # other silly things. Try our best to handle that. word = word[5:] ret['patch'] = True index = word.find('/') if index != -1 and is_digit(word[0]) and is_digit(word[index + 1]): try: ret['n'], ret['m'] = map(int, word.split('/', 1)) except ValueError: pass elif word[0] == 'V' and is_digit(word[1]): try: ret['version'] = int(word[1:]) except Exception, e: pass elif word.startswith('FOR-') and is_digit(word[4]): ret['for-release'] = word[4:] elif is_digit(word[0]) and word.find('.') != -1: ret['for-release'] = word elif word in ['RFC', '/RFC']: ret['rfc'] = True elif word in ['PATCH']: ret['patch'] = True elif word in ['PULL']: ret['pull-request'] = True ret['patch'] = True elif word == config.get_list_tag().upper(): pass else: patch_tags.append(word)
def decode_subject_text(subject): ret = {"n": 1, "m": 1, "version": 1, "patch": False, "rfc": False} patch_tags = [] while len(subject) and subject[0] == "[": bracket, subject = find_and_split(subject[1:], "]") subject = subject.lstrip() if bracket: words = map(unicode.upper, bracket.split(" ")) for word in words: if not word: continue if word.startswith("PATCH") and word != "PATCH": # It's pretty common for people to do PATCHv2 or # other silly things. Try our best to handle that. word = word[5:] ret["patch"] = True index = word.find("/") if index != -1 and is_digit(word[0]) and is_digit(word[index + 1]): ret["n"], ret["m"] = map(int, word.split("/", 1)) elif word[0] == "V" and is_digit(word[1]): try: ret["version"] = int(word[1:]) except Exception, e: pass elif word.startswith("FOR-") and is_digit(word[4]): ret["for-release"] = word[4:] elif is_digit(word[0]) and word.find(".") != -1: ret["for-release"] = word elif word in ["RFC", "/RFC"]: ret["rfc"] = True elif word in ["PATCH"]: ret["patch"] = True elif word in ["PULL"]: ret["pull-request"] = True ret["patch"] = True elif word == config.get_list_tag().upper(): pass else: patch_tags.append(word)
def get_subject(msg): list_tag = u'[%s] ' % config.get_list_tag(); subject = get_header(msg, 'Subject') if subject.startswith(list_tag): subject = subject[len(list_tag):].strip() return subject
def get_subject(msg): list_tag = u"[%s] " % config.get_list_tag() subject = get_header(msg, "Subject") if subject.startswith(list_tag): subject = subject[len(list_tag) :].strip() return subject