Allowing multiple folder as argument. #24

Merged
mdk merged 4 commits from mdk/potodo:mdk-multi-folders into main 2025-10-23 20:56:40 +02:00
Owner

It's still WIP but I worked on #21, tried to refactor for readability instead of just stashing code on top of code to make it work.

Had to rework the presentation too, to be able to display multiple hierarchies, got this:

1 directory  40.91% done
└── repository/  40.91% done
    ├── file1.po                           1 /   3 ( 33.0% translated), 1 fuzzy
    ├── file2.po                           0 /   1 (  0.0% translated)
    ├── excluded/  75.00% done
    │   └── file4.po                       1 /   2 ( 50.0% translated)
    └── folder/  58.82% done
        ├── excluded.po                    1 /   2 ( 50.0% translated)
        ├── file3.po                       0 /   1 (  0.0% translated)

That's still not perfect, and I've not tried the pot merge yet.

It's still WIP but I worked on #21, tried to refactor for readability instead of just stashing code on top of code to make it work. Had to rework the presentation too, to be able to display multiple hierarchies, got this: ``` 1 directory 40.91% done └── repository/ 40.91% done ├── file1.po 1 / 3 ( 33.0% translated), 1 fuzzy ├── file2.po 0 / 1 ( 0.0% translated) ├── excluded/ 75.00% done │ └── file4.po 1 / 2 ( 50.0% translated) └── folder/ 58.82% done ├── excluded.po 1 / 2 ( 50.0% translated) ├── file3.po 0 / 1 ( 0.0% translated) ``` That's still not perfect, and I've not tried the pot merge yet.
mdk force-pushed mdk-multi-folders from 45cfc43cbc to eb8dfe6320 2025-10-16 11:52:51 +02:00 Compare
mdk changed title from WIP: Allowing multiple folder as argument. to Allowing multiple folder as argument. 2025-10-16 11:53:40 +02:00
Author
Owner

I added a small test to ensure "--pot" still works.

It's not ideal yet: because all unmatched pot are copied from the pot/ directory to the tmp directory, unselected pot file are still displayed in the result:

$ potodo --pot tests/fixtures/pots -p tests/fixtures/repository/ 
1 directory  16.28% done
└── tmpz0k82w8y/  16.28% done
    ├── file1.po                           0 /   2 (  0.0% translated)
    ├── file3.po                           0 /   1 (  0.0% translated)
    └── folder/  33.33% done
        ├── file5.po                       0 /   1 (  0.0% translated)

$ potodo --pot tests/fixtures/pots -p tests/fixtures/repository/folder/
1 directory  0.00% done
└── tmppq2f_ct8/  0.00% done
    ├── file1.po                           0 /   2 (  0.0% translated)
    ├── file3.po                           0 /   1 (  0.0% translated)
    └── folder/  0.00% done
        ├── file5.po                       0 /   1 (  0.0% translated)
        └── finished.po                    0 /   1 (  0.0% translated)

@maciek I spot a strange naming in pot/ and folder/ inside the fixtures directory, is it on purpose? See file3.pot vs file3.po not being in the same directory:

> tree tests/fixtures/
tests/fixtures/
├── git_repository
│   ├── dotgit
│   │   └── configure.po
│   └── file1.po
├── pots
│   ├── #file1.pot#
│   ├── file1.pot
│   ├── file3.pot
│   └── folder
│       ├── file5.pot
│       └── finished.pot
└── repository
    ├── excluded
    │   └── file4.po
    ├── file1.po
    ├── file2.po
    └── folder
        ├── excluded.po
        ├── file3.po
        └── finished.po

Looks like it is on purpose, according to your tests. So my potodo --pot tests/fixtures/pots -p tests/fixtures/repository/folder/ is in fact very weird, as it tries to merge pots/ with folder/ and successfully match file3, haha.

I added a small test to ensure "--pot" still works. It's not ideal yet: because all unmatched pot are copied from the pot/ directory to the tmp directory, unselected pot file are still displayed in the result: ``` $ potodo --pot tests/fixtures/pots -p tests/fixtures/repository/ 1 directory 16.28% done └── tmpz0k82w8y/ 16.28% done ├── file1.po 0 / 2 ( 0.0% translated) ├── file3.po 0 / 1 ( 0.0% translated) └── folder/ 33.33% done ├── file5.po 0 / 1 ( 0.0% translated) $ potodo --pot tests/fixtures/pots -p tests/fixtures/repository/folder/ 1 directory 0.00% done └── tmppq2f_ct8/ 0.00% done ├── file1.po 0 / 2 ( 0.0% translated) ├── file3.po 0 / 1 ( 0.0% translated) └── folder/ 0.00% done ├── file5.po 0 / 1 ( 0.0% translated) └── finished.po 0 / 1 ( 0.0% translated) ``` @maciek I spot a strange naming in `pot/` and `folder/` inside the `fixtures` directory, is it on purpose? See `file3.pot` vs `file3.po` not being in the same directory: ``` > tree tests/fixtures/ tests/fixtures/ ├── git_repository │   ├── dotgit │   │   └── configure.po │   └── file1.po ├── pots │   ├── #file1.pot# │   ├── file1.pot │   ├── file3.pot │   └── folder │   ├── file5.pot │   └── finished.pot └── repository ├── excluded │   └── file4.po ├── file1.po ├── file2.po └── folder ├── excluded.po ├── file3.po └── finished.po ``` Looks like it is on purpose, according to your tests. So my `potodo --pot tests/fixtures/pots -p tests/fixtures/repository/folder/` is in fact very weird, as it tries to merge `pots/` with `folder/` and successfully match `file3`, haha.
Author
Owner

