Skip to content

Commit d73c7e9

Browse files
committed
strict mode and docs
1 parent 4dea85e commit d73c7e9

File tree

9 files changed

+42
-54
lines changed

9 files changed

+42
-54
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [0.1.5] - 2017-10-21
8+
9+
### Added
10+
11+
- Added 'strict' parameter to constrictor.
712

813
## [0.1.4] - 2017-10-15
914

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ testall:
2323
.PHONY: docs
2424
docs:
2525
cd docs && make html
26-
python -c "import os, webbrowser; webbrowser.open('file://' + os.path.abspath('./docs/build/html/index.html'))"
26+
python -c "import os, webbrowser; webbrowser.open('file://' + os.path.abspath('./docs/_build/html/index.html'))"

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ same way as any other supported filesystem.
1111

1212
Open an S3FS by explicitly using the constructor:
1313

14-
```python
15-
from s3_s3fs import s3FS
16-
s3fs = S3FS('mybucket')
17-
# to use an s3-compatible service
18-
s3fs = S3FS('mybucket', endpoint_url='service.endpoint.url')
19-
```
20-
21-
Or with a FS URL:
22-
23-
```python
14+
```python
15+
from s3_s3fs import s3FS
16+
s3fs = S3FS('mybucket')
17+
```
18+
19+
Or with a FS URL:
20+
21+
```python
2422
from fs import open_fs
2523
s3fs = open_fs('s3://mybucket')
26-
# to use an s3-compatible service
27-
s3fs = open_fs('s3://mybucket?endpoint_url=service.endpoint.url')
28-
```
24+
```
2925

3026
## Downloading Files
3127

docs/conf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323

2424
import fs_s3fs
2525

26+
import sphinx_rtd_theme
27+
28+
html_theme = "sphinx_rtd_theme"
29+
30+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
31+
2632
# -- General configuration ------------------------------------------------
2733

2834
# If your documentation needs a minimal Sphinx version, state it here.
@@ -84,7 +90,7 @@
8490
# The theme to use for HTML and HTML Help pages. See the documentation for
8591
# a list of builtin themes.
8692
#
87-
html_theme = 'alabaster'
93+
#html_theme = 'alabaster'
8894

8995
# Theme options are theme-specific and customize the look and feel of a theme
9096
# further. For a list of options available for each theme, see the

docs/index.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ it explicitly::
4242
from fs_s3fs import S3FS
4343
s3fs = S3FS('mybucket')
4444

45-
See :class:`~fs_s3fs.S3FS` for other arguments you may pass to the
46-
constructor.
45+
S3FS Constructor
46+
----------------
47+
48+
.. autoclass:: fs_s3fs.S3FS
49+
:members:
4750

4851

4952
Authentication

docs/s3fs.rst

Lines changed: 0 additions & 21 deletions
This file was deleted.

fs_s3fs/_s3fs.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,22 @@ class S3FS(FS):
202202
`PyFilesystem <https://pyfilesystem.org>`_
203203
204204
:param str bucket_name: The S3 bucket name.
205-
:param str dir_path: The root directory within the S3 Bucker.
206-
Defaults to "/""
207-
:param str aws_access_key_id: The access key, or None to read the
208-
key from standard configuration files.
209-
:param str aws_secret_access_key: The secret key, or None to read
205+
:param str dir_path: The root directory within the S3 Bucket.
206+
Defaults to ``"/"``
207+
:param str aws_access_key_id: The access key, or ``None`` to read
210208
the key from standard configuration files.
209+
:param str aws_secret_access_key: The secret key, or ``None`` to
210+
read the key from standard configuration files.
211211
:param str endpoint_url: Alternative endpoint url (``None`` to use
212212
default).
213213
:param str aws_session_token:
214214
:param str region: Optional S3 region.
215215
:param str delimiter: The delimiter to separate folders, defaults to
216216
a forward slash.
217-
:param bool strict: Validate correctness of the destination path.
218-
For example, throw exception FileExpected() when a directory
219-
path is supplied to ``setbinfile()`` method.
220-
These validations are quite expensive and normally can be
221-
safely disabled, assuming the client application doesn't mess
222-
with file paths intentionally.
223-
Defaults to ``True``.
217+
:param bool strict: When ``True`` (default) S3FS will follow the
218+
PyFilesystem specification exactly. Set to ``False`` to disable
219+
validation of destination paths which may speed up uploads /
220+
downloads.
224221
225222
"""
226223

@@ -612,9 +609,10 @@ def setinfo(self, path, info):
612609

613610
def getbytes(self, path):
614611
self.check()
615-
info = self.getinfo(path)
616-
if not info.is_file:
617-
raise errors.FileExpected(path)
612+
if self.strict:
613+
info = self.getinfo(path)
614+
if not info.is_file:
615+
raise errors.FileExpected(path)
618616
_path = self.validatepath(path)
619617
_key = self._path_to_key(_path)
620618
bytes_file = io.BytesIO()

fs_s3fs/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.4"
1+
__version__ = "0.1.5a0"

fs_s3fs/opener.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def open_fs(self, fs_url, parse_result, writeable, create, cwd):
2222
raise OpenerError(
2323
"invalid bucket name in '{}'".format(fs_url)
2424
)
25+
strict = parse_result.params.get('strict', 'y') == 'y'
2526
s3fs = S3FS(
2627
bucket_name,
2728
dir_path=dir_path or '/',

0 commit comments

Comments
 (0)