Skip to content

Commit

Permalink
Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalarico committed Aug 25, 2021
1 parent 2b72b0f commit 98d8c0f
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 76 deletions.
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,8 @@ format:
black .

docs:
bash -c "cd ./docs; make html"
open ./docs/build/html/index.html
@bash -c "./scripts/build_docs.sh"

clean:
python3 -c "import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]"
python3 -c "import pathlib; [p.rmdir() for p in pathlib.Path('.').rglob('pytest_cache')]"
rm -rdf ./docs/build
rm -rdf ./dist
rm -rdf ./build
rm -rdf ./htmlcov
rm -rdf pyairtable.egg-info
rm -rdf .pytest_cache
@bash -c "./scripts/clean.sh"

20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

36 changes: 0 additions & 36 deletions docs/make.bat

This file was deleted.

2 changes: 0 additions & 2 deletions pyairtable/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ def attachment(url: str, filename="") -> dict:
Airtable will download the file at the given url and keep its own copy of it.
All other attachment object properties will be generated server-side soon afterward.
..note ::
test
Note:
Attachment field values muest be **an array of objects**.
Expand Down
12 changes: 12 additions & 0 deletions scripts/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

sourceDir="docs/source"
buildDir="docs/build"

source ./scripts/console.sh

info 'Building Docs 📚'

python -m sphinx -a -W -E "$sourceDir" "$buildDir"
11 changes: 7 additions & 4 deletions scripts/bump.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash

source ./scripts/console.sh


function bump {
previousVersion=$( grep '^__version__' pyairtable/__init__.py | sed 's/__version__ = \"\(.*\)\"/\1/' )
previousVersion=$(echo -n "${previousVersion}")
echo "Enter Version [current is ${previousVersion}]:"
info "Enter Version [current is ${previousVersion}]:"
read version
if [ -z "$version" ]; then
echo "Empty version string - using existing"
info "Empty version string - using existing"
version="$previousVersion"
return
fi
Expand All @@ -15,8 +18,8 @@ function bump {
}

function confirmEval {
echo "CMD > $1"
echo "ENTER to confirm"
info "CMD > $1"
info "ENTER to confirm"
read foo
eval $1
}
Expand Down
14 changes: 14 additions & 0 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

source ./scripts/console.sh

info "Cleanning up files 🧹"

python3 -c "import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]"
python3 -c "import pathlib; [p.rmdir() for p in pathlib.Path('.').rglob('pytest_cache')]"
rm -rdf ./docs/build
rm -rdf ./dist
rm -rdf ./build
rm -rdf ./htmlcov
rm -rdf pyairtable.egg-info
rm -rdf .pytest_cache
29 changes: 29 additions & 0 deletions scripts/console.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

RED='\033[1;31m'
L_GREEN='\033[1;32m'
L_BLUE='\033[1;34m'
L_GREY='\033[0;37m'
WHITE='\033[1;37m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

console() {
local color=$1
local msg=$2
printf "${!color}${msg}${NC}\n"
}

error() {
local msg=$1
console 'RED' "==> $msg"
}

info() {
local msg=$1
console 'L_GREEN' "==> ${msg}"
}
warn() {
local msg=$1
console 'L_BLUE' "==> ${msg}"
}
10 changes: 10 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

source ./scripts/console.sh

info 'Formatting'

flake8 .
black --diff .
12 changes: 8 additions & 4 deletions scripts/githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/bash

echo "> Checking for breakpoints"
source ./scripts/console.sh

info 'Pre-Commit Hook'

info "Checking for breakpoints"

breakpoint=$(git grep breakpoint -- '*.py')
if [ -n "$breakpoint" ]
then
echo "COMMIT REJECTED: Please remove breakpoint before commiting."
echo $breakpoint
error "COMMIT REJECTED: Please remove breakpoint before commiting."
error $breakpoint
exit 1
fi

set -e

echo "> Linting"
make lint
make docs

0 comments on commit 98d8c0f

Please sign in to comment.