We would need a syntax or something to tell "This pot directory match this root, BUT I don't want my project studied from the root, I want just this directory".

Like:

potodo --pot tests/fixtures/pots/:tests/fixtures/repository/ -p tests/fixtures/repository/folder/

maybe?

We have to think about allowing, in the future, taking po files instead of directories, so:

potodo --pot tests/fixtures/pots/:tests/fixtures/repository/ -p tests/fixtures/repository/folder/finished.po

Or --pot-root plus --po-root (giving one implying giving the other).

We would need a syntax or something to tell "This pot directory match this root, BUT I don't want my project studied from the root, I want just this directory". Like: potodo --pot tests/fixtures/pots/:tests/fixtures/repository/ -p tests/fixtures/repository/folder/ maybe? We have to think about allowing, in the future, taking po files instead of directories, so: potodo --pot tests/fixtures/pots/:tests/fixtures/repository/ -p tests/fixtures/repository/folder/finished.po Or `--pot-root` plus `--po-root` (giving one implying giving the other).
Contributor

Ah, good point. Alternatively we could be finding a common root in -p
arguments and matching the common root against --pot, but filtering the pot
root based on specified paths.

Ah, good point. Alternatively we could be finding a common root in -p arguments and matching the common root against --pot, but filtering the pot root based on specified paths.
Author
Owner

@maciek wrote in #24 (comment):

Ah, good point. Alternatively we could be finding a common root in -p
arguments and matching the common root against --pot, but filtering the pot
root based on specified paths.

I fear that too fragile. I mean it works for our specific use case of python-docs-fr, and for all flat repository that don't have any folder at all, but for the others it can break:

