Skip to content

Commit

Permalink
⚡ major dev changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MaaniBeigy committed Aug 10, 2024
1 parent cef617f commit 2b82580
Show file tree
Hide file tree
Showing 30 changed files with 721 additions and 722 deletions.
Binary file modified .logs/mypy.txt
Binary file not shown.
Binary file modified .logs/pylint-log.txt
Binary file not shown.
Binary file added .logs/safety.json
Binary file not shown.
Binary file modified .logs/safety.txt
Binary file not shown.
25 changes: 25 additions & 0 deletions .shell/mypy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Find and delete files named 'mypy.txt'
Get-ChildItem -Path . -Recurse -Filter 'mypy.txt' | Remove-Item -Force

# Find and delete files named 'mypy.svg'
Get-ChildItem -Path . -Recurse -Filter 'mypy.svg' | Remove-Item -Force

# Run mypy using poetry and save the output to a log file
poetry run mypy --config-file pyproject.toml ./ | Tee-Object -FilePath ".logs/mypy.txt"

# Extract the mypy result from the log file
$mypy_result = Select-String -Path ".logs/mypy.txt" -Pattern 'Success' | ForEach-Object {
$_.Line -split ' ' | Select-Object -First 1
} | ForEach-Object {
$_ -replace ':', ''
}

# Output the mypy result (for verification)
Write-Output "mypy_result: $mypy_result"

# Remove the old mypy.svg file
Remove-Item -Path "assets/images/mypy.svg" -Force -Recurse

# Generate the mypy badge using pybadges and save it to a file
$command = "poetry run python -m pybadges --left-text='mypy' --right-color='brightgreen' --right-text=$mypy_result --embed-logo >> assets/images/mypy.svg"
Invoke-Expression $command
22 changes: 22 additions & 0 deletions .shell/pylint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Find and delete files named 'pylint-log.txt'
Get-ChildItem -Path . -Recurse -Filter 'pylint-log.txt' | Remove-Item -Force

# Find and delete files named 'pylint.svg'
Get-ChildItem -Path . -Recurse -Filter 'pylint.svg' | Remove-Item -Force

# Run pylint using poetry and save the output to a log file
poetry run pylint pycvcqv | Tee-Object -FilePath ".logs/pylint-log.txt"

# Extract the lint score from the log file
$lintscore = Select-String -Path ".logs/pylint-log.txt" -Pattern 'rated at' | ForEach-Object {
$_.Line -split ' ' | Select-Object -Index 6
} | ForEach-Object {
$_ -split '/' | Select-Object -First 1
}

# Output the lint score (for verification)
Write-Output "lintscore: $lintscore"

# Generate the pylint badge using anybadge and save it to a file
$command = "poetry run python -m anybadge -o --value=$lintscore --file=assets/images/pylint.svg pylint"
Invoke-Expression $command
19 changes: 19 additions & 0 deletions .shell/safety.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Read the JSON file content
$jsonContent = Get-Content -Path ".logs/safety.json" -Raw

# Parse the JSON content
$jsonObject = $jsonContent | ConvertFrom-Json

# Extract the value
$vulnerabilities_found = $jsonObject.report_meta.vulnerabilities_found

# Output the value
Write-Output $vulnerabilities_found

# Remove the old vulnerabilities.svg file
Remove-Item -Path "assets/images/vulnerabilities.svg" -Force -Recurse

# Run the Python command using poetry and the extracted value
# Note: Make sure 'poetry' and 'python3' are in your system's PATH
$command = "poetry run python -m pybadges --left-text='vulnerabilities' --right-text='$vulnerabilities_found' --left-color='#40aef9' --right-color='#0c2739' --logo=assets/images/safety.png --embed-logo >> assets/images/vulnerabilities.svg"
Invoke-Expression $command
4 changes: 2 additions & 2 deletions .shell/safety.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
find . -name 'safety.txt' -delete
find . -name 'vulnerabilities.svg' -delete
poetry run safety check --output text > .logs/safety.txt
poetry run safety check --output json > .logs/safety.json
poetry run safety check --policy-file safety_policy.yml --output text > .logs/safety.txt
poetry run safety check --policy-file safety_policy.yml --output json > .logs/safety.json
vulnerabilities_found=$(jq -r '.report_meta.vulnerabilities_found' .logs/safety.json)
export VULNERABILITIES_FOUND=$vulnerabilities_found
echo "vulnerabilities:" $VULNERABILITIES_FOUND
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mypy:
.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report
poetry run safety check --policy-file safety_policy.yml --full-report
poetry run bandit -ll --recursive pycvcqv tests

.PHONY: lint
Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
[![Security: bandit](https://img.shields.io/badge/security-bandit-green.svg)](https://github.com/PyCQA/bandit)
[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/MaaniBeigy/pycvcqv/blob/master/.pre-commit-config.yaml)
[![License](https://img.shields.io/github/license/MaaniBeigy/pycvcqv)](https://github.com/MaaniBeigy/pycvcqv/blob/master/LICENSE)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FMaaniBeigy%2Fpycvcqv.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FMaaniBeigy%2Fpycvcqv?ref=badge_shield)

Coefficient of Variation (CV) and Coefficient of Quartile Variation (CQV) with Confidence Intervals (CI)

Expand All @@ -30,7 +29,7 @@ Python port of [cvcqv](https://github.com/MaaniBeigy/cvcqv)
## Introduction

`pycvcqv` provides some easy-to-use functions to calculate the
Coefficient of Variation (`cv`) and Coefficient of Quartile Variation (`cqv`)
Coefficient of Variation (`cv`) and Coefficient of Quartile Variation (`cqv`)
with confidence intervals provided with all available methods.

## Install
Expand Down Expand Up @@ -74,6 +73,7 @@ cqv(data=data, num_threads=-1)
## For contributors

### Testing

#### Linux

```bash
Expand All @@ -92,6 +92,7 @@ pre-commit run --all-files
```powershell
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
```

2. Find the poetry installation directory:

```text
Expand Down Expand Up @@ -138,7 +139,7 @@ poetry run pytest --cov-report term --cov pycvcqv tests/
poetry run coverage-badge -o assets/images/coverage.svg -f
```

8. Codestyle check
8. Code-style check

```powershell
poetry run pyupgrade --exit-zero-even-if-changed --py37-plus
Expand All @@ -151,7 +152,7 @@ poetry run darglint --verbosity 2 pycvcqv tests

```powershell
poetry check
poetry run safety check --full-report
poetry run safety check --policy-file safety_policy.yml --output json > .logs/safety.json
poetry run bandit -ll --recursive pycvcqv tests
```

Expand All @@ -167,11 +168,5 @@ git push -u origin main

## Credits

[![🚀 Your next Python package needs a bleeding-edge project structure.](https://img.shields.io/badge/python--package--template-%F0%9F%9A%80-brightgreen)](https://github.com/TezRomacH/python-package-template)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FMaaniBeigy%2Fpycvcqv.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FMaaniBeigy%2Fpycvcqv?ref=badge_shield)

[![🚀 Your next Python package needs a bleeding-edge project structure.](https://img.shields.io/badge/python--package--template-%F0%9F%9A%80-brightgreen)](https://github.com/TezRomacH/python-package-template)
This project was generated with [`python-package-template`](https://github.com/TezRomacH/python-package-template)

## License

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FMaaniBeigy%2Fpycvcqv.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FMaaniBeigy%2Fpycvcqv?ref=badge_large)
Binary file modified assets/images/mypy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 0 additions & 23 deletions assets/images/pylint.svg

This file was deleted.

Binary file modified assets/images/vulnerabilities.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b82580

Please sign in to comment.