Skip to content

Commit df497c3

Browse files
committed
add: PyPI
1 parent 5b3de1d commit df497c3

File tree

9 files changed

+101
-48
lines changed

9 files changed

+101
-48
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ dmypy.json
131131

132132
# project
133133
*.sh
134+
135+
.idea/

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
# githubapps.py
1+
# githubapps.py
2+
3+
A Python wrapper for the Github Apps API
4+
5+
# installing
6+
Install and update using pip:
7+
8+
`pip install githubapps.py`
9+
10+
A simple example.
11+
12+
```python
13+
import githubapps
14+
def main():
15+
with open('env/private.key', 'rb') as f_private:
16+
private_key = f_private.read()
17+
with open('env/app_id.key', 'r') as f_app_id:
18+
app_id = f_app_id.read()
19+
with open('env/installation_id.key', 'r') as f_installation_id:
20+
installation_id = f_installation_id.read()
21+
client_secret = private_key
22+
auth = githubapps.Auth(app_id, installation_id, client_secret)
23+
access_token = auth.get_access_token()
24+
print(access_token)
25+
```

example/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PyJWT
2+
aiohttp
3+
requests
4+
cryptography
5+
PyGithub

example/test.py

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11

2-
import githubapp
2+
import githubapps
33
from github import Github
44

55
# using an access token
66

7+
78
def main():
89

9-
with open('env/private.key', 'rb') as f_private:
10-
private_key = f_private.read()
11-
with open('env/app_id.key', 'r') as f_app_id:
12-
app_id = f_app_id.read()
13-
with open('env/installation_id.key', 'r') as f_installation_id:
14-
installation_id = f_installation_id.read()
15-
client_secret = private_key
16-
auth = githubapp.Auth(app_id, installation_id, client_secret)
17-
access_token = auth.get_access_token()
18-
print(access_token)
19-
20-
g = Github(access_token)
21-
22-
repo = g.get_repo("RTa-scp/reserveiframe")
23-
repocontent=[]
24-
contents = repo.get_contents("src/reserve")
25-
while contents:
26-
file_content = contents.pop(0)
27-
if file_content.type == "dir":
28-
contents.extend(repo.get_contents(file_content.path))
10+
with open('env/private.key', 'rb') as f_private:
11+
private_key = f_private.read()
12+
with open('env/app_id.key', 'r') as f_app_id:
13+
app_id = f_app_id.read()
14+
with open('env/installation_id.key', 'r') as f_installation_id:
15+
installation_id = f_installation_id.read()
16+
client_secret = private_key
17+
auth = githubapps.Auth(app_id, installation_id, client_secret)
18+
access_token = auth.get_access_token()
19+
20+
g = Github(access_token)
21+
22+
repo = g.get_repo("RTa-scp/reserveiframe")
23+
repocontent = []
24+
contents = repo.get_contents("src/reserve", ref="reserve")
25+
while contents:
26+
file_content = contents.pop(0)
27+
if file_content.type == "dir":
28+
contents.extend(repo.get_contents(file_content.path))
29+
else:
30+
repocontent.append(file_content.path)
31+
file = "src/reserve/component/theme.md"
32+
if file in repocontent:
33+
contents = repo.get_contents(file, ref="reserve")
34+
repo.update_file(contents.path, "update: GithubApps",
35+
'---\nurl: content\nuser: user\nstarttime: "2022-04-10"\nendtime: "2022-07-10"\n---\n<reserve />', contents.sha, branch="reserve")
2936
else:
30-
repocontent.append(file_content.path)
31-
print(repocontent)
32-
file = "src/reserve/component/theme.md"
33-
if file in repocontent:
34-
contents = repo.get_contents(file, ref="main")
35-
repo.update_file(contents.path, "update: GithubApps", '---\nurl: content\nuser: user\nstarttime: "2022-04-10"\nendtime: "2022-07-10"\n---\n<reserve />', contents.sha, branch="main")
36-
else:
37-
repo.create_file(file, "create: GithubApps", '---\nurl: content\nuser: user\nstarttime: "2022-04-10"\nendtime: "2022-07-10"\n---\n<reserve />', branch="main")
38-
39-
# repo.create_file("src/reserve/test.md", "create: GithubApps", '---\nurl: content\nuser: user\nstarttime: "2022-03-10"\nendtime: "2022-06-10"\n---\n<reserve />', branch="main")
40-
# contents = repo.get_contents("src/reserve/test.md", ref="main")
41-
# repo.update_file(contents.path, "update: GithubApps", '---\nurl: content\nuser: user\nstarttime: "2022-04-10"\nendtime: "2022-07-10"\n---\n<reserve />', contents.sha, branch="main")
37+
repo.create_file(file, "create: GithubApps",
38+
'---\nurl: content\nuser: user\nstarttime: "2022-04-11"\nendtime: "2022-07-11"\n---\n<reserve />', branch="reserve")
39+
4240

4341
if __name__ == "__main__":
44-
main()
42+
main()

githubapp/__init__.py renamed to githubapps/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:copyright: (c) 2022 by the authors and contributors (see AUTHORS).
66
:license: MIT, see LICENSE for more details.
77
"""
8-
__title__ = 'githubapp'
8+
__title__ = 'githubapps'
99
__author__ = 'RTa-technology'
1010
__license__ = 'MIT'
1111
__copyright__ = 'Copyright 2022 by the authors and contributors (see AUTHORS)'
File renamed without changes.
File renamed without changes.

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
PyJWT
22
aiohttp
33
requests
4-
cryptography
5-
PyGithub
4+
cryptography

setup.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1-
from setuptools import setup, find_packages
2-
3-
setup(
4-
name='githubapp',
5-
version='0.1.0',
6-
license='MIT',
7-
description='This is a wrapper for the Github Apps API.',
8-
author='RTa-technology',
9-
packages=["githubapp"],
10-
)
1+
2+
import re
3+
4+
import setuptools
5+
6+
version = ''
7+
with open('githubapps/__init__.py') as f:
8+
version = re.search(
9+
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1)
10+
11+
requirements = []
12+
with open('requirements.txt', 'r') as f:
13+
requirements = f.read().splitlines()
14+
15+
16+
with open('README.md', 'r') as f:
17+
long_description = f.read()
18+
19+
setuptools.setup(
20+
name='githubapps',
21+
version=version,
22+
license='MIT',
23+
description='This is a wrapper for the Github Apps API.',
24+
long_description_content_type='text/markdown',
25+
url='https://github.com/RTa-technology/githubapps.py',
26+
author='RTa-technology',
27+
packages=setuptools.find_packages(),
28+
install_requires=requirements,
29+
classifiers=[
30+
'Programming Language :: Python :: 3.8',
31+
'Programming Language :: Python :: 3.9',
32+
'License :: OSI Approved :: MIT License',
33+
'Operating System :: OS Independent',
34+
],
35+
)

0 commit comments

Comments
 (0)