If we have a repo with fr/LC_MESSAGES/a/foo/,fr/LC_MESSAGES/a/bar/, fr/LC_MESSAGES/a/baz/ they could run potodo --pot pot/ -p fr/LC_MESSAGES/a/foo/ -p fr/LC_MESSAGES/a/bar/. The deduced common ancestor would be fr/LC_MESSAGES/a/, while the root is fr/LC_MESSAGES/ :(

What about merging as-is and meditating on this on another thread? I don't think the error we're discussing can break existing use of potodo (with a single -p) it manifest when multiples -p are used.

@maciek wrote in https://git.afpy.org/AFPy/potodo/pulls/24#issuecomment-5119: > Ah, good point. Alternatively we could be finding a common root in -p > arguments and matching the common root against --pot, but filtering the pot > root based on specified paths. I fear that too fragile. I mean it works for our specific use case of python-docs-fr, and for all flat repository that don't have any folder at all, but for the others it can break: If we have a repo with `fr/LC_MESSAGES/a/foo/`,`fr/LC_MESSAGES/a/bar/`, `fr/LC_MESSAGES/a/baz/` they could run `potodo --pot pot/ -p fr/LC_MESSAGES/a/foo/ -p fr/LC_MESSAGES/a/bar/`. The deduced common ancestor would be `fr/LC_MESSAGES/a/`, while the root is `fr/LC_MESSAGES/` :( What about merging as-is and meditating on this on another thread? I don't think the error we're discussing can break existing use of potodo (with a single `-p`) it manifest when multiples `-p` are used.
maciek left a comment

What about merging as-is and meditating on this on another thread? I don't think the error we're discussing can break existing use of potodo (with a single -p) it manifest when multiples -p are used.

Agreed 👍 there're no regression in this regard, we can treat the behaviours discussed as missing features.

I found one regression though, connected with the JSON output.

% uvx --from git+https://git.afpy.org/mdk/potodo@mdk-multi-folders potodo -p tutorial --json
[]
% uvx --from git+https://git.afpy.org/afpy/potodo potodo -p tutorial --json
[
    {
        […,
            {
                "name": "tutorial/stdlib",
                "path": "/Users/m-aciek/projects/python-docs-pl/tutorial/stdlib.po",
                "entries": 67,
                "fuzzies": 0,
                "translated": 66,
                "percent_translated": 98,
                "reserved_by": null,
                "reservation_date": null
            },
            {
                "name": "tutorial/stdlib2",
                "path": "/Users/m-aciek/projects/python-docs-pl/tutorial/stdlib2.po",
                "entries": 65,
                "fuzzies": 0,
                "translated": 64,
                "percent_translated": 98,
                "reserved_by": null,
                "reservation_date": null
            }
        ]
    }
]

Other than that I like the console output improvements! Also confirming excluding works well with the new behaviour.

% uvx --from git+https://git.afpy.org/mdk/potodo@mdk-multi-folders potodo -p tutorial -p library --exclude '**/a*' --above 10 
2 directories  21.92% done
├── tutorial/  98.18% done
│   ├── errors.po                         92 /  96 ( 95.0% translated)
│   ├── index.po                           7 /   9 ( 77.0% translated)
│   ├── inputoutput.po                   111 / 112 ( 99.0% translated)
│   ├── interactive.po                     6 /   7 ( 85.0% translated)
│   ├── interpreter.po                    31 /  33 ( 93.0% translated)
│   ├── introduction.po                  119 / 120 ( 99.0% translated)
│   ├── modules.po                       115 / 117 ( 98.0% translated)
│   ├── stdlib.po                         66 /  67 ( 98.0% translated)
│   ├── stdlib2.po                        64 /  65 ( 98.0% translated)
└── library/  10.20% done
    ├── __future__.po                     20 /  49 ( 40.0% translated)
    ├── __main__.po                        9 /  72 ( 12.0% translated)
    ├── bdb.po                            56 / 119 ( 47.0% translated)
    …

Thank you!

> What about merging as-is and meditating on this on another thread? I don't think the error we're discussing can break existing use of potodo (with a single -p) it manifest when multiples -p are used. Agreed 👍 there're no regression in this regard, we can treat the behaviours discussed as missing features. I found one regression though, connected with the JSON output. ``` % uvx --from git+https://git.afpy.org/mdk/potodo@mdk-multi-folders potodo -p tutorial --json [] % uvx --from git+https://git.afpy.org/afpy/potodo potodo -p tutorial --json [ { […, { "name": "tutorial/stdlib", "path": "/Users/m-aciek/projects/python-docs-pl/tutorial/stdlib.po", "entries": 67, "fuzzies": 0, "translated": 66, "percent_translated": 98, "reserved_by": null, "reservation_date": null }, { "name": "tutorial/stdlib2", "path": "/Users/m-aciek/projects/python-docs-pl/tutorial/stdlib2.po", "entries": 65, "fuzzies": 0, "translated": 64, "percent_translated": 98, "reserved_by": null, "reservation_date": null } ] } ] ``` Other than that I like the console output improvements! Also confirming excluding works well with the new behaviour. ``` % uvx --from git+https://git.afpy.org/mdk/potodo@mdk-multi-folders potodo -p tutorial -p library --exclude '**/a*' --above 10 2 directories 21.92% done ├── tutorial/ 98.18% done │ ├── errors.po 92 / 96 ( 95.0% translated) │ ├── index.po 7 / 9 ( 77.0% translated) │ ├── inputoutput.po 111 / 112 ( 99.0% translated) │ ├── interactive.po 6 / 7 ( 85.0% translated) │ ├── interpreter.po 31 / 33 ( 93.0% translated) │ ├── introduction.po 119 / 120 ( 99.0% translated) │ ├── modules.po 115 / 117 ( 98.0% translated) │ ├── stdlib.po 66 / 67 ( 98.0% translated) │ ├── stdlib2.po 64 / 65 ( 98.0% translated) └── library/ 10.20% done ├── __future__.po 20 / 49 ( 40.0% translated) ├── __main__.po 9 / 72 ( 12.0% translated) ├── bdb.po 56 / 119 ( 47.0% translated) … ``` Thank you!
@ -95,1 +96,4 @@
)
def test_run_witout_dash_dash_pot(run_potodo, repo_dir):
Contributor
def test_run_without_dash_dash_pot(run_potodo, repo_dir):

nit: spelling error witout -> without

```suggestion def test_run_without_dash_dash_pot(run_potodo, repo_dir): ``` nit: spelling error witout -> without
mdk marked this conversation as resolved
typo
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
ce8d4d95ef
FIX json output
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
0d051835c2
Author
Owner

Fixed the json output!

Fixed the json output!
pylint
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
608f9d908d
mdk merged commit 2706a46b1c into main 2025-10-23 20:56:40 +02:00
mdk deleted branch mdk-multi-folders 2025-10-23 20:56:40 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AFPy/potodo!24
No description provided.