def METHOD_NAME(text):
    """generate appropriate restriction for text
    Parsing basically breaks it down into chunks split by /, with each
    chunk allowing for prefix/postfix globbing- note that a postfixed
    glob on package token is treated as package attribute matching,
    not as necessarily a version match.
    If only one chunk is found, it's treated as a package chunk.
    Finally, it supports a nonstandard variation of atom syntax where
    the category can be dropped.
    Examples:
    - `*`: match all
    - `dev-*/*`: category must start with 'dev-'
    - `dev-*`: package must start with 'dev-'
    - `*-apps/portage*`: category must end in '-apps', package must start with
      'portage'
    - `>=portage-2.1`: atom syntax, package 'portage', version greater then or
      equal to '2.1'
    - dev-qt/*:5: all Qt 5 libs
    - boost:0/1.60: all packages named boost with a slot/subslot of 0/1.60.0
    :param text: string to attempt to parse
    :type text: string
    :return: :obj:`pkgcore.restrictions.packages` derivative
    """
    orig_text = text = text.strip()
    if "!" in text:
        raise ParseError(
            f"'!' or any form of blockers make no sense in this usage: {text!r}"
        )
    restrictions = []
    if "::" in text:
        text, repo_id = text.rsplit("::", 1)
        restrictions.append(restricts.RepositoryDep(repo_id))
    if ":" in text:
        text, slot = text.rsplit(":", 1)
        slot, _sep, subslot = slot.partition("/")
        if slot:
            if "*" in slot:
                if r := convert_glob(slot):
                    restrictions.append(packages.PackageRestriction("slot", r))
            else:
                restrictions.append(restricts.SlotDep(slot))
        if subslot:
            if "*" in subslot:
                if r := convert_glob(subslot):
                    restrictions.append(packages.PackageRestriction("subslot", r))
            else:
                restrictions.append(restricts.SubSlotDep(subslot))
    tsplit = text.rsplit("/", 1)
    if len(tsplit) == 1:
        ops, text = collect_ops(text)
        if not ops:
            if "*" in text:
                if r := convert_glob(text):
                    restrictions.append(packages.PackageRestriction("package", r))
                else:
                    restrictions.append(packages.AlwaysTrue)
                if len(restrictions) == 1:
                    return restrictions[0]
                return packages.AndRestriction(*restrictions)
        elif text.startswith("*"):
            raise ParseError(
                f"cannot do prefix glob matches with version ops: {orig_text}"
            )
        # ok... fake category.  whee.
        try:
            r = list(
                collect_package_restrictions(
                    atom.atom(f"{ops}category/{text}").restrictions,
                    attrs=("category",),
                    invert=True,
                )
            )
        except errors.MalformedAtom as e:
            e.atom = orig_text
            raise ParseError(str(e)) from e
        if not restrictions and len(r) == 1:
            return r[0]
        restrictions.extend(r)
        return packages.AndRestriction(*restrictions)
    elif text[0] in atom.valid_ops or "*" not in text:
        # possibly a valid atom object
        try:
            return atom.atom(orig_text)
        except errors.MalformedAtom as e:
            if "*" not in text:
                raise ParseError(str(e)) from e
            # support globbed targets with version restrictions
            return packages.AndRestriction(*parse_globbed_version(text, orig_text))
    r = list(map(convert_glob, tsplit))
    if not r[0] and not r[1]:
        restrictions.append(packages.AlwaysTrue)
    elif not r[0]:
        restrictions.append(packages.PackageRestriction("package", r[1]))
    elif not r[1]:
        restrictions.append(packages.PackageRestriction("category", r[0]))
    else:
        restrictions.extend(
            (
                packages.PackageRestriction("category", r[0]),
                packages.PackageRestriction("package", r[1]),
            )
        )
    if len(restrictions) == 1:
        return restrictions[0]
    return packages.AndRestriction(*restrictions)