Skip to content

Commit

Permalink
Always use dict query in makeurl()
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Feb 1, 2024
1 parent 072d0fd commit 7f7bfa8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 51 deletions.
2 changes: 1 addition & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6025,7 +6025,7 @@ def do_rremove(self, subcmd, opts):
raise e

@cmdln.alias('r')
@cmdln.option('-l', '--last-build', action='store_true',
@cmdln.option('-l', '--last-build', action='store_true', default=None,
help='show last build results (succeeded/failed/unknown)')
@cmdln.option('-r', '--repo', action='append', default=[],
help='Show results only for specified repo(s)')
Expand Down
81 changes: 31 additions & 50 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def error(msg, xml):
def getProjectGlobalServices(self, apiurl: str, project: str, package: str):
self.apiurl = apiurl
# get all project wide services in one file, we don't store it yet
u = makeurl(apiurl, ['source', project, package], query='cmd=getprojectservices')
u = makeurl(apiurl, ["source", project, package], query={"cmd": "getprojectservices"})
try:
f = http_POST(u)
root = ET.parse(f).getroot()
Expand Down Expand Up @@ -3853,11 +3853,9 @@ def show_attribute_meta(apiurl: str, prj: str, pac, subpac, attribute, with_defa
path.append('_attribute')
if attribute:
path.append(attribute)
query = []
if with_defaults:
query.append("with_default=1")
if with_project:
query.append("with_project=1")
query = {}
query["with_default"] = with_defaults
query["with_project"] = with_project
url = makeurl(apiurl, path, query)
try:
f = http_GET(url)
Expand Down Expand Up @@ -4304,11 +4302,10 @@ def show_upstream_xsrcmd5(


def show_project_sourceinfo(apiurl: str, project: str, nofilename: bool, *packages):
query = ['view=info']
if packages:
query.extend([f'package={quote_plus(p)}' for p in packages])
if nofilename:
query.append('nofilename=1')
query = {}
query["view"] = "info"
query["package"] = packages
query["nofilename"] = nofilename
f = http_GET(makeurl(apiurl, ['source', project], query=query))
return f.read()

Expand Down Expand Up @@ -4705,7 +4702,7 @@ def create_submit_request(
options_block,
_html_escape(message))

u = makeurl(apiurl, ['request'], query='cmd=create')
u = makeurl(apiurl, ["request"], query={"cmd": "create"})
r = None
try:
f = http_POST(u, data=xml)
Expand Down Expand Up @@ -5791,7 +5788,7 @@ def link_to_branch(apiurl: str, project: str, package: str):
"""

if '_link' in meta_get_filelist(apiurl, project, package):
u = makeurl(apiurl, ['source', project, package], 'cmd=linktobranch')
u = makeurl(apiurl, ["source", project, package], {"cmd": "linktobranch"})
http_POST(u)
else:
raise oscerr.OscIOError(None, f'no _link file inside project \'{project}\' package \'{package}\'')
Expand Down Expand Up @@ -6536,23 +6533,15 @@ def show_results_meta(
):
repository = repository or []
arch = arch or []
query = []
if package:
query.append(f'package={quote_plus(package)}')
if oldstate:
query.append(f'oldstate={quote_plus(oldstate)}')
if lastbuild:
query.append('lastbuild=1')
if multibuild:
query.append('multibuild=1')
if locallink:
query.append('locallink=1')
if code:
query.append(f'code={quote_plus(code)}')
for repo in repository:
query.append(f'repository={quote_plus(repo)}')
for a in arch:
query.append(f'arch={quote_plus(a)}')
query = {}
query["package"] = package
query["oldstate"] = oldstate
query["lastbuild"] = lastbuild
query["multibuild"] = multibuild
query["locallink"] = locallink
query["code"] = code
query["repository"] = repository
query["arch"] = arch
u = makeurl(apiurl, ['build', prj, '_result'], query=query)
f = http_GET(u)
return f.readlines()
Expand Down Expand Up @@ -7052,15 +7041,13 @@ def print_data(data, strip_time=False):


def get_dependson(apiurl: str, project: str, repository: str, arch: str, packages=None, reverse=None):
query = []
if packages:
for i in packages:
query.append(f'package={quote_plus(i)}')
query = {}
query["package"] = packages

if reverse:
query.append('view=revpkgnames')
query["view"] = "revpkgnames"
else:
query.append('view=pkgnames')
query["view"] = "pkgnames"

u = makeurl(apiurl, ['build', project, repository, arch, '_builddepinfo'], query=query)
f = http_GET(u)
Expand All @@ -7070,12 +7057,9 @@ def get_dependson(apiurl: str, project: str, repository: str, arch: str, package
def get_buildinfo(
apiurl: str, prj: str, package: str, repository: str, arch: str, specfile=None, addlist=None, debug=None
):
query = []
if addlist:
for i in addlist:
query.append(f'add={quote_plus(i)}')
if debug:
query.append('debug=1')
query = {}
query["add"] = addlist
query["debug"] = debug

u = makeurl(apiurl, ['build', prj, repository, arch, package, '_buildinfo'], query=query)

Expand All @@ -7087,10 +7071,8 @@ def get_buildinfo(


def get_buildconfig(apiurl: str, prj: str, repository: str, path=None):
query = []
if path:
for prp in path:
query.append(f'path={quote_plus(prp)}')
query = {}
query["path"] = path
u = makeurl(apiurl, ['build', prj, repository, '_buildconfig'], query=query)
f = http_GET(u)
return f.read()
Expand Down Expand Up @@ -8856,7 +8838,7 @@ def which(name: str):


def get_comments(apiurl: str, kind, *args):
url = makeurl(apiurl, ('comments', kind) + args)
url = makeurl(apiurl, ["comments", kind] + list(args))
f = http_GET(url)
return ET.parse(f).getroot()

Expand All @@ -8879,9 +8861,8 @@ def print_rec(comments, indent=''):

def create_comment(apiurl: str, kind, comment, *args, **kwargs) -> Optional[str]:
query = {}
if kwargs.get('parent') is not None:
query = {'parent_id': kwargs['parent']}
u = makeurl(apiurl, ('comments', kind) + args, query=query)
query["parent_id"] = kwargs.get("parent", None)
u = makeurl(apiurl, ["comments", kind] + list(args), query=query)
f = http_POST(u, data=comment)
ret = ET.fromstring(f.read()).find('summary')
if ret is None:
Expand Down

0 comments on commit 7f7bfa8

Please sign in to comment.