memberjojo 1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- memberjojo-1.2/LICENSE +21 -0
- memberjojo-1.2/PKG-INFO +123 -0
- memberjojo-1.2/README.md +99 -0
- memberjojo-1.2/pyproject.toml +47 -0
- memberjojo-1.2/src/memberjojo/__init__.py +12 -0
- memberjojo-1.2/src/memberjojo/_version.py +34 -0
- memberjojo-1.2/src/memberjojo/config.py +5 -0
- memberjojo-1.2/src/memberjojo/mojo_common.py +55 -0
- memberjojo-1.2/src/memberjojo/mojo_member.py +355 -0
- memberjojo-1.2/src/memberjojo/mojo_transaction.py +242 -0
- memberjojo-1.2/tests/test_mojo_members.py +205 -0
- memberjojo-1.2/tests/test_mojo_members_iter.py +66 -0
- memberjojo-1.2/tests/test_mojo_transactions.py +240 -0
- memberjojo-1.2/tests/test_version.py +27 -0
memberjojo-1.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Duncan Bellamy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
memberjojo-1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memberjojo
|
|
3
|
+
Version: 1.2
|
|
4
|
+
Summary: memberjojo - tools for working with members.
|
|
5
|
+
Author-email: Duncan Bellamy <dunk@denkimushi.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: coverage ; extra == "dev"
|
|
11
|
+
Requires-Dist: flit ; extra == "dev"
|
|
12
|
+
Requires-Dist: pytest ; extra == "dev"
|
|
13
|
+
Requires-Dist: furo ; extra == "docs"
|
|
14
|
+
Requires-Dist: myst-parser>=2.0 ; extra == "docs"
|
|
15
|
+
Requires-Dist: sphinx>=7.0 ; extra == "docs"
|
|
16
|
+
Requires-Dist: sphinx-autodoc-typehints ; extra == "docs"
|
|
17
|
+
Requires-Dist: black ; extra == "lint"
|
|
18
|
+
Requires-Dist: pylint ; extra == "lint"
|
|
19
|
+
Project-URL: Home, https://github.com/a16bitsysop/memberjojo
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Provides-Extra: docs
|
|
22
|
+
Provides-Extra: lint
|
|
23
|
+
|
|
24
|
+
# memberjojo
|
|
25
|
+
|
|
26
|
+
`memberjojo` is a Python library for managing [Membermojo](http://membermojo.co.uk/)
|
|
27
|
+
data from CSV imports.\
|
|
28
|
+
It provides member database interactions, and transaction querying.\
|
|
29
|
+
This is done in a local SQLite database, and does not alter anything on Membermojo.\
|
|
30
|
+
It provides tools to load, and query membership and transaction data efficiently
|
|
31
|
+
without having to use SQLite directly.\
|
|
32
|
+
When importing CSV files existing entries are skipped, so you can just import the
|
|
33
|
+
latest download and the local database is updated with new entries.\
|
|
34
|
+
All the transaction data is imported into the database,
|
|
35
|
+
but currently only a limited amount of member data is imported.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
Install via `pip`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install memberjojo
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or clone the repo and install locally with `flit`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/a16bitsysop/memberjojo.git
|
|
51
|
+
cd memberjojo
|
|
52
|
+
flit install --symlink
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
Example loading members and using Member objects:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from pathlib import Path
|
|
61
|
+
from membermojo import Member
|
|
62
|
+
|
|
63
|
+
# database is created if it does not exist
|
|
64
|
+
member_database_path = Path(Path(__file__).parent, "database", "my-members.db")
|
|
65
|
+
member_csv_path = Path("download", "members.csv")
|
|
66
|
+
|
|
67
|
+
members = Member(member_database_path)
|
|
68
|
+
members.import_csv(member_csv_path)
|
|
69
|
+
|
|
70
|
+
for member in members:
|
|
71
|
+
print(member.first_name, member.last_name, member.member_num)
|
|
72
|
+
|
|
73
|
+
# Get full name for a given member number
|
|
74
|
+
found_name = members.get_name(1)
|
|
75
|
+
if found_name:
|
|
76
|
+
print(f"Member with id of 1 is {found_name}")
|
|
77
|
+
else:
|
|
78
|
+
print("Member 1 does not exist")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Documentation
|
|
82
|
+
|
|
83
|
+
Full documentation is available at
|
|
84
|
+
👉 [https://a16bitsysop.github.io/memberjojo/](https://a16bitsysop.github.io/memberjojo/)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Running Tests
|
|
89
|
+
|
|
90
|
+
Run tests:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pytest
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Contributing
|
|
97
|
+
|
|
98
|
+
Contributions are welcome! Please:
|
|
99
|
+
|
|
100
|
+
1. Fork the repo
|
|
101
|
+
2. Create your feature branch `git checkout -b my-feature`
|
|
102
|
+
3. Edit the source code to add and test your changes
|
|
103
|
+
4. Commit your changes `git commit -m 'Add some feature'`
|
|
104
|
+
5. Push to your branch `git push origin my-feature`
|
|
105
|
+
6. Open a Pull Request
|
|
106
|
+
|
|
107
|
+
Please follow the existing code style and write tests for new features.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
This project is licensed under the MIT [MIT License](https://github.com/a16bitsysop/memberjojo/blob/main/LICENSE).
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Contact
|
|
118
|
+
|
|
119
|
+
Created and maintained by Duncan Bellamy.
|
|
120
|
+
Feel free to open issues or reach out on GitHub.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
memberjojo-1.2/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# memberjojo
|
|
2
|
+
|
|
3
|
+
`memberjojo` is a Python library for managing [Membermojo](http://membermojo.co.uk/)
|
|
4
|
+
data from CSV imports.\
|
|
5
|
+
It provides member database interactions, and transaction querying.\
|
|
6
|
+
This is done in a local SQLite database, and does not alter anything on Membermojo.\
|
|
7
|
+
It provides tools to load, and query membership and transaction data efficiently
|
|
8
|
+
without having to use SQLite directly.\
|
|
9
|
+
When importing CSV files existing entries are skipped, so you can just import the
|
|
10
|
+
latest download and the local database is updated with new entries.\
|
|
11
|
+
All the transaction data is imported into the database,
|
|
12
|
+
but currently only a limited amount of member data is imported.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Install via `pip`:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install memberjojo
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or clone the repo and install locally with `flit`:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/a16bitsysop/memberjojo.git
|
|
28
|
+
cd memberjojo
|
|
29
|
+
flit install --symlink
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Example loading members and using Member objects:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
from membermojo import Member
|
|
39
|
+
|
|
40
|
+
# database is created if it does not exist
|
|
41
|
+
member_database_path = Path(Path(__file__).parent, "database", "my-members.db")
|
|
42
|
+
member_csv_path = Path("download", "members.csv")
|
|
43
|
+
|
|
44
|
+
members = Member(member_database_path)
|
|
45
|
+
members.import_csv(member_csv_path)
|
|
46
|
+
|
|
47
|
+
for member in members:
|
|
48
|
+
print(member.first_name, member.last_name, member.member_num)
|
|
49
|
+
|
|
50
|
+
# Get full name for a given member number
|
|
51
|
+
found_name = members.get_name(1)
|
|
52
|
+
if found_name:
|
|
53
|
+
print(f"Member with id of 1 is {found_name}")
|
|
54
|
+
else:
|
|
55
|
+
print("Member 1 does not exist")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
Full documentation is available at
|
|
61
|
+
👉 [https://a16bitsysop.github.io/memberjojo/](https://a16bitsysop.github.io/memberjojo/)
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Running Tests
|
|
66
|
+
|
|
67
|
+
Run tests:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pytest
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Contributing
|
|
74
|
+
|
|
75
|
+
Contributions are welcome! Please:
|
|
76
|
+
|
|
77
|
+
1. Fork the repo
|
|
78
|
+
2. Create your feature branch `git checkout -b my-feature`
|
|
79
|
+
3. Edit the source code to add and test your changes
|
|
80
|
+
4. Commit your changes `git commit -m 'Add some feature'`
|
|
81
|
+
5. Push to your branch `git push origin my-feature`
|
|
82
|
+
6. Open a Pull Request
|
|
83
|
+
|
|
84
|
+
Please follow the existing code style and write tests for new features.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
This project is licensed under the MIT [MIT License](https://github.com/a16bitsysop/memberjojo/blob/main/LICENSE).
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Contact
|
|
95
|
+
|
|
96
|
+
Created and maintained by Duncan Bellamy.
|
|
97
|
+
Feel free to open issues or reach out on GitHub.
|
|
98
|
+
|
|
99
|
+
---
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_scm",]
|
|
3
|
+
build-backend = "flit_scm:buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "memberjojo"
|
|
7
|
+
authors = [{name = "Duncan Bellamy", email = "dunk@denkimushi.com"}]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
dynamic = ["version", "description"]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Home = "https://github.com/a16bitsysop/memberjojo"
|
|
16
|
+
|
|
17
|
+
[project.optional-dependencies]
|
|
18
|
+
dev = [
|
|
19
|
+
"coverage",
|
|
20
|
+
"flit",
|
|
21
|
+
"pytest",
|
|
22
|
+
]
|
|
23
|
+
lint = [
|
|
24
|
+
"black",
|
|
25
|
+
"pylint",
|
|
26
|
+
]
|
|
27
|
+
docs = [
|
|
28
|
+
"furo", # HTML theme
|
|
29
|
+
"myst-parser>=2.0", # For Markdown support
|
|
30
|
+
"sphinx>=7.0",
|
|
31
|
+
"sphinx-autodoc-typehints", # For cleaner type hints in docs
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[tool.flit.sdist]
|
|
35
|
+
exclude = ["**/.DS_Store"]
|
|
36
|
+
include = ["tests", "src/memberjojo/_version.py"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools_scm]
|
|
39
|
+
write_to = "src/memberjojo/_version.py"
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
pythonpath = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.pylint.main]
|
|
45
|
+
output-format = "colorized"
|
|
46
|
+
verbose = true
|
|
47
|
+
ignore-patterns = ["_version.py"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
memberjojo - tools for working with members.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from ._version import version as __version__
|
|
7
|
+
except ModuleNotFoundError:
|
|
8
|
+
# _version.py is written when building dist
|
|
9
|
+
__version__ = "0.0.0+local"
|
|
10
|
+
|
|
11
|
+
from .mojo_member import Member, MemberData
|
|
12
|
+
from .mojo_transaction import Transaction
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '1.2'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 2)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = 'g30b3ecb9d'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MojoSkel base class
|
|
3
|
+
|
|
4
|
+
This module provides a common base class (`MojoSkel`) for other `memberjojo` modules.
|
|
5
|
+
It includes helper methods for working with SQLite databases.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sqlite3
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MojoSkel:
|
|
12
|
+
"""
|
|
13
|
+
Establishes a connection to a SQLite database and provides helper methods
|
|
14
|
+
for querying tables.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, db_path: str, table_name: str):
|
|
18
|
+
"""
|
|
19
|
+
Initialize the MojoSkel class.
|
|
20
|
+
|
|
21
|
+
Connects to the SQLite database and sets the row factory for
|
|
22
|
+
dictionary-style access to columns.
|
|
23
|
+
|
|
24
|
+
:param db_path: Path to the SQLite database file.
|
|
25
|
+
:param table_name: Name of the table to operate on, or create when importing.
|
|
26
|
+
"""
|
|
27
|
+
self.conn = sqlite3.connect(db_path)
|
|
28
|
+
|
|
29
|
+
self.conn.row_factory = sqlite3.Row
|
|
30
|
+
self.cursor = self.conn.cursor()
|
|
31
|
+
self.table_name = table_name
|
|
32
|
+
|
|
33
|
+
def show_table(self, limit: int = 2):
|
|
34
|
+
"""
|
|
35
|
+
Print the first few rows of the table as dictionaries.
|
|
36
|
+
|
|
37
|
+
:param limit: (optional) Number of rows to display. Defaults to 2.
|
|
38
|
+
"""
|
|
39
|
+
self.cursor.execute(f'SELECT * FROM "{self.table_name}" LIMIT ?', (limit,))
|
|
40
|
+
rows = self.cursor.fetchall()
|
|
41
|
+
|
|
42
|
+
if not rows:
|
|
43
|
+
print("(No data)")
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
for row in rows:
|
|
47
|
+
print(dict(row))
|
|
48
|
+
|
|
49
|
+
def count(self) -> int:
|
|
50
|
+
"""
|
|
51
|
+
Returns count of the number of rows in the table.
|
|
52
|
+
"""
|
|
53
|
+
self.cursor.execute(f'SELECT COUNT(*) FROM "{self.table_name}"')
|
|
54
|
+
result = self.cursor.fetchone()
|
|
55
|
+
return result[0] if result else 0
|