Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with wildcards in calculations. #2195

Open
RML-IAEA opened this issue Nov 29, 2022 · 0 comments
Open

Issue with wildcards in calculations. #2195

RML-IAEA opened this issue Nov 29, 2022 · 0 comments

Comments

@RML-IAEA
Copy link
Contributor

RML-IAEA commented Nov 29, 2022

Description

Issue with wildcards in calculations.
see error: "Wildcards for interims are not allowed:"
image
In the current code wildcards cannot be used without defining the keyword elsewhere in the function. You cannot use the "keyword.wildcard" by itself.

Reproduction guide

Create the analysis service "gs_Be7_00 " and calculation "send_object" and attempt to run it.
gs_Be7_00 is a keyword for the analysis service

Looking at the code:

        keywords = re.compile(r"\[([^\.^\]]+)\]").findall(value)
        for keyword in keywords:
            # Check if the service keyword exists and is active.
            dep_service = catalog(getKeyword=keyword, is_active=True)
            if not dep_service and keyword not in interim_keywords:
                msg = _(
                    "Validation failed: Keyword '${keyword}' is invalid",
                    mapping={
                        'keyword': safe_unicode(keyword)
                    })
                return to_utf8(translate(msg))

        # Allow to use Wildcards, LDL and UDL values in calculations
        allowedwds = ["LDL", "UDL", "BELOWLDL", "ABOVEUDL"]
        keysandwildcards = re.compile(r"\[([^\]]+)\]").findall(value)
        keysandwildcards = [k for k in keysandwildcards if "." in k]
        keysandwildcards = [k.split(".", 1) for k in keysandwildcards]
        errwilds = [k[1] for k in keysandwildcards if k[0] not in keywords]
        if len(errwilds) > 0:
            msg = _(
                "Wildcards for interims are not allowed: ${wildcards}",
                mapping={
                    "wildcards": safe_unicode(", ".join(errwilds))
                })
            return to_utf8(translate(msg))

The list "errwilds" will be filled if the key from keysandwildcards is not in keywords.

Expected behaviour

I would like to be able to use wildcards without passing the keyword separately.

Versions

  • OS: Linux

  • senaite.core: master

  • senaite.impress: master

  • senaite.core.listing: master

  • senaite.core.supermodel: master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant