-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# cli-tools | ||
toy project for learning different languages | ||
|
||
This project is meant to have a set of projects that can be implemented in different languages. The projects are practical and use eachother. | ||
|
||
## Projects | ||
|
||
1. hashFile - hash the content of a file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
venv | ||
.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Hashfile | ||
|
||
## Installation | ||
|
||
``` | ||
python3 -m venv venv | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Run | ||
|
||
``` | ||
source venv/bin/activate | ||
bash run.sh | ||
``` | ||
|
||
## Test | ||
|
||
``` | ||
bash test.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest | ||
click |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python src/__init__.py $1 |
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from io import BufferedReader | ||
import click | ||
import hashlib | ||
|
||
@click.command() | ||
@click.argument("filepath") | ||
def hashFile(filepath:click.File): | ||
"""Hash the content of the file""" | ||
f = open(filepath, "rb").read() | ||
hash = hashlib.sha256(f).hexdigest() | ||
click.echo(hash) | ||
|
||
if __name__ == '__main__': | ||
hashFile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest tests/ |
Empty file.
Binary file not shown.
Binary file added
BIN
+2.52 KB
hashFile/tests/__pycache__/test_hashFile.cpython-311-pytest-8.1.1.pyc
Binary file not shown.
Binary file added
BIN
+2.37 KB
hashFile/tests/__pycache__/test_helloWorld.cpython-311-pytest-8.1.1.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from click.testing import CliRunner | ||
from src.hashFile import hashFile | ||
|
||
def test(): | ||
runner = CliRunner() | ||
result = runner.invoke(hashFile, ['tests/trivial/input']) | ||
assert result.output == open('tests/trivial/output', "r").read() + "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e |