You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Return checksum for single file as input
* Add warning that ignore/include flags are ignored for single file input
* Tests for single file as input
* Update documentation to reflect single-file ability
* Ensure input to gather_file_paths is a directory
* Test directory requirement for gather_file_paths
---------
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
Length of the digest for SHAKE (required) or BLAKE (optional) algorithms in bytes
37
38
```
38
39
39
40
> Note: The available algorithms are determined by those available to `hashlib` and may vary depending on your system and OpenSSL version, so the set shown on your system with `sum-buddy -h` may be different from above. At a minimum, it should include: `{blake2s, blake2b, md5, sha1, sha224, sha256, sha384, sha512, sha3_224, sha3_256, sha3_384, sha3_512, shake_128, shake_256}`, which is given by `hashlib.algorithms_guaranteed`.
@@ -136,24 +137,24 @@ We expose three functions to be used in your Python code:
136
137
```python
137
138
from sumbuddy import get_checksums, gather_file_paths, checksum_file
Generate a CSV file with the filepath, filename, and checksum of all files in the input directory according to patterns to ignore. Checksum column is labeled by the selected algorithm (e.g., 'md5' or 'sha256').
15
15
16
16
Parameters:
17
17
------------
18
-
input_directory - String. Directory to traverse for files.
18
+
input_path - String. File or directory to traverse for files.
19
19
output_filepath - String [optional]. Filepath for the output CSV file. Defaults to None, i.e. output will be to stdout.
20
20
ignore_file - String [optional]. Filepath for the ignore patterns file.
21
21
include_hidden - Boolean [optional]. Whether to include hidden files. Default is False.
22
22
algorithm - String. Algorithm to use for checksums. Default: 'md5', see options with 'hashlib.algorithms_available'.
23
23
length - Integer [conditionally optional]. Length of the digest for SHAKE (required) and BLAKE (optional) algorithms in bytes.
parser=argparse.ArgumentParser(description="Generate CSV with filepath, filename, and checksums for all files in a given directory")
60
-
parser.add_argument("input_dir", help="Directory to traverse for files")
66
+
67
+
parser=argparse.ArgumentParser(description="Generate CSV with filepath, filename, and checksums for all files in a given directory (or a single file)")
68
+
parser.add_argument("input_path", help="File or directory to traverse for files")
61
69
parser.add_argument("-o", "--output-file", help="Filepath for the output CSV file; defaults to stdout", default=None)
62
70
group=parser.add_mutually_exclusive_group()
63
71
group.add_argument("-i", "--ignore-file", help="Filepath for the ignore patterns file")
message=f"The directory {input_directory} and subdirectories (if any) contain no files. \nPlease provide a directory with files."
4
4
super().__init__(message)
5
5
6
+
classNotADirectoryError(Exception):
7
+
def__init__(self, input_directory):
8
+
message=f"The input path '{input_directory}' is not a directory. \nPlease provide a directory with files."
9
+
super().__init__(message)
10
+
6
11
classNoFilesAfterFilteringError(Exception):
7
12
def__init__(self, input_directory, ignore_file):
8
13
message=f"The directory {input_directory} contains files, but all are filtered out. \nCheck patterns in your {ignore_file} file and/or hidden files settings."
0 commit comments