Page MenuHomeSoftware Heritage

use right abstraction replacing PosixPath with Path
ClosedPublic

Authored by tenma on Fri, Sep 11, 5:41 PM.

Details

Summary

replaced PosixPath with Path, which astracts away environment detail, in the whole package

Depends on D3931

Diff Detail

Repository
rDTSCN Code scanner
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

tenma created this revision.Fri, Sep 11, 5:41 PM

Build is green

Patch application report for D3932 (id=13859)

Could not rebase; Attempt merge onto f838fed672...

Updating f838fed..f95b49a
Fast-forward
 swh/scanner/cli.py                 | 106 +++++++++++++++++--------------------
 swh/scanner/dashboard/dashboard.py |   8 +--
 swh/scanner/model.py               |  14 ++---
 swh/scanner/plot.py                |  13 ++---
 swh/scanner/scanner.py             | 100 ++++++++++++++++++++++++++++------
 swh/scanner/tests/conftest.py      |   6 +--
 swh/scanner/tests/test_cli.py      |  16 ------
 swh/scanner/tests/test_scanner.py  |  23 ++++++--
 8 files changed, 170 insertions(+), 116 deletions(-)
 delete mode 100644 swh/scanner/tests/test_cli.py
Changes applied before test
commit f95b49a7fd38696c483d811eb5769c17031e9d08
Author: tenma <tenma+swh@mailbox.org>
Date:   Fri Sep 11 17:37:29 2020 +0200

    use right abstraction replacing PosixPath with Path
    
    replaced PosixPath with Path, which astracts away environment detail, in the whole package

commit 8ab1bc99c170b423774fa885552a9777f62898bb
Author: tenma <tenma+swh@mailbox.org>
Date:   Fri Sep 11 17:24:47 2020 +0200

    refactor non-cli code out of cli in swh-scanner
    
    moved non-cli code including imports out of cli module to scanner module

commit 95e0af65495bb3b1af3d6d6f31015ffef11bd4af
Author: tenma <tenma+swh@mailbox.org>
Date:   Fri Sep 11 16:54:38 2020 +0200

    Add standard config support and auth token for swh-scanner
    
    - impl a full SWH config scheme, which loads config like the following
    (descending priority):
        - CLI switch for config path
        - CLI envvar for component config path (click auto_envvar feature)
        - CLI envvar for global config path
        - default global config path under ~/.config/swh/global.yml
        - merge loaded config with default specific config mapping
    - for now the default config path is hardcoded but will move to swh.core.config later
    - url and token config is namespaced with web-api to start having a
    consistent hierarchical config model accross components
    - added simple HTTP auth token support for requests to the SWH API,
    without adding yet another dependency for a small middleware
    
    Close T2572

See https://jenkins.softwareheritage.org/job/DTSCN/job/tests-on-diff/49/ for more details.

Looks good to me. So windows users will be able to use swh-scanner after that change, right ?

anlambert accepted this revision.Fri, Sep 11, 5:53 PM
This revision is now accepted and ready to land.Fri, Sep 11, 5:53 PM
tenma added a comment.Fri, Sep 11, 6:20 PM

That's just typing, so it could just theoretically crash mypy with non-POSIX paths.
In windows there are MS paths and POSIX paths, depending on the API used.
I don't think it may actually pose a problem because the distinction only exists at runtime, it is just... semantically invalid.

This revision was automatically updated to reflect the committed changes.