# Path: bugzilla/_util.py
# def listify(val):
#     """Ensure that value is either None or a list, converting single values
#     into 1-element lists"""
#     if val is None:
#         return val
#     if isinstance(val, list):
#         return val
#     return [val]


import base64
import json
import logging
import os
from ._backendbase import _BackendBase
from .exceptions import BugzillaError
from ._util import listify
        data["alias"] = listify(aliases)
        ret = self._get("/bug", data)
        return ret

    def bug_attachment_get(self, attachment_ids, paramdict):
        # XMLRPC supported mutiple fetch at once, but not REST
        ret = {}
        for attid in listify(attachment_ids):
            out = self._get("/bug/attachment/%s" % attid, paramdict)
            _update_key(ret, out, "attachments")
            _update_key(ret, out, "bugs")
        return ret

    def bug_attachment_get_all(self, bug_ids, paramdict):
        # XMLRPC supported mutiple fetch at once, but not REST
        ret = {}
        for bugid in listify(bug_ids):
            out = self._get("/bug/%s/attachment" % bugid, paramdict)
            _update_key(ret, out, "attachments")
            _update_key(ret, out, "bugs")
        return ret

    def bug_attachment_create(self, bug_ids, data, paramdict):
        if data is not None and "data" not in paramdict:
            paramdict["data"] = base64.b64encode(data).decode("utf-8")
        paramdict["ids"] = listify(bug_ids)
        return self._post("/bug/%s/attachment" % paramdict["ids"][0],
                paramdict)

    def bug_attachment_update(self, attachment_ids, paramdict):

# Path: bugzilla/_util.py
# def listify(val):
#     """Ensure that value is either None or a list, converting single values
#     into 1-element lists"""
#     if val is None:
#         return val
#     if isinstance(val, list):
#         return val
#     return [val]


# Path: bugzilla/_backendrest.py
import base64
import json
import logging
import os
from ._backendbase import _BackendBase
from .exceptions import BugzillaError
from ._util import listify

        data["alias"] = listify(aliases)
        ret = self._get("/bug", data)
        return ret

    def bug_attachment_get(self, attachment_ids, paramdict):
        # XMLRPC supported mutiple fetch at once, but not REST
        ret = {}
        for attid in listify(attachment_ids):
            out = self._get("/bug/attachment/%s" % attid, paramdict)
            _update_key(ret, out, "attachments")
            _update_key(ret, out, "bugs")
        return ret

    def bug_attachment_get_all(self, bug_ids, paramdict):
        # XMLRPC supported mutiple fetch at once, but not REST
        ret = {}
        for bugid in listify(bug_ids):
            out = self._get("/bug/%s/attachment" % bugid, paramdict)
            _update_key(ret, out, "attachments")
            _update_key(ret, out, "bugs")
        return ret

    def bug_attachment_create(self, bug_ids, data, paramdict):
        if data is not None and "data" not in paramdict:
            paramdict["data"] = base64.b64encode(data).decode("utf-8")
        paramdict["ids"] = listify(bug_ids)
        return self._post("/bug/%s/attachment" % paramdict["ids"][0],
                paramdict)

    def bug_attachment_update(self, attachment_ids, paramdict):

        paramdict["ids"] = listify(attachment_ids)