开源项目教程:Qiniu Python SDK
pyGolang bindings to the CPython C-API项目地址:https://gitcode.com/gh_mirrors/py2/py
1. 项目的目录结构及介绍
qiniu-py/
├── docs/
│ ├── index.md
│ └── ...
├── qiniu/
│ ├── __init__.py
│ ├── auth.py
│ ├── bucket.py
│ ├── config.py
│ └── ...
├── tests/
│ ├── __init__.py
│ ├── test_auth.py
│ ├── test_bucket.py
│ └── ...
├── .gitignore
├── LICENSE
├── README.md
├── setup.py
└── requirements.txt
- docs/: 项目文档目录,包含使用说明和API文档。
- qiniu/: 核心代码目录,包含SDK的主要功能模块。
- init.py: 初始化文件,定义包的入口。
- auth.py: 认证模块,处理API请求的认证。
- bucket.py: 存储空间管理模块。
- config.py: 配置模块,包含全局配置项。
- tests/: 测试代码目录,包含单元测试和集成测试。
- .gitignore: Git忽略文件配置。
- LICENSE: 项目许可证。
- README.md: 项目说明文档。
- setup.py: 安装脚本,用于安装项目依赖和打包。
- requirements.txt: 项目依赖列表。
2. 项目的启动文件介绍
项目的启动文件通常是setup.py
,它负责安装项目依赖和打包项目。以下是setup.py
的基本内容:
from setuptools import setup, find_packages
setup(
name='qiniu-py',
version='1.11.0',
description='Qiniu Resource Storage SDK for Python',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Qiniu',
author_email='sdk@qiniu.com',
url='https://github.com/qiniu/py',
packages=find_packages(),
install_requires=open('requirements.txt').read().splitlines(),
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
)
3. 项目的配置文件介绍
项目的配置文件通常是qiniu/config.py
,它包含全局配置项,如API域名、超时时间等。以下是config.py
的基本内容:
class Config:
ACCESS_KEY = 'your_access_key'
SECRET_KEY = 'your_secret_key'
API_HOST = 'https://api.qiniu.com'
UPLOAD_HOST = 'https://up.qiniu.com'
DOWNLOAD_HOST = 'https://dn.qiniu.com'
TIMEOUT = 30 # 请求超时时间,单位秒
config = Config()
- ACCESS_KEY: 七牛云存储的访问密钥。
- SECRET_KEY: 七牛云存储的密钥。
- API_HOST: API请求的域名。
- UPLOAD_HOST: 文件上传的域名。
- DOWNLOAD_HOST: 文件下载的域名。
- TIMEOUT: 请求超时时间,单位秒。
通过这些配置项,可以灵活地调整SDK的行为,以适应不同的使用场景。
pyGolang bindings to the CPython C-API项目地址:https://gitcode.com/gh_mirrors/py2/py