Skip to content

make parse.matchLineImpl more greedy ? #223

@Carreau

Description

@Carreau

I've got a issue where FPP will match only some lines (piping git status).

Example;

$ git status | fpp
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    examples/.DS_Store
    examples/minimal.py
    examples/p1.py
    examples/tutorial/.DS_Store #not matched
    examples/tutorial/screenshots/.DS_Store #not matched 

This seem to be because parse match is not greedy enough:

In [11]: parse.matchLine('examples/tutorial/screenshots/.DS_Store')
Out[11]:
('/screenshots/.DS_Store',
 0,
 <_sre.SRE_Match object; span=(17, 39), match='/screenshots/.DS_Store'>)

Which if you require the file to exists will not match as it discards 2 directory:

In [12]: parse.matchLine('examples/tutorial/screenshots/.DS_Store', True)
# no results.

Digging deeper, parse.matchLineImpl is already not greedy enough

In [22]: parse.matchLineImpl('examples/tutorial/screenshots/.DS_Store', True)
Out[22]:
[('/screenshots/.DS_Store',
  0,
  <_sre.SRE_Match object; span=(17, 39), match='/screenshots/.DS_Store'>)]

Haven't yet looked at which regex in parse.REGEX_WATERFALL is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions