Page MenuHomePhabricator

text-contains exception does not respect regex option from fix but listens to command line
Closed, DuplicatePublic

Description

ibox = 'Infobox - whatever'
fixes['add-infobox'] = {
    'regex': True,
    'exceptions': {
        'text-contains': [
            r'\{\{' + first_upper(ibox),
            r'\{\{' + first_lower(ibox),
        ],
    },
    'msg': {
        '_default': 'add infobox',
    },
    'replacements': [
        build_infobox_regex(ibox),
    ],
}

My text-contains key includes some regexes and the fix has regex: True. However, those exceptions only skip relevant articles when I include -regex to the command (which is otherwise redundant if I only use fixes).

Event Timeline

Because Exceptions specified via 'fix' are merged to those via CLI.
So all exceptions become common,
And when this is done, the 'regex': True information is not considered, but only the -regex value.

I am not sure what is the wanted behaviour.
And if there is a reason in not handling the exceptions fix by fix.

Replacement management in replace.py gives me a headache.

Replacement management in replace.py gives me a headache.

Me too after your clarification. But I believe we can handle that.

There is just a few scenarios: (pwb.py replace only run with...)

  1. -manualinput with one or more pairs
  2. a single -fix
  3. multiple -fix'es
  4. one or more -fix'es and -manualinput with one or more pairs

My opinion:

  • -regex (-dotall, -nocase etc.) shouldn't influence individual fixes
  • when only -fix'es are requested, all of them should inherit all exceptions (-excepttext etc.)
  • when all replacements come from command line, apply exceptions to all of them ("squash" replacements to a single -fix)

Now there's only one remaining point: combined input. I would introduce a new -inherit argument that would optionally make all command line exceptions inherited to all fixes (as well as the "squashed" one), otherwise (default behavior) it would only be relevant for command line replacements.

Comments?

Xqt triaged this task as High priority.Sep 9 2017, 12:51 PM

If I got you correctly, I agree.
Each fix (either via user-fixes or cmd line) has its own set of specs (we can see cmd line inputs as 'one fix').
An option from cmd line to override fix definition in specific areas.