コード例 #1
0
ファイル: test_utils.py プロジェクト: ZigZg/spectrometer
    def test_format_text_split_long_link(self):
        original = ('https://blueprints.launchpad.net/stackalytics/+spec/'
                    'stackalytics-core')
        expected = ('https://​blueprints.launchpad.net/​'
                    'stackalytics/​+spec/​stackalytics-core')

        self.assertEqual(expected, utils.format_text(original))
コード例 #2
0
    def test_format_text_split_long_link(self):
        original = ('https://blueprints.launchpad.net/stackalytics/+spec/'
                    'stackalytics-core')
        expected = ('https://​blueprints.launchpad.net/​'
                    'stackalytics/​+spec/​stackalytics-core')

        self.assertEqual(expected, utils.format_text(original))
コード例 #3
0
ファイル: helpers.py プロジェクト: ZigZg/spectrometer
def make_commit_message(record):
    s = record['message']
    module = record['module']

    s = utils.format_text(s)

    # insert links
    s = re.sub(re.compile('(blueprint\s+)([\w-]+)', flags=re.IGNORECASE),
               r'\1<a href="https://blueprints.launchpad.net/' +
               module + r'/+spec/\2" class="ext_link">\2</a>', s)
    s = re.sub(re.compile('(bug[\s#:]*)([\d]{5,7})', flags=re.IGNORECASE),
               r'\1<a href="https://bugs.launchpad.net/bugs/\2" '
               r'class="ext_link">\2</a>', s)
    s = re.sub(r'\s+(I[0-9a-f]{40})',
               r' <a href="https://git.opendaylight.org/gerrit/#q,\1,n,z" '
               r'class="ext_link">\1</a>', s)

    s = utils.unwrap_text(s)
    return s
コード例 #4
0
ファイル: helpers.py プロジェクト: tnadeau/spectrometer
def make_commit_message(record):
    s = record['message']
    module = record['module']

    s = utils.format_text(s)

    # insert links
    s = re.sub(
        re.compile('(blueprint\s+)([\w-]+)', flags=re.IGNORECASE),
        r'\1<a href="https://blueprints.launchpad.net/' + module +
        r'/+spec/\2" class="ext_link">\2</a>', s)
    s = re.sub(
        re.compile('(bug[\s#:]*)([\d]{5,7})', flags=re.IGNORECASE),
        r'\1<a href="https://bugs.launchpad.net/bugs/\2" '
        r'class="ext_link">\2</a>', s)
    s = re.sub(
        r'\s+(I[0-9a-f]{40})',
        r' <a href="https://git.opendaylight.org/gerrit/#q,\1,n,z" '
        r'class="ext_link">\1</a>', s)

    s = utils.unwrap_text(s)
    return s
コード例 #5
0
ファイル: helpers.py プロジェクト: tnadeau/spectrometer
def extend_record(record):
    record = vault.extend_record(record)
    _extend_record_common_fields(record)

    if record['record_type'] == 'commit':
        record['branches'] = ','.join(record['branches'])
        if 'correction_comment' not in record:
            record['correction_comment'] = ''
        record['message'] = make_commit_message(record)
        if record['commit_date']:
            record['commit_date_str'] = format_datetime(record['commit_date'])
    elif record['record_type'] == 'mark':
        parent = vault.get_memory_storage().get_record_by_primary_key(
            record['review_id'])
        if not parent:
            return None

        _extend_by_parent_info(record, parent)
    elif record['record_type'] == 'patch':
        parent = vault.get_memory_storage().get_record_by_primary_key(
            record['review_id'])
        _extend_by_parent_info(record, parent)
    elif record['record_type'] == 'email':
        record['email_link'] = record.get('email_link') or ''
        record['blueprint_links'] = []
        for bp_id in record.get('blueprint_id', []):
            bp_module, bp_name = bp_id.split(':')
            record['blueprint_links'].append(
                make_blueprint_link(bp_module, bp_name))
    elif record['record_type'] in ['bpd', 'bpc']:
        record['summary'] = utils.format_text(record['summary'])
        if record.get('mention_count'):
            record['mention_date_str'] = format_datetime(
                record['mention_date'])
        record['blueprint_link'] = make_blueprint_link(record['module'],
                                                       record['name'])

    return record
コード例 #6
0
ファイル: helpers.py プロジェクト: ZigZg/spectrometer
def extend_record(record):
    record = vault.extend_record(record)
    _extend_record_common_fields(record)

    if record['record_type'] == 'commit':
        record['branches'] = ','.join(record['branches'])
        if 'correction_comment' not in record:
            record['correction_comment'] = ''
        record['message'] = make_commit_message(record)
        if record['commit_date']:
            record['commit_date_str'] = format_datetime(record['commit_date'])
    elif record['record_type'] == 'mark':
        parent = vault.get_memory_storage().get_record_by_primary_key(
            record['review_id'])
        if not parent:
            return None

        _extend_by_parent_info(record, parent)
    elif record['record_type'] == 'patch':
        parent = vault.get_memory_storage().get_record_by_primary_key(
            record['review_id'])
        _extend_by_parent_info(record, parent)
    elif record['record_type'] == 'email':
        record['email_link'] = record.get('email_link') or ''
        record['blueprint_links'] = []
        for bp_id in record.get('blueprint_id', []):
            bp_module, bp_name = bp_id.split(':')
            record['blueprint_links'].append(
                make_blueprint_link(bp_module, bp_name))
    elif record['record_type'] in ['bpd', 'bpc']:
        record['summary'] = utils.format_text(record['summary'])
        if record.get('mention_count'):
            record['mention_date_str'] = format_datetime(
                record['mention_date'])
        record['blueprint_link'] = make_blueprint_link(record['module'],
                                                       record['name'])

    return record