Skip to content
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6275306
Update README.md
ZhaoQi99 Feb 28, 2019
f16c571
Update README.md
xiekeyi98 Mar 22, 2019
41bb7a0
Add Codacy badge
codacy-badger Mar 26, 2019
0db9e11
docs(README.md): fix travis badge
ZhaoQi99 Mar 28, 2019
e5287b0
style(snnusdk): format code using pep8 and isort
ZhaoQi99 Apr 1, 2019
cb50586
chore: add dev-requirements.txt
ZhaoQi99 Apr 1, 2019
0981b70
test(get_courses.html): fix get_course.html file coding
ZhaoQi99 Apr 12, 2019
06671f5
test(test_campus): add test_get_list method
ZhaoQi99 Apr 12, 2019
80ffe05
ci: add Makefile and modify travis config
ZhaoQi99 Apr 12, 2019
2d685ed
test: add code quality check
ZhaoQi99 Apr 12, 2019
48385fc
fix(test): fix pep8 check
ZhaoQi99 Apr 12, 2019
bea3380
docs(README): add installation about Tesseract-OCR
ZhaoQi99 Apr 12, 2019
bea4501
docs(README): add contributor
ZhaoQi99 Apr 12, 2019
11d1721
chore(dev-requirements.txt): add sphinx
ZhaoQi99 Apr 13, 2019
0a21402
ci(docs): auto build docs
ZhaoQi99 Apr 13, 2019
4db8d56
ci: add jobs
ZhaoQi99 Apr 14, 2019
8283d8c
ci: fix typos
ZhaoQi99 Apr 14, 2019
9f658b7
ci(docs): add branches limit
ZhaoQi99 Apr 14, 2019
a5dadb2
Add Codacy badge
codacy-badger Apr 13, 2019
aa49d7d
docs(README): quick fix README
ZhaoQi99 Apr 14, 2019
6ecba93
test(test_library): add test_borrow_info method
ZhaoQi99 Apr 13, 2019
f64df47
test(test_campus): fix assertIsInstance
ZhaoQi99 Apr 13, 2019
9b5b6a4
perf(library): improve library login method peroformance
ZhaoQi99 Apr 13, 2019
3dd673c
test(test_library): add test library methods
ZhaoQi99 Apr 13, 2019
7ce779c
fix(library): fix library UnauthorizedError
ZhaoQi99 Apr 13, 2019
a6f80aa
test: change setUp to setUpClass
ZhaoQi99 Apr 13, 2019
db9ff24
refactor(Notice/News): extraction base class from New and Notice
ZhaoQi99 Apr 1, 2019
fc3c404
perf(message): improve get Notice/News performance
ZhaoQi99 Apr 13, 2019
69fc378
feat: 增加部分功能测试
Small-funny Apr 14, 2019
b470497
fix(message): quick-fix News
ZhaoQi99 Apr 14, 2019
80827d2
ci: install tesseract-ocr
ZhaoQi99 Apr 14, 2019
e380977
test: fix and modify some tests
ZhaoQi99 Apr 14, 2019
ea8e468
test: change setUp to setUpClass
ZhaoQi99 Apr 14, 2019
652d423
test(test_campus): quick fix test_get_photo method
ZhaoQi99 Apr 14, 2019
6cdc52e
test(test_room): add expectfailure
ZhaoQi99 Apr 14, 2019
c31ff50
docs(library): quick-fix library.rst
ZhaoQi99 Apr 14, 2019
15fb5a4
docs(README): Update README.md
ZhaoQi99 Apr 15, 2019
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
31 changes: 25 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
language: python
sudo: true
python:
- "3.5"
- "3.6"
install:
- pip install -r requirements.txt
script: True
- pip install -r dev-requirements.txt
- pip install pytest-pep8
- yes| sudo add-apt-repository ppa:alex-p/tesseract-ocr
- yes| sudo apt-get update
- yes | sudo apt install tesseract-ocr
- yes | sudo apt install libtesseract-dev
jobs:
include:
- stage: test
script:
- make ci
- make build-docs
python: '3.5'
- stage: test
script:
- make ci
- make build-docs
python: '3.6'
- stage: docs
script:
- make build-docs && bash publish-docs.sh
python: '3.6'
branches:
only:
- master
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ci:
python -m unittest
pytest --pep snnusdk
pytest test
build-docs:
cd docs && make html
@echo "Build successful!"

