Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnsureHashAlgorithm #492

Merged
merged 8 commits into from
Oct 21, 2023
Merged

Add EnsureHashAlgorithm #492

merged 8 commits into from
Oct 21, 2023

Commits on May 15, 2023

  1. Create EnsureHashAlgorithm based on EnsureChoice

    This adds EnsureHashAlgorithm constraint which checks whether the
    given algorith name is contained in hashlib's algorithms_guaranteed
    set. It derives from EnsureChoice without further customization.
    
    Using `algorithms_guaranteed` covers algorithms that have named
    constructors in hashlib, i.e. accessible through getattr(hashlib,
    name) - that's the current usage in MultiHash. Future expansion could
    see us move to algorithms_available - these will be recognized when
    passed to (slower) hashlib.new(), but have no named constructors.
    
    For details, see: https://docs.python.org/3.11/library/hashlib.html
    mslw committed May 15, 2023
    Configuration menu
    Copy the full SHA
    2fa7b99 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2023

  1. Fix EnsureHashAlgorithm & use EnsureListOf

    The EnsureHash algorithm now calls its super.__init__ correctly.
    
    We use EnsureHashAlgorithm() | EnsureListOf(...) in ls_file_colelction
    now. This correctly handles incoming values, which are always a list
    in CLI (argparse behaviour with --append) and can be str or list in
    Python API. At least when they are OK.
    
    When input is not OK, two things are suboptimal:
    - an incorrect hash (str) proceeds to EnsureListOf, which tries to go
      letter by letter, failing on first
    - a hash (list) with an incorrect value would first fail on
      EnsureHashAlgorithm(list), proceed to EnsureListOf, and fail on
      EnsureHashAlgorithm(str)
    As a conequence, in both cases the error message would say "does not
    match any of 2 alternatives" and print EnsureChoice message ("is not
    one of ...") twice.
    mslw committed May 16, 2023
    Configuration menu
    Copy the full SHA
    632facb View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2023

  1. Apply @mih's patch from comment for improved error

    as suggested in
    datalad#346 (comment)
    mih authored and adswa committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    0f04769 View commit details
    Browse the repository at this point in the history

Commits on Oct 20, 2023

  1. Configuration menu
    Copy the full SHA
    b27725a View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2023

  1. Configuration menu
    Copy the full SHA
    b27f292 View commit details
    Browse the repository at this point in the history
  2. Add changelog

    mih committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    6788864 View commit details
    Browse the repository at this point in the history
  3. Minor tuning, documentation

    mih committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    666977d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4e04ec8 View commit details
    Browse the repository at this point in the history