(string, case_xpath=None, fixture_xpath=None, module=None, form=None)
return string
Replace xpath shortcuts with full value.
Replace xpath shortcuts with full value.
Replace xpath shortcuts with full value .
def interpolate_xpath(string, case_xpath=None, fixture_xpath=None, module=None, form=None):
    """
    Replace xpath shortcuts with full value.
    """
    if case_xpath is None and any([
        '#case' in string,
        '#parent' in string,
        '#host' in string,
        # DOT_INTERPOLATE_PATTERN throws false positives, so if it flags the string,
        # verify that the string's dots would actually get replaced
        re.search(DOT_INTERPOLATE_PATTERN, string) and dot_interpolate(string, "") != string,
    ]):
        # At the moment this function is only used by module and form filters.
        # If that changes, amend the error message accordingly.
        raise CaseXPathValidationError(_(CASE_REFERENCE_VALIDATION_ERROR), module=module, form=form)
    replacements = {
        '#user': UsercaseXPath().case(),
        '#session/': session_var('', path=''),
    }
    if fixture_xpath:
        replacements['$fixture_value'] = fixture_xpath

    if case_xpath:
        replacements['#case'] = case_xpath
        replacements['#parent'] = CaseIDXPath(case_xpath + '/index/parent').case()
        replacements['#host'] = CaseIDXPath(case_xpath + '/index/host').case()

    for pattern, repl in replacements.items():
        string = string.replace(pattern, repl)

    if case_xpath:
        return dot_interpolate(string, case_xpath)

    return string
def interpolate_xpath ( string , case_xpath = None , fixture_xpath = None , module = None , form = None ) : if case_xpath is None and any ( [ '#case' in string , '#parent' in string , '#host' in string , # DOT_INTERPOLATE_PATTERN throws false positives, so if it flags the string, # verify that the string's dots would actually get replaced re . search ( DOT_INTERPOLATE_PATTERN , string ) and dot_interpolate ( string , "" ) != string , ] ) : # At the moment this function is only used by module and form filters. # If that changes, amend the error message accordingly. raise CaseXPathValidationError ( _ ( CASE_REFERENCE_VALIDATION_ERROR ) , module = module , form = form ) replacements = { '#user' : UsercaseXPath ( ) . case ( ) , '#session/' : session_var ( '' , path = '' ) , } if fixture_xpath : replacements [ '$fixture_value' ] = fixture_xpath if case_xpath : replacements [ '#case' ] = case_xpath replacements [ '#parent' ] = CaseIDXPath ( case_xpath + '/index/parent' ) . case ( ) replacements [ '#host' ] = CaseIDXPath ( case_xpath + '/index/host' ) . case ( ) for pattern , repl in replacements . items ( ) : string = string . replace ( pattern , repl ) if case_xpath : return dot_interpolate ( string , case_xpath ) return string