19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[![Build Status](https://travis-ci.com/ZhaoQi99/SNNU-SDK.svg?branch=dev)](https://travis-ci.com/ZhaoQi99/SNNU-SDK)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a631e0b7b3484ecf8cf3226b8f0d90b9)](https://app.codacy.com/app/ZhaoQi99/SNNU-SDK?utm_source=github.com&utm_medium=referral&utm_content=snnucs/SNNU-SDK&utm_campaign=Badge_Grade_Settings)
[![Build Status](https://travis-ci.com/snnucs/SNNU-SDK.svg?branch=dev)](https://travis-ci.com/snnucs/SNNU-SDK)
[![image](https://img.shields.io/pypi/v/snnusdk.svg)](https://pypi.org/project/snnusdk/)
[![Release](https://img.shields.io/github/release/ZhaoQi99/SNNU-SDK.svg)](https://github.com/ZhaoQi99/SNNU-SDK/releases)
[![image](https://img.shields.io/pypi/pyversions/snnusdk.svg)](https://pypi.org/project/snnusdk/)
[![Documentation Status](https://readthedocs.org/projects/snnu-sdk/badge/?version=dev)](https://snnu-sdk.readthedocs.io/zh_CN/dev/?badge=dev)
[![GitHub license](https://img.shields.io/github/license/ZhaoQi99/SNNU-SDK.svg)](https://github.com/ZhaoQi99/SNNU-SDK/blob/dev/LICENSE)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/snnucs/SNNU-SDK.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/snnucs/SNNU-SDK/context:python)


# 陕西师范大学(SNNU) 第三方Python SDK
Expand Down Expand Up @@ -42,12 +44,17 @@ SNNU-SDK 是陕西师范大学(SNNU)的一个第三方Python-SDK,实现了校
- 所支持的部门

## 安装

### 安装snnusdk
```bash
pip install snnusdk
✨🍰✨

```
### (可选)安装Tesseract-OCR
如需正常使用Urp教务系统相关功能,需安装OCR识别引擎
- [Windows](https://github.com/tesseract-ocr/tesseract/wiki#windows)
- [Linux](https://github.com/tesseract-ocr/tesseract/wiki#linux)
- [Mac OS](https://github.com/tesseract-ocr/tesseract/wiki#macos)
## 使用示例
这里是一些简单的使用案例
```Python
Expand Down Expand Up @@ -92,7 +99,7 @@ libiary = Library(username='B11111111', password='xxx')
```

## 文档
你可以在[https://ZhaoQi99.github.io/SNNU-SDK](https://ZhaoQi99.github.io/SNNU-SDK)看到本项目的完整使用文档。
你可以在[https://snnucs.github.io/SNNU-SDK](https://snnucs.github.io/SNNU-SDK)看到本项目的完整使用文档。

## 贡献你的代码
欢迎您贡献出自己的一份力量,你可以随时提交`issue`或`fork`本仓库,静候你的`pull request`。
Expand All @@ -101,11 +108,11 @@ libiary = Library(username='B11111111', password='xxx')
感谢所有对本项目做出过贡献的开发者([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):


| [<img src="https://avatars3.githubusercontent.com/u/40024866?v=4" width="100px;"/><br /><sub><b>jhy</b></sub>](https://Small-funny.github.io/)<br />[💻](https://github.com/ZhaoQi99/SNNU-SDK/commits?author=Small-funny "Code") [📖](https://github.com/ZhaoQi99/SNNU-SDK/commits?author=Small-funny "Documentation")|
| :---: |
| [<img src="https://avatars3.githubusercontent.com/u/40024866?v=4" width="100px;"/><br /><sub><b>jhy</b></sub>](https://Small-funny.github.io/)<br />[💻](https://github.com/ZhaoQi99/SNNU-SDK/commits?author=Small-funny "Code") [📖](https://github.com/ZhaoQi99/SNNU-SDK/commits?author=Small-funny "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/7782671?v=4" width="100px;"/><br /><sub><b>Keyi Xie</b></sub>](https://xiekeyi98.github.io/)<br /> [📖](https://github.com/ZhaoQi99/SNNU-SDK/commits?author=xiekeyi98 "Documentation") |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

## 谁在使用

## 开源协议 & 作者
* 作者:Qi Zhao([[email protected]](mailto:[email protected]))
* 开源协议:[GNU General Public License v3.0](https://github.com/ZhaoQi99/SNNU-SDK/blob/dev/LICENSE)
* 开源协议:[GNU General Public License v3.0](https://github.com/ZhaoQi99/SNNU-SDK/blob/dev/LICENSE)
58 changes: 58 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
alabaster==0.7.12
apipkg==1.5
astroid==2.2.5
atomicwrites==1.3.0
attrs==19.1.0
autopep8==1.4.3
Babel==2.6.0
beautifulsoup4==4.6.3
bleach==3.0.2
bs4==0.0.1
certifi==2018.11.29
chardet==3.0.4
colorama==0.4.1
docutils==0.14
execnet==1.6.0
idna==2.7
imagesize==1.1.0
isort==4.3.16
Jinja2==2.10.1
lazy-object-proxy==1.3.1
lxml==4.2.5
MarkupSafe==1.1.1
mccabe==0.6.1
more-itertools==7.0.0
packaging==19.0
pep8==1.7.1
Pillow==5.3.0
pkginfo==1.4.2
pluggy==0.9.0
py==1.8.0
pycodestyle==2.5.0
Pygments==2.3.0
pylint==2.3.1
pyparsing==2.4.0
pytesseract==0.2.5
pytest==4.4.0
pytest-cache==1.0
pytest-pep8==1.0.6
pytz==2019.1
readme-renderer==24.0
requests==2.20.1
requests-toolbelt==0.8.0
six==1.12.0
snowballstemmer==1.2.1
Sphinx==2.0.1
sphinx-rtd-theme==0.4.3
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
tqdm==4.28.1
twine==1.12.1
typed-ast==1.3.1
urllib3==1.24.1
webencodings==0.5.1
wrapt==1.11.1
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = ../../SNNU-SDk-docs
BUILDDIR = SNNU-SDK-docs

# Put it first so that "make" without argument is like "make help".
help:
Expand Down
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=../../SNNU-SDk-docs
set BUILDDIR=SNNU-SDK-docs

if "%1" == "" goto help

Expand Down
3 changes: 0 additions & 3 deletions docs/source/libiary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@

.. autoclass:: snnusdk.Library
:members:


.. automethod:: snnusdk.libiary.get_borrow_info
15 changes: 15 additions & 0 deletions publish-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
export GH_REF="github.com/snnucs/SNNU-SDK.git"
cd docs && make html
git clone https://${GH_REF} html
cd html
git checkout gh-pages
git pull origin
rm -rf *
sudo mv ./../SNNU-SDK-docs/html/* ./
git status
git config --global user.name "Qi Zhao"
git config --global user.email "[email protected]"
git add .
git commit -m "Travis CI Auto Builder at `date +"%Y-%m-%d %H:%M"`"
git push --quiet "https://${GH_TOKEN}@${GH_REF}" gh-pages:gh-pages
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
pep8ignore =
configs.py ALL
pep8maxlinelength = 128
8 changes: 3 additions & 5 deletions snnusdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from snnusdk.campus import Campus
from snnusdk.libiary import Library
from snnusdk.libiary import get_borrow_info
from snnusdk.urp import Urp
from snnusdk.message import News, Notice, get_support_dep
from snnusdk.room import Room
from snnusdk.campus import Campus
from snnusdk.message import Notice,News
from snnusdk.message import get_support_dep
from snnusdk.urp import Urp
39 changes: 28 additions & 11 deletions snnusdk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

import requests
import urllib3
from PIL import Image
from bs4 import BeautifulSoup
from PIL import Image

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


class API(requests.Session):

def __init__(self):
super(API, self).__init__()
self.verify = False

def get_image(self, url=None, method="get", params=None, json=None, data=None, **kwargs):
def get_image(self,
url=None,
method="get",
params=None,
json=None,
data=None,
**kwargs):
"""
图片接口通用请求方法
:param method: 请求方法,默认为get
Expand All @@ -25,13 +30,19 @@ def get_image(self, url=None, method="get", params=None, json=None, data=None, *
:return: pillow的Image对象
"""
try: # 出现网络连接问题,直接在该处抛出错误
r = getattr(self, method)(url, json=json,
data=data, params=params, **kwargs)
r = getattr(self, method)(
url, json=json, data=data, params=params, **kwargs)
return Image.open(BytesIO(r.content))
except ConnectionError:
raise ConnectionError("请检查网络连接")

def get_soup(self, url=None, method="get", params=None, json=None, data=None, **kwargs):
def get_soup(self,
url=None,
method="get",
params=None,
json=None,
data=None,
**kwargs):
"""
html页面通用请求方法
:param method: 请求方法,默认为get
Expand All @@ -42,8 +53,8 @@ def get_soup(self, url=None, method="get", params=None, json=None, data=None, **
:return: BeautifulSoup对象
"""
try: # 出现网络连接问题,直接在该处抛出错误
r = getattr(self, method)(url, json=json,
data=data, params=params, **kwargs)
r = getattr(self, method)(
url, json=json, data=data, params=params, **kwargs)
except ConnectionError:
raise ConnectionError("请检查网络连接")
else:
Expand All @@ -53,7 +64,13 @@ def get_soup(self, url=None, method="get", params=None, json=None, data=None, **
else: # 处理其他状态码
raise Exception('请确保能够正常访问当前页面: {}'.format(url))

def get_json(self, url=None, method="get", params=None, json=None, data=None, **kwargs):
def get_json(self,
url=None,
method="get",
params=None,
json=None,
data=None,
**kwargs):
"""
json接口通用请求方法
:param method: 请求方法, 默认为get
Expand All @@ -64,8 +81,8 @@ def get_json(self, url=None, method="get", params=None, json=None, data=None, **
:return: json转换出的字典
"""
try: # 出现网络连接问题,直接在该处抛出错误
r = getattr(self, method)(url, json=json,
data=data, params=params, **kwargs)
r = getattr(self, method)(
url, json=json, data=data, params=params, **kwargs)
return r.json()
except ConnectionError:
raise ConnectionError("请检查网络连接")
Loading