mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-12 02:04:04 +02:00
- support new history including review history of OBS 2.6
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,5 +1,5 @@
|
|||||||
0.148
|
0.148
|
||||||
-
|
- support new history including review history of OBS 2.6
|
||||||
|
|
||||||
0.147
|
0.147
|
||||||
- support groups in maintainership requests
|
- support groups in maintainership requests
|
||||||
|
39
osc/core.py
39
osc/core.py
@@ -2401,6 +2401,31 @@ class ReviewState(AbstractState):
|
|||||||
return self.comment
|
return self.comment
|
||||||
|
|
||||||
|
|
||||||
|
class RequestHistory(AbstractState):
|
||||||
|
"""Represents a history element of a request"""
|
||||||
|
def __init__(self, history_node):
|
||||||
|
AbstractState.__init__(self, history_node.tag)
|
||||||
|
self.who = history_node.get('who')
|
||||||
|
self.when = history_node.get('when')
|
||||||
|
if not history_node.find('description') is None and \
|
||||||
|
history_node.find('description').text:
|
||||||
|
# OBS 2.6
|
||||||
|
self.description = history_node.find('description').text.strip()
|
||||||
|
else:
|
||||||
|
# OBS 2.5 and before
|
||||||
|
self.description = history_node.get('name')
|
||||||
|
self.comment = ''
|
||||||
|
if not history_node.find('comment') is None and \
|
||||||
|
history_node.find('comment').text:
|
||||||
|
self.comment = history_node.find('comment').text.strip()
|
||||||
|
|
||||||
|
def get_node_attrs(self):
|
||||||
|
return ('who', 'when', 'description')
|
||||||
|
|
||||||
|
def get_comment(self):
|
||||||
|
return self.comment
|
||||||
|
|
||||||
|
|
||||||
class RequestState(AbstractState):
|
class RequestState(AbstractState):
|
||||||
"""Represents the state of a request"""
|
"""Represents the state of a request"""
|
||||||
def __init__(self, state_node):
|
def __init__(self, state_node):
|
||||||
@@ -2411,6 +2436,9 @@ class RequestState(AbstractState):
|
|||||||
self.name = state_node.get('name')
|
self.name = state_node.get('name')
|
||||||
self.who = state_node.get('who')
|
self.who = state_node.get('who')
|
||||||
self.when = state_node.get('when')
|
self.when = state_node.get('when')
|
||||||
|
if state_node.find('description') is None:
|
||||||
|
# OBS 2.6 has it always, before it did not exist
|
||||||
|
self.description = state_node.get('description')
|
||||||
self.comment = ''
|
self.comment = ''
|
||||||
if not state_node.find('comment') is None and \
|
if not state_node.find('comment') is None and \
|
||||||
state_node.find('comment').text:
|
state_node.find('comment').text:
|
||||||
@@ -2578,8 +2606,8 @@ class Request:
|
|||||||
self.actions.append(Action.from_xml(action))
|
self.actions.append(Action.from_xml(action))
|
||||||
for review in root.findall('review'):
|
for review in root.findall('review'):
|
||||||
self.reviews.append(ReviewState(review))
|
self.reviews.append(ReviewState(review))
|
||||||
for hist_state in root.findall('history'):
|
for history_element in root.findall('history'):
|
||||||
self.statehistory.append(RequestState(hist_state))
|
self.statehistory.append(RequestHistory(history_element))
|
||||||
if not root.find('accept_at') is None and root.find('accept_at').text:
|
if not root.find('accept_at') is None and root.find('accept_at').text:
|
||||||
self.accept_at = root.find('accept_at').text.strip()
|
self.accept_at = root.find('accept_at').text.strip()
|
||||||
if not root.find('title') is None:
|
if not root.find('title') is None:
|
||||||
@@ -2802,11 +2830,10 @@ class Request:
|
|||||||
if reviews:
|
if reviews:
|
||||||
lines.append('\nReview: %s' % indent.join(reviews))
|
lines.append('\nReview: %s' % indent.join(reviews))
|
||||||
|
|
||||||
tmpl = '%(name)-10s %(when)-12s %(who)s'
|
tmpl = '%(when)-10s %(who)-12s %(desc)s'
|
||||||
histories = []
|
histories = []
|
||||||
for hist in reversed(self.statehistory):
|
for hist in reversed(self.statehistory):
|
||||||
d = {'name': hist.name, 'when': hist.when,
|
d = {'when': hist.when, 'who': hist.who, 'desc': hist.description}
|
||||||
'who': hist.who}
|
|
||||||
histories.append(tmpl % d)
|
histories.append(tmpl % d)
|
||||||
if histories:
|
if histories:
|
||||||
lines.append('\nHistory: %s' % indent.join(histories))
|
lines.append('\nHistory: %s' % indent.join(histories))
|
||||||
@@ -3921,7 +3948,7 @@ def create_submit_request(apiurl,
|
|||||||
|
|
||||||
|
|
||||||
def get_request(apiurl, reqid):
|
def get_request(apiurl, reqid):
|
||||||
u = makeurl(apiurl, ['request', reqid])
|
u = makeurl(apiurl, ['request', reqid], {'withfullhistory': '1'})
|
||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user