From 6204b6c2f505a4c1e5206185e7dee51487b5d23f Mon Sep 17 00:00:00 2001 From: peze <954152927@qq.com> Date: Wed, 19 Jun 2019 13:26:10 +0800 Subject: [PATCH] fix doc style --- README-CN.rst | 2 +- README.rst | 302 +++++++++++++++++++++++++------------------------- 2 files changed, 152 insertions(+), 152 deletions(-) diff --git a/README-CN.rst b/README-CN.rst index bdc47138..ed7e73d8 100644 --- a/README-CN.rst +++ b/README-CN.rst @@ -9,7 +9,7 @@ Aliyun OSS SDK for Python :target: https://coveralls.io/github/aliyun/aliyun-oss-python-sdk?branch=master `README of English `_ ------------------- +--------------------------------------------------------------------------------------------- 概述 ---- diff --git a/README.rst b/README.rst index 5b5ddb22..c468b58e 100644 --- a/README.rst +++ b/README.rst @@ -1,151 +1,151 @@ -Alibaba Cloud OSS SDK for Python -================================ - -.. image:: https://badge.fury.io/py/oss2.svg - :target: https://badge.fury.io/py/oss2 -.. image:: https://travis-ci.org/aliyun/aliyun-oss-python-sdk.svg?branch=master - :target: https://travis-ci.org/aliyun/aliyun-oss-python-sdk -.. image:: https://coveralls.io/repos/github/aliyun/aliyun-oss-python-sdk/badge.svg?branch=master - :target: https://coveralls.io/github/aliyun/aliyun-oss-python-sdk?branch=master - -`README of Chinese `_ ------------------- - -Overview --------- - -Alibaba Cloud Object Storage Python SDK 2.x. This version is not compatible with the previous version (Version 0.x). The package name is `oss2` to avoid conflict with previous versions. - - -The SDK of this version is dependent on the third-party HTTP library `requests `_ and `crcmod`. Install the SDK following the methods below. - -Note: - - This version does not contain the `osscmd` command line tool. - -Running environment -------------------- - -Python 2.6,2.7,3.3,3.4,3.5 - -Note: - - Do not use Python 3.3.0 or 3.3.1. Refer to `Python Issue 16658 `_. - -Installing ----------- - -Install the official release version through PIP (taking Linux as an example): - -.. code-block:: bash - - $ pip install oss2 - -You can also install the unzipped installer package directly: - -.. code-block:: bash - - $ sudo python setup.py install - - -Getting started ---------------- - -.. code-block:: python - - # -*- coding: utf-8 -*- - - import oss2 - - endpoint = 'http://oss-cn-hangzhou.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region. - - auth = oss2.Auth('', '') - bucket = oss2.Bucket(auth, endpoint, '') - - # The object key in the bucket is story.txt - key = 'story.txt' - - # Upload - bucket.put_object(key, 'Ali Baba is a happy youth.') - - # Download - bucket.get_object(key).read() - - # Delete - bucket.delete_object(key) - - # Traverse all objects in the bucket - for object_info in oss2.ObjectIterator(bucket): - print(object_info.key) - -For more examples, refer to the code under the "examples" directory. - -Handling errors ---------------- - -The Python SDK interface will throw an exception in case of an error (see oss2.exceptions sub-module) unless otherwise specified. An example is provided below: - -.. code-block:: python - - try: - result = bucket.get_object(key) - print(result.read()) - except oss2.exceptions.NoSuchKey as e: - print('{0} not found: http_status={1}, request_id={2}'.format(key, e.status, e.request_id)) - -Setup Logging ---------------- - -The following code can set the logging level of 'oss2'. - .. code-block:: python - - import logging - logging.getLogger('oss2').setLevel(logging.WARNING) - -Testing -------- - -First set the required AccessKeyId, AccessKeySecret, endpoint and bucket information for the test through environment variables (**Do not use the bucket for the production environment**). -Take the Linux system for example: - -.. code-block:: bash - - $ export OSS_TEST_ACCESS_KEY_ID= - $ export OSS_TEST_ACCESS_KEY_SECRET= - $ export OSS_TEST_ENDPOINT= - $ export OSS_TEST_BUCKET= - - $ export OSS_TEST_STS_ID= - $ export OSS_TEST_STS_KEY= - $ export OSS_TEST_STS_ARN= - - -Run the test in the following method: - -.. code-block:: bash - - $ nosetests # First install nose - - -You can set environment variable to test auth v2: - -.. code-block:: bash - - $ export OSS_TEST_AUTH_VERSION=v2 - -More resources --------------- -- `More examples `_. -- `Python SDK API documentation `_. -- `Official Python SDK documentation `_. - -Contacting us -------------- -- `Alibaba Cloud OSS official website `_. -- `Alibaba Cloud OSS official forum `_. -- `Alibaba Cloud OSS official documentation center `_. -- Alibaba Cloud official technical support: `Submit a ticket `_. - -License -------- -- `MIT `_. +Alibaba Cloud OSS SDK for Python +================================ + +.. image:: https://badge.fury.io/py/oss2.svg + :target: https://badge.fury.io/py/oss2 +.. image:: https://travis-ci.org/aliyun/aliyun-oss-python-sdk.svg?branch=master + :target: https://travis-ci.org/aliyun/aliyun-oss-python-sdk +.. image:: https://coveralls.io/repos/github/aliyun/aliyun-oss-python-sdk/badge.svg?branch=master + :target: https://coveralls.io/github/aliyun/aliyun-oss-python-sdk?branch=master + +`README of Chinese `_ +------------------------------------------------------------------------------------------------ + +Overview +-------- + +Alibaba Cloud Object Storage Python SDK 2.x. This version is not compatible with the previous version (Version 0.x). The package name is `oss2` to avoid conflict with previous versions. + + +The SDK of this version is dependent on the third-party HTTP library `requests `_ and `crcmod`. Install the SDK following the methods below. + +Note: + + This version does not contain the `osscmd` command line tool. + +Running environment +------------------- + +Python 2.6,2.7,3.3,3.4,3.5 + +Note: + + Do not use Python 3.3.0 or 3.3.1. Refer to `Python Issue 16658 `_. + +Installing +---------- + +Install the official release version through PIP (taking Linux as an example): + +.. code-block:: bash + + $ pip install oss2 + +You can also install the unzipped installer package directly: + +.. code-block:: bash + + $ sudo python setup.py install + + +Getting started +--------------- + +.. code-block:: python + + # -*- coding: utf-8 -*- + + import oss2 + + endpoint = 'http://oss-cn-hangzhou.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region. + + auth = oss2.Auth('', '') + bucket = oss2.Bucket(auth, endpoint, '') + + # The object key in the bucket is story.txt + key = 'story.txt' + + # Upload + bucket.put_object(key, 'Ali Baba is a happy youth.') + + # Download + bucket.get_object(key).read() + + # Delete + bucket.delete_object(key) + + # Traverse all objects in the bucket + for object_info in oss2.ObjectIterator(bucket): + print(object_info.key) + +For more examples, refer to the code under the "examples" directory. + +Handling errors +--------------- + +The Python SDK interface will throw an exception in case of an error (see oss2.exceptions sub-module) unless otherwise specified. An example is provided below: + +.. code-block:: python + + try: + result = bucket.get_object(key) + print(result.read()) + except oss2.exceptions.NoSuchKey as e: + print('{0} not found: http_status={1}, request_id={2}'.format(key, e.status, e.request_id)) + +Setup Logging +--------------- + +The following code can set the logging level of 'oss2'. + .. code-block:: python + + import logging + logging.getLogger('oss2').setLevel(logging.WARNING) + +Testing +------- + +First set the required AccessKeyId, AccessKeySecret, endpoint and bucket information for the test through environment variables (**Do not use the bucket for the production environment**). +Take the Linux system for example: + +.. code-block:: bash + + $ export OSS_TEST_ACCESS_KEY_ID= + $ export OSS_TEST_ACCESS_KEY_SECRET= + $ export OSS_TEST_ENDPOINT= + $ export OSS_TEST_BUCKET= + + $ export OSS_TEST_STS_ID= + $ export OSS_TEST_STS_KEY= + $ export OSS_TEST_STS_ARN= + + +Run the test in the following method: + +.. code-block:: bash + + $ nosetests # First install nose + + +You can set environment variable to test auth v2: + +.. code-block:: bash + + $ export OSS_TEST_AUTH_VERSION=v2 + +More resources +-------------- +- `More examples `_. +- `Python SDK API documentation `_. +- `Official Python SDK documentation `_. + +Contacting us +------------- +- `Alibaba Cloud OSS official website `_. +- `Alibaba Cloud OSS official forum `_. +- `Alibaba Cloud OSS official documentation center `_. +- Alibaba Cloud official technical support: `Submit a ticket `_. + +License +------- +- `MIT `_.