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

Make the Documentation #1

Merged
merged 32 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b6ede7b
updated docstrings
juliotux Oct 15, 2023
2eaf059
add dependencies for docs
juliotux Oct 15, 2023
b99fea7
first scketch of the docs
juliotux Oct 15, 2023
6eb3fbe
gitignore generated files
juliotux Oct 15, 2023
0f92cf4
removed matplotlib sphinx dependency
juliotux Oct 15, 2023
16c7599
rtd building
juliotux Oct 15, 2023
b2df75b
updated general readme
juliotux Oct 15, 2023
88a1331
just more general comments
juliotux Oct 15, 2023
d928816
api: remove inheritance diagram
juliotux Oct 15, 2023
3e0f147
improve docstrings of SQLTable
juliotux Oct 15, 2023
3dd95a9
improved docstrings of SQLRow and SQLColumn
juliotux Oct 15, 2023
9a06aa7
add structure to general usage
juliotux Oct 15, 2023
785ec9b
more structure chnges
juliotux Oct 15, 2023
25d4afe
update sanitizer to more sql standards
juliotux Oct 15, 2023
214fae8
fix b32 padding
juliotux Oct 15, 2023
b0e3812
test length of b32 encoding
juliotux Oct 15, 2023
07dc93e
non-conformant names docs
juliotux Oct 15, 2023
ba75cb0
general usage title
juliotux Oct 15, 2023
dcd9c18
run pytest on docs
juliotux Oct 15, 2023
0ebf4d0
update docs action
juliotux Oct 15, 2023
a3e7bd3
ignore files that may be created during tests
juliotux Oct 15, 2023
7824d8b
SQLTable: __setitem__ with add_column
juliotux Oct 15, 2023
30caa0c
fix nonconformant doctests
juliotux Oct 15, 2023
8420cba
fix more tests
juliotux Oct 15, 2023
102d0ad
complete skip publish if not at main
juliotux Oct 15, 2023
86d9e55
fix pep8 in tests
juliotux Oct 15, 2023
717293a
raise tests
juliotux Oct 15, 2023
8b7d63f
changed some reprs and buggy behavior
juliotux Oct 18, 2023
3b48c8f
general usage documentation
juliotux Oct 18, 2023
69a54b4
SQLRow: mimic dict keys and items
juliotux Oct 18, 2023
514e58c
viewer classes docs
juliotux Oct 18, 2023
ea0e5fa
where statements doc
juliotux Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Documentation Building

on:
pull_request:
push:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: 0 7 * * 1 # 7 A.M. mon

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
tests:
name: Docs Building
runs-on: ubuntu-latest
if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))"

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
cache-dependency-path: '**/pyproject.toml'
- name: Install base dependencies
run: pip install -U -q pip setuptools
- name: Install package dependencies
run: pip install -U -q .[docs]
- name: Build with Sphinx
run: |
cd docs
make html

doctest:
name: Documentation Testing
runs-on: ubuntu-latest
if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))"

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
cache-dependency-path: '**/pyproject.toml'
- name: Install base dependencies
run: pip install -U -q pip setuptools
- name: Install pytest
run: pip install -U -q pytest pytest-doctestplus
- name: Install package dependencies
run: pip install -U .[docs] .[test]
- name: Run pytest on docs
run: pytest --doctest-rst --doctest-plus docs
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
publish-pypi:
name: Build and publish to PyPi
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@master
with:
Expand All @@ -41,7 +42,6 @@ jobs:
--wheel
--outdir dist/
- name: Publish package to PyPi
if: github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.vscode
version.py
# files that may be created during tests
*.db

# docs generated files
docs/_build
docs/api

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
30 changes: 30 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: .
extra_requirements:
- docs
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DBasTable

[![Unit Tests](https://github.com/juliotux/DBasTable/actions/workflows/unittests.yml/badge.svg)](https://github.com/juliotux/DBasTable/actions/workflows/unittests.yml) [![codecov](https://codecov.io/gh/juliotux/DBasTable/graph/badge.svg?token=r9kulm3ANZ)](https://codecov.io/gh/juliotux/DBasTable)
[![Unit Tests](https://github.com/juliotux/DBasTable/actions/workflows/unittests.yml/badge.svg)](https://github.com/juliotux/DBasTable/actions/workflows/unittests.yml) [![codecov](https://codecov.io/gh/juliotux/DBasTable/graph/badge.svg?token=r9kulm3ANZ)](https://codecov.io/gh/juliotux/DBasTable) [![Documentation Status](https://readthedocs.org/projects/dbastable/badge/?version=latest)](https://dbastable.readthedocs.io/en/latest/?badge=latest)

A simplier way to access SQLite tables, just like Numpy structured arrarys or Pandas dataframes.

Expand Down Expand Up @@ -29,3 +29,41 @@ As menioned above, we intended to perform only simple operations with this packa
I'm not a SQL master, nor a digital security guru. I'm an astrophysicist that do some python. So, if you want to use it, use with care.

# Install and Documentation

## Installation

The easiest way to install dbastable is via [pip](https://pip.pypa.io/en/stable/)

```
pip install dbastable
```

Alternatively, you can clone the repository and install it manually:

```
git clone
cd dbastable
pip install -U .
```

or

```
pip install -U git+https://github.com/juliotux/dbastable
```

Development version is also available in pip:

```
pip install -U --pre dbastable
```


## Documentation


The documentation is available at https://dbastable.readthedocs.io/en/latest/

# License

`dbastable` is licensed under the terms of the [MIT license](https://opensource.org/license/mit/). See the file `LICENSE` for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
10 changes: 6 additions & 4 deletions dbastable/_sanitizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import base64
import math

from ._def import _B32_COL_PREFIX, _ID_KEY

Expand All @@ -9,8 +10,8 @@ def _colname_to_b32_decode(string):
# ensure remove the prefix
string = string.lstrip(_B32_COL_PREFIX)
# base32 need 8 chars padding
remainder = len(string) % 8
string += '='*(8-remainder)
pad = math.ceil(len(string) / 8) * 8 - len(string)
string += '='*pad
return string


Expand All @@ -36,12 +37,13 @@ def _sanitize_key(self, key):
# TODO: check for protected names
if key.startswith(_B32_COL_PREFIX) or key == _ID_KEY:
raise ValueError(f'{key} uses a protected name.')
if len([ch for ch in key if not ch.isalnum() and ch != '_']) != 0:
if len([ch for ch in key if not ch.isalnum() and ch != '_']) != 0 \
or key[0].isdigit():
# if a name is invalid, encode it in base32 and add a prefix
# if it is allowed
if self._allow_b32_colnames:
return self._encode_b32(key)
raise ValueError(f'Invalid column name: {key}.')
raise ValueError(f'Invalid column name: {key}')
return key.lower()

def _sanitize_colnames(self, data):
Expand Down
Loading