Skip to content

Commit e5e85ad

Browse files
authored
typing, docs, formatting (#246)
* typing, docs, formatting * docs * readme revamp, and pull request template
1 parent 5c362e4 commit e5e85ad

File tree

9 files changed

+78
-50
lines changed

9 files changed

+78
-50
lines changed

CONTRIBUTORS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contributors (sorted alphabetically)
2+
3+
Many thanks to the following developers for contributing to this project:
4+
5+
- [Geoff Jukes](https://github.com/geoffjukes)
6+
- [Giampaolo](https://github.com/gpcimino)
7+
- [Martin Larralde](https://github.com/althonos)
8+
- [Will McGugan](https://github.com/willmcgugan)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 Will McGugan
3+
Copyright (c) 2016-2019 Will McGugan
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
PyFilesystem2
2-
=============
1+
# PyFilesystem2
32

43
Python's Filesystem abstraction layer.
54

65
[![PyPI version](https://badge.fury.io/py/fs.svg)](https://badge.fury.io/py/fs)
76
[![PyPI](https://img.shields.io/pypi/pyversions/fs.svg)](https://pypi.org/project/fs/)
87
[![Build Status](https://travis-ci.org/PyFilesystem/pyfilesystem2.svg?branch=master)](https://travis-ci.org/PyFilesystem/pyfilesystem2)
98
[![Coverage Status](https://coveralls.io/repos/github/PyFilesystem/pyfilesystem2/badge.svg)](https://coveralls.io/github/PyFilesystem/pyfilesystem2)
10-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/30ad6445427349218425d93886ade9ee)](https://www.codacy.com/app/will-mcgugan/pyfilesystem2?utm_source=github.com&utm_medium=referral&utm_content=PyFilesystem/pyfilesystem2&utm_campaign=Badge_Grade)
9+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/30ad6445427349218425d93886ade9ee)](https://www.codacy.com/app/will-mcgugan/pyfilesystem2?utm_source=github.com&utm_medium=referral&utm_content=PyFilesystem/pyfilesystem2&utm_campaign=Badge_Grade)
1110
[![Code Health](https://landscape.io/github/PyFilesystem/pyfilesystem2/master/landscape.svg?style=flat)](https://landscape.io/github/PyFilesystem/pyfilesystem2/master)
1211

13-
Documentation
14-
-------------
12+
## Documentation
1513

16-
* [Wiki](https://www.pyfilesystem.org)
17-
* [API Documentation](https://pyfilesystem2.readthedocs.io/en/latest/)
18-
* [GitHub Repository](https://github.com/PyFilesystem/pyfilesystem2)
19-
* [Blog](https://www.willmcgugan.com/tag/fs/)
14+
- [Wiki](https://www.pyfilesystem.org)
15+
- [API Documentation](https://pyfilesystem2.readthedocs.io/en/latest/)
16+
- [GitHub Repository](https://github.com/PyFilesystem/pyfilesystem2)
17+
- [Blog](https://www.willmcgugan.com/tag/fs/)
2018

19+
## Introduction
2120

22-
Introduction
23-
------------
24-
25-
Think of PyFilesystem's ``FS`` objects as the next logical step to
26-
Python's ``file`` objects. In the same way that file objects abstract a
21+
Think of PyFilesystem's `FS` objects as the next logical step to
22+
Python's `file` objects. In the same way that file objects abstract a
2723
single file, FS objects abstract an entire filesystem.
2824

2925
Let's look at a simple piece of code as an example. The following
3026
function uses the PyFilesystem API to count the number of non-blank
31-
lines of Python code in a directory. It works *recursively*, so it will
32-
find ``.py`` files in all sub-directories.
27+
lines of Python code in a directory. It works _recursively_, so it will
28+
find `.py` files in all sub-directories.
3329

3430
```python
3531
def count_python_loc(fs):
@@ -50,10 +46,10 @@ print(count_python_loc(projects_fs))
5046
```
5147

5248
The line `project_fs = open_fs('~/projects')` opens an FS object that
53-
maps to the ``projects`` directory in your home folder. That object is
49+
maps to the `projects` directory in your home folder. That object is
5450
used by `count_python_loc` when counting lines of code.
5551

56-
To count the lines of Python code in a *zip file*, we can make the
52+
To count the lines of Python code in a _zip file_, we can make the
5753
following change:
5854

5955
```python
@@ -90,20 +86,27 @@ work with the OS filesystem. Any other filesystem would require an
9086
entirely different API, and you would likely have to re-implement the
9187
directory walking functionality of `os.walk`.
9288

93-
Credits
94-
-------
89+
## Credits
90+
91+
The following developers have contributed code and their time to this projects:
92+
93+
- [Will McGugan](https://github.com/willmcgugan)
94+
- [Martin Larralde](https://github.com/althonos)
95+
- [Giampaolo](https://github.com/gpcimino)
96+
- [Geoff Jukes](https://github.com/geoffjukes)
9597

96-
* [Will McGugan](https://github.com/willmcgugan)
97-
* [Martin Larralde](https://github.com/althonos)
98-
* [Giampaolo](https://github.com/gpcimino) for `copy_if_newer` and ftp fixes.
99-
* [Geoff Jukes](https://github.com/geoffjukes) for ftp fixes.
98+
See CONTRIBUTORS.md for a full list of contributors.
10099

101100
PyFilesystem2 owes a massive debt of gratitude to the following
102101
developers who contributed code and ideas to the original version.
103102

104-
* Ryan Kelly
105-
* Andrew Scheller
106-
* Ben Timby
103+
- Ryan Kelly
104+
- Andrew Scheller
105+
- Ben Timby
107106

108107
Apologies if I missed anyone, feel free to prompt me if your name is
109108
missing here.
109+
110+
## Support
111+
112+
If commercial support is required, please contact [Will McGugan](mailto:[email protected]).

fs/_bulk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def stop(self):
100100
self.queue.put(None)
101101
for worker in self.workers:
102102
worker.join()
103-
# Free up references help by workers
103+
# Free up references held by workers
104104
del self.workers[:]
105105
self.queue.join()
106106
self.running = False

fs/base.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,8 @@ def walk(self):
116116
# ---------------------------------------------------------------- #
117117

118118
@abc.abstractmethod
119-
def getinfo(
120-
self,
121-
path, # type: Text
122-
namespaces=None, # type: Optional[Collection[Text]]
123-
):
124-
# type: (...) -> Info
119+
def getinfo(self, path, namespaces=None):
120+
# type: (Text, Optional[Collection[Text]]) -> Info
125121
"""Get information about a resource on a filesystem.
126122
127123
Arguments:
@@ -393,7 +389,7 @@ def copydir(self, src_path, dst_path, create=False):
393389
src_path (str): Path of source directory.
394390
dst_path (str): Path to destination directory.
395391
create (bool): If `True`, then ``dst_path`` will be created
396-
if it doesn't exist alreadys (defaults to `False`).
392+
if it doesn't exist already (defaults to `False`).
397393
398394
Raises:
399395
fs.errors.ResourceNotFound: If the ``dst_path``
@@ -980,7 +976,7 @@ def lock(self):
980976

981977
def movedir(self, src_path, dst_path, create=False):
982978
# type: (Text, Text, bool) -> None
983-
"""Move contents of directory ``src_path`` to ``dst_path``.
979+
"""Move directory ``src_path`` to ``dst_path``.
984980
985981
Parameters:
986982
src_path (str): Path of source directory on the filesystem.

fs/osfs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
try:
2828
from scandir import scandir # type: ignore
2929
except ImportError: # pragma: no cover
30-
scandir = None
30+
scandir = None # pragma: no cover
3131

3232
try:
3333
from os import sendfile
3434
except ImportError:
3535
try:
3636
from sendfile import sendfile # type: ignore
3737
except ImportError:
38-
sendfile = None
38+
sendfile = None # pragma: no cover
3939

4040
from . import errors
4141
from .errors import FileExists

fs/test.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,14 @@ def test_getinfo(self):
494494

495495
# Check that if the details namespace is present, times are
496496
# of valid types.
497-
if 'details' in info.namespaces:
498-
details = info.raw['details']
499-
self.assertIsInstance(details.get('accessed'), (type(None), int, float))
500-
self.assertIsInstance(details.get('modified'), (type(None), int, float))
501-
self.assertIsInstance(details.get('created'), (type(None), int, float))
502-
self.assertIsInstance(details.get('metadata_changed'), (type(None), int, float))
497+
if "details" in info.namespaces:
498+
details = info.raw["details"]
499+
self.assertIsInstance(details.get("accessed"), (type(None), int, float))
500+
self.assertIsInstance(details.get("modified"), (type(None), int, float))
501+
self.assertIsInstance(details.get("created"), (type(None), int, float))
502+
self.assertIsInstance(
503+
details.get("metadata_changed"), (type(None), int, float)
504+
)
503505

504506
def test_exists(self):
505507
# Test exists method.
@@ -1739,6 +1741,7 @@ def test_movedir(self):
17391741
self.fs.movedir("foo/bar", "foo2")
17401742
self.assert_text("foo2/foofoo.txt", "Hello")
17411743
self.assert_isdir("foo2/baz/egg")
1744+
self.assert_not_exists("foo/bar")
17421745
self.assert_not_exists("foo/bar/foofoo.txt")
17431746
self.assert_not_exists("foo/bar/baz/egg")
17441747

@@ -1814,7 +1817,5 @@ def test_case_sensitive(self):
18141817
self.assert_isfile("fOO")
18151818

18161819
def test_glob(self):
1817-
self.assertIsInstance(
1818-
self.fs.glob,
1819-
glob.BoundGlobber
1820-
)
1820+
self.assertIsInstance(self.fs.glob, glob.BoundGlobber)
1821+

fs/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_intermediate_dirs(fs, dir_path):
6969
list: A list of non-existing paths.
7070
7171
Raises:
72-
`fs.errors.DirectoryExpected`: If a path component
72+
~fs.errors.DirectoryExpected: If a path component
7373
references a file and not a directory.
7474
7575
"""

pull_request_template.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# PyFilesystem Pull Request
2+
3+
Thank you for your pull request!
4+
5+
## Type of changes
6+
7+
- [ ] Bug fix
8+
- [ ] New Feature
9+
- [ ] Documentation / docstrings
10+
- [ ] Other
11+
12+
## Checklist
13+
14+
- [ ] I've run the latest [black](https://github.com/ambv/black) with default args on new code
15+
- [ ] I've updated CHANGELOG.md
16+
- [ ] I accept that @willmcgugan may be pedantic in the code review
17+
18+
## Description
19+
20+
Please describe your changes here. If this fixes a bug, please link to the issue, if possible.

0 commit comments

Comments
 (0)