release-tools/lp-tag.py
Ihar Hrachyshka d15e2b8901 lp-tag.py: be prepared for empty lines in input
Change-Id: Ife608108c22c38fe9913a5ed6095d643832cbd12
2017-06-13 14:55:09 -07:00

50 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
This Launchpad tool is used to tag bugs with a tag.
"""
import argparse
import sys
from launchpadlib.launchpad import Launchpad
def _parse_args():
parser = argparse.ArgumentParser(
description='Tag tags with a tag.')
parser.add_argument(
'tag', help='Tag to use')
return parser.parse_args()
def main():
args = _parse_args()
lp = Launchpad.login_with('openstack-releasing', 'production')
bugnums = [line.strip() for line in sys.stdin.readlines()]
for bugnum in bugnums:
if bugnum:
bug = lp.bugs[bugnum]
tag = args.tag
tags = bug.tags
if tag not in tags:
tags.append(tag)
bug.tags = tags
bug.lp_save()
if __name__ == '__main__':
main()