mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-15 06:47:15 +01:00
Merge pull request #1627 from dirkmueller/use_findtext
Use findtext() instead of find().text
This commit is contained in:
commit
1951bb4648
24
osc/build.py
24
osc/build.py
@ -91,7 +91,7 @@ class Buildinfo:
|
|||||||
|
|
||||||
if root.find('error') is not None:
|
if root.find('error') is not None:
|
||||||
sys.stderr.write('buildinfo is broken... it says:\n')
|
sys.stderr.write('buildinfo is broken... it says:\n')
|
||||||
error = root.find('error').text
|
error = root.findtext("error")
|
||||||
if error.startswith('unresolvable: '):
|
if error.startswith('unresolvable: '):
|
||||||
sys.stderr.write('unresolvable: ')
|
sys.stderr.write('unresolvable: ')
|
||||||
sys.stderr.write('\n '.join(error[14:].split(',')))
|
sys.stderr.write('\n '.join(error[14:].split(',')))
|
||||||
@ -125,20 +125,10 @@ class Buildinfo:
|
|||||||
# buildarch: The architecture of the build result (host arch in GNU definition)
|
# buildarch: The architecture of the build result (host arch in GNU definition)
|
||||||
# hostarch: The architecture of the build environment (build arch in GNU defintion)
|
# hostarch: The architecture of the build environment (build arch in GNU defintion)
|
||||||
# crossarch: Same as hostarch, but indicating that a sysroot with an incompatible architecture exists
|
# crossarch: Same as hostarch, but indicating that a sysroot with an incompatible architecture exists
|
||||||
self.buildarch = root.find('arch').text
|
self.buildarch = root.findtext("arch")
|
||||||
if root.find('crossarch') is not None:
|
self.crossarch = root.findtext("crossarch")
|
||||||
self.crossarch = root.find('crossarch').text
|
self.hostarch = root.findtext("hostarch")
|
||||||
else:
|
self.release = root.findtext("release")
|
||||||
self.crossarch = None
|
|
||||||
if root.find('hostarch') is not None:
|
|
||||||
self.hostarch = root.find('hostarch').text
|
|
||||||
else:
|
|
||||||
self.hostarch = None
|
|
||||||
|
|
||||||
if root.find('release') is not None:
|
|
||||||
self.release = root.find('release').text
|
|
||||||
else:
|
|
||||||
self.release = None
|
|
||||||
if conf.config['api_host_options'][apiurl]['downloadurl']:
|
if conf.config['api_host_options'][apiurl]['downloadurl']:
|
||||||
# Formerly, this was set to False, but we have to set it to True, because a large
|
# Formerly, this was set to False, but we have to set it to True, because a large
|
||||||
# number of repos in OBS are misconfigured and don't actually have repos setup - they
|
# number of repos in OBS are misconfigured and don't actually have repos setup - they
|
||||||
@ -154,7 +144,7 @@ class Buildinfo:
|
|||||||
self.debuginfo = 0
|
self.debuginfo = 0
|
||||||
if root.find('debuginfo') is not None:
|
if root.find('debuginfo') is not None:
|
||||||
try:
|
try:
|
||||||
self.debuginfo = int(root.find('debuginfo').text)
|
self.debuginfo = int(root.findtext("debuginfo"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -718,7 +708,7 @@ def create_build_descr_data(
|
|||||||
if topdir:
|
if topdir:
|
||||||
buildenv_file = os.path.join(topdir, f"_buildenv.{repo}.{arch}")
|
buildenv_file = os.path.join(topdir, f"_buildenv.{repo}.{arch}")
|
||||||
if not os.path.isfile(buildenv_file):
|
if not os.path.isfile(buildenv_file):
|
||||||
buildenv_file = os.path.join(topdir, f"_buildenv")
|
buildenv_file = os.path.join(topdir, "_buildenv")
|
||||||
if os.path.isfile(buildenv_file):
|
if os.path.isfile(buildenv_file):
|
||||||
print(f"Using local file: {os.path.basename(buildenv_file)}", file=sys.stderr)
|
print(f"Using local file: {os.path.basename(buildenv_file)}", file=sys.stderr)
|
||||||
with open(buildenv_file, "rb") as f:
|
with open(buildenv_file, "rb") as f:
|
||||||
|
@ -6489,7 +6489,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
cfg = f
|
cfg = f
|
||||||
root = ET.parse(cfg).getroot()
|
root = ET.parse(cfg).getroot()
|
||||||
repo = root.get("repository")
|
repo = root.get("repository")
|
||||||
arch = root.find("arch").text
|
arch = root.findtext("arch")
|
||||||
return repo, arch
|
return repo, arch
|
||||||
|
|
||||||
@cmdln.alias('lbl')
|
@cmdln.alias('lbl')
|
||||||
|
44
osc/core.py
44
osc/core.py
@ -381,10 +381,7 @@ class ReviewState(AbstractState):
|
|||||||
self.by_package = review_node.get('by_package')
|
self.by_package = review_node.get('by_package')
|
||||||
self.who = review_node.get('who')
|
self.who = review_node.get('who')
|
||||||
self.when = review_node.get('when')
|
self.when = review_node.get('when')
|
||||||
self.comment = ''
|
self.comment = review_node.findtext("comment", default="").strip()
|
||||||
if not review_node.find('comment') is None and \
|
|
||||||
review_node.find('comment').text:
|
|
||||||
self.comment = review_node.find('comment').text.strip()
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
result = super().__repr__()
|
result = super().__repr__()
|
||||||
@ -421,17 +418,15 @@ class RequestHistory(AbstractState):
|
|||||||
super().__init__(history_node.tag)
|
super().__init__(history_node.tag)
|
||||||
self.who = history_node.get('who')
|
self.who = history_node.get('who')
|
||||||
self.when = history_node.get('when')
|
self.when = history_node.get('when')
|
||||||
if not history_node.find('description') is None and \
|
if history_node.find('description') is not None:
|
||||||
history_node.find('description').text:
|
|
||||||
# OBS 2.6
|
# OBS 2.6
|
||||||
self.description = history_node.find('description').text.strip()
|
self.description = history_node.findtext("description").strip()
|
||||||
else:
|
else:
|
||||||
# OBS 2.5 and before
|
# OBS 2.5 and before
|
||||||
self.description = history_node.get('name')
|
self.description = history_node.get("name")
|
||||||
self.comment = ''
|
self.comment = ''
|
||||||
if not history_node.find('comment') is None and \
|
if history_node.find("comment") is not None:
|
||||||
history_node.find('comment').text:
|
self.comment = history_node.findtext("comment").strip()
|
||||||
self.comment = history_node.find('comment').text.strip()
|
|
||||||
self.name = self._parse_name(history_node)
|
self.name = self._parse_name(history_node)
|
||||||
|
|
||||||
def _parse_name(self, history_node):
|
def _parse_name(self, history_node):
|
||||||
@ -471,9 +466,8 @@ class RequestState(AbstractState):
|
|||||||
# OBS 2.6 has it always, before it did not exist
|
# OBS 2.6 has it always, before it did not exist
|
||||||
self.description = state_node.get('description')
|
self.description = state_node.get('description')
|
||||||
self.comment = ''
|
self.comment = ''
|
||||||
if not state_node.find('comment') is None and \
|
if state_node.find('comment') is not None:
|
||||||
state_node.find('comment').text:
|
self.comment = state_node.findtext("comment").strip()
|
||||||
self.comment = state_node.find('comment').text.strip()
|
|
||||||
|
|
||||||
def get_node_attrs(self):
|
def get_node_attrs(self):
|
||||||
return ('name', 'who', 'when', 'approver')
|
return ('name', 'who', 'when', 'approver')
|
||||||
@ -744,14 +738,14 @@ class Request:
|
|||||||
self.reviews.append(ReviewState(review))
|
self.reviews.append(ReviewState(review))
|
||||||
for history_element in root.findall('history'):
|
for history_element in root.findall('history'):
|
||||||
self.statehistory.append(RequestHistory(history_element))
|
self.statehistory.append(RequestHistory(history_element))
|
||||||
if not root.find('priority') is None and root.find('priority').text:
|
if root.findtext("priority"):
|
||||||
self.priority = root.find('priority').text.strip()
|
self.priority = root.findtext("priority").strip()
|
||||||
if not root.find('accept_at') is None and root.find('accept_at').text:
|
if root.findtext("accept_at"):
|
||||||
self.accept_at = root.find('accept_at').text.strip()
|
self.accept_at = root.findtext("accept_at").strip()
|
||||||
if not root.find('title') is None:
|
if root.findtext("title"):
|
||||||
self.title = root.find('title').text.strip()
|
self.title = root.findtext("title").strip()
|
||||||
if not root.find('description') is None and root.find('description').text:
|
if root.findtext("description"):
|
||||||
self.description = root.find('description').text.strip()
|
self.description = root.findtext("description").strip()
|
||||||
|
|
||||||
def add_action(self, type, **kwargs):
|
def add_action(self, type, **kwargs):
|
||||||
"""add a new action to the request"""
|
"""add a new action to the request"""
|
||||||
@ -3030,10 +3024,10 @@ def submit_action_diff(apiurl: str, action: Action):
|
|||||||
if e.code != 404:
|
if e.code != 404:
|
||||||
raise e
|
raise e
|
||||||
root = ET.fromstring(e.read())
|
root = ET.fromstring(e.read())
|
||||||
return b'error: \'%s\' does not exist' % root.find('summary').text.encode()
|
return b'error: \'%s\' does not exist' % root.findtext("summary").encode()
|
||||||
elif e.code == 404:
|
elif e.code == 404:
|
||||||
root = ET.fromstring(e.read())
|
root = ET.fromstring(e.read())
|
||||||
return b'error: \'%s\' does not exist' % root.find('summary').text.encode()
|
return b'error: \'%s\' does not exist' % root.findtext("summary").encode()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
@ -4675,7 +4669,7 @@ def get_source_rev(apiurl: str, project: str, package: str, revision=None):
|
|||||||
# remember the newest one.
|
# remember the newest one.
|
||||||
if not ent:
|
if not ent:
|
||||||
ent = new
|
ent = new
|
||||||
elif ent.find('time').text < new.find('time').text:
|
elif ent.findtext("time") < new.findtext("time"):
|
||||||
ent = new
|
ent = new
|
||||||
if not ent:
|
if not ent:
|
||||||
return {'version': None, 'error': 'empty revisionlist: no such package?'}
|
return {'version': None, 'error': 'empty revisionlist: no such package?'}
|
||||||
|
@ -136,11 +136,11 @@ class RepoDataQueryResult(packagequery.PackageQueryResult):
|
|||||||
|
|
||||||
@_to_bytes_or_None
|
@_to_bytes_or_None
|
||||||
def arch(self):
|
def arch(self):
|
||||||
return self.__element.find(namespace("common") + "arch").text
|
return self.__element.findtext(namespace("common") + "arch")
|
||||||
|
|
||||||
@_to_bytes_or_None
|
@_to_bytes_or_None
|
||||||
def description(self):
|
def description(self):
|
||||||
return self.__element.find(namespace("common") + "description").text
|
return self.__element.findtext(namespace("common") + "description")
|
||||||
|
|
||||||
def distribution(self):
|
def distribution(self):
|
||||||
return None
|
return None
|
||||||
@ -151,7 +151,7 @@ class RepoDataQueryResult(packagequery.PackageQueryResult):
|
|||||||
|
|
||||||
@_to_bytes_or_None
|
@_to_bytes_or_None
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.__element.find(namespace("common") + "name").text
|
return self.__element.findtext(namespace("common") + "name")
|
||||||
|
|
||||||
def path(self):
|
def path(self):
|
||||||
locationElement = self.__element.find(namespace("common") + "location")
|
locationElement = self.__element.find(namespace("common") + "location")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user