8000 Implemnted dynammic method generation · coffeepenbit/bookstack@ac63b0e · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit ac63b0e

Browse files
committed
Implemnted dynammic method generation
2 parents e9bc595 + 75b2d08 commit ac63b0e

File tree

10 files changed

+254
-143
lines changed

10 files changed

+254
-143
lines changed

.bumpversion.cfg

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
[bumpversion]
2-
current_version = 0.1.0-alpha.2
3-
commit = False
2+
current_version = 0.1.0-beta
3+
commit = True
44
tag = False
5-
6-
7-
parse =
8-
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) # major, minor and patch
9-
(?:\-(?P<pre>(?:alpha|beta|rc))\.(?P<prenum>\d+))? # pre-release
10-
11-
serialize =
12-
{major}.{minor}.{patch}-{pre}.{prenum}
13-
{major}.{minor}.{patch}-{pre}
14-
{major}.{minor}.{patch}
5+
parse =
6+
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) # major, minor and patch
7+
(?:\-(?P<pre>(?:alpha|beta|rc))(\.(?P<prenum>\d+))?)? # pre-release
8+
serialize =
9+
{major}.{minor}.{patch}-{pre}.{prenum}
10+
{major}.{minor}.{patch}-{pre}
11+
{major}.{minor}.{patch}
1512

1613
[bumpversion:part:pre]
17-
values =
18-
alpha
19-
beta
20-
rc
14+
values =
15+
alpha
16+
beta
17+
rc
2118

2219
[bumpversion:part:prenum]
2320
first_value = 1
2421

25-
2622
[bumpversion:file:src/bookstack/__version__.py]
2723

28-
[bumpversion:file:README.md]
24+
[bumpversion:file:README.md]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Project specific
22
tests/*
33
!tests/test_models.py
4+
!tests/test_readme.py
45

56
# Byte-compiled / optimized / DLL files
67
__pycache__/

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at coffeepenbit@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# bookstack
2-
*version: 0.1.0-alpha.2*
2+
*version: 0.1.0-beta*
33

44
**Please note that this project is currently in an unstable state. Please be patient.**
55

@@ -15,16 +15,35 @@ To use BookStack's API, you'll need to get a token ID and secret.
1515

1616
You can find how to get these values from your BookStack instance's doc page at `http[s]://<example.com>/api/docs`
1717

18+
**Note**: Your account's user group must have API usage priveleges enabled.
19+
1820
# Usage
1921
Once you've acquired your token ID and secret, you're ready to rock.
2022

2123
```python
22-
import bookstack
24+
>>> import bookstack
2325

2426
# Input the appropriate values for these three variables
25-
base_url = 'http[s]://<example.com>'
26-
token_id = '<token_id>'
27-
token_secret = '<token_secret>'
27+
>>> base_url = 'http[s]://<example.com>'
28+
>>> token_id = '<token_id>'
29+
>>> token_secret = '<token_secret>'
30+
31+
>>> api = bookstack.BookStack(base_url, token_id=token_id, token_secret=token_secret)
32+
```
33+
34+
This wrapper *dynamically* generates its API calls at runtime. To have the wrapper generate the methods, use:
35+
36+
```python
37+
>>> api.generate_api_methods()
38+
39+
>>> api.available_api_methods
40+
{'get_books_export_pdf', 'get_shelves_list', 'post_books_create', 'get_docs_display', 'delete_shelves_delete', 'get_books_list', 'get_docs_json', 'delete_books_delete', 'get_books_read', 'get_shelves_read', 'put_books_update', 'get_books_export_plain_text', 'get_books_export_html', 'post_shelves_create', ...}
41+
```
2842

29-
api = bookstack.BookStack(base_url, token_id=token_id, token_secret=token_secret)
30-
```
43+
The above are then the methods available to you, for example:
44+
45+
```python
46+
>>> books_list = api.get_books_list()
47+
>>> books_list['data'][0]['name']
48+
'Mathematics'
49+
```

setup.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
from setuptools import setup, find_packages
22
import os
33

4-
5-
here = os.path.abspath(os.path.dirname(__file__))
6-
7-
about = {}
8-
with open(os.path.join(here, 'src', 'bookstack', '__init__.py'), 'r', encoding='utf-8') as f:
9-
exec(f.read(), about)
10-
11-
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
12-
long_description = f.read()
13-
14-
install_requires = [
15-
'requests'
4+
CLASSIFIERS = [
5+
"Programming Language :: Python :: 3",
6+
"License :: OSI Approved :: MIT License",
E377 7+
"Operating System :: OS Independent",
168
]
17-
18-
extras_require = {
9+
EXTRAS_REQUIRE = {
1910
'dev': [
2011
'bump2version',
2112
'pylint',
@@ -25,24 +16,44 @@
2516
'tox'
2617
]
2718
}
19+
INSTALL_REQUIRES = [
20+
'requests>= 2.18, < 3',
21+
'cached_property >= 1.5, < 2',
22+
'inflection == 0.4'
23+
]
24+
2825

26+
def get_about(here):
27+
about = {}
28+
about_info_path = os.path.join(here, 'src', 'bookstack', '__version__.py')
29+
with open(about_info_path,'r', encoding='utf-8' ) as f:
30+
exec(f.read(), about)
31+
32+
return about
33+
34+
def get_long_description(here):
35+
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
36+
long_description = f.read()
37+
38+
return long_description
39+
40+
41+
here = os.path.abspath(os.path.dirname(__file__))
42+
about = get_about(here)
2943

3044
setup(
3145
name=about['__title__'],
3246
version=about['__version__'],
3347
url=about['__url__'],
3448
description=about['__description__'],
35-
long_description=long_description,
49+
long_description=get_long_description(here),
3650
author=about['__author__'],
3751
author_email=about['__author_email__'],
3852
long_description_content_type='text/markdown',
3953
packages=find_packages('src'),
4054
package_dir={'': 'src'},
41-
install_requires=install_requires,
42-
extras_require=extras_require,
43-
classifiers=[
44-
"Programming Language :: Python :: 3",
45-
"License :: OSI Approved :: MIT License",
46-
"Operating System :: OS Independent",
47-
]
55+
python_requires='>=3.6',
56+
install_requires=INSTALL_REQUIRES,
57+
extras_require=EXTRAS_REQUIRE,
58+
classifiers=CLASSIFIERS
4859
)

src/bookstack/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__maintainer__ = 'coffeepenbit'
55
__title__ = 'bookstack'
66
__url__ = "https://github.com/coffeepenbit/bookstack"
7-
__version__ = '0.1.0-alpha.2'
7+
__version__ = '0.1.0-beta'

0 commit comments

Comments
 (0)
0