1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[v11]= Python's filesystem abstraction layer (3.11)
8 SDESC[v12]= Python's filesystem abstraction layer (3.12)
9 HOMEPAGE= https://github.com/PyFilesystem/pyfilesystem2
10 CONTACT= Python_Automaton[python@ironwolf.systems]
13 SITES[main]= PYPIWHL/b9/5c/a3d95dc1ec6cdeb032d789b552ecc76effa3557ea9186e1566df6aac18df
14 DISTFILE[1]= fs-2.4.16-py2.py3-none-any.whl:main
19 OPTIONS_AVAILABLE= PY311 PY312
20 OPTIONS_STANDARD= none
21 VOPTS[v11]= PY311=ON PY312=OFF
22 VOPTS[v12]= PY311=OFF PY312=ON
24 DISTNAME= fs-2.4.16.dist-info
28 [PY311].RUN_DEPENDS_ON= python-appdirs:single:v11
29 python-setuptools:single:v11
31 [PY311].USES_ON= python:v11,wheel
33 [PY312].RUN_DEPENDS_ON= python-appdirs:single:v12
34 python-setuptools:single:v12
36 [PY312].USES_ON= python:v12,wheel
38 [FILE:2706:descriptions/desc.single]
41 Python's Filesystem abstraction layer.
47 [Windows Build Status]
61 Think of PyFilesystem's `FS` objects as the next logical step to
62 Python's `file` objects. In the same way that file objects abstract a
63 single file, FS objects abstract an entire filesystem.
65 Let's look at a simple piece of code as an example. The following
66 function uses the PyFilesystem API to count the number of non-blank
67 lines of Python code in a directory. It works _recursively_, so it will
68 find `.py` files in all sub-directories.
71 def count_python_loc(fs):
72 """Count non-blank lines of Python code."""
74 for path in fs.walk.files(filter=['*.py']):
75 with fs.open(path) as python_file:
76 count += sum(1 for line in python_file if line.strip())
80 We can call `count_python_loc` as follows:
83 from fs import open_fs
84 projects_fs = open_fs('~/projects')
85 print(count_python_loc(projects_fs))
88 The line `project_fs = open_fs('~/projects')` opens an FS object that
89 maps to the `projects` directory in your home folder. That object is
90 used by `count_python_loc` when counting lines of code.
92 To count the lines of Python code in a _zip file_, we can make the
96 projects_fs = open_fs('zip://projects.zip')
99 Or to count the Python lines on an FTP server:
102 projects_fs = open_fs('ftp://ftp.example.org/projects')
105 No changes to `count_python_loc` are necessary, because PyFileystem
106 provides a simple consistent interface to anything that resembles a
107 collection of files and directories. Essentially, it allows you to write
108 code that is independent of where and how the files are physically
111 Contrast that with a version that purely uses the standard library:
114 def count_py_loc(path):
116 for root, dirs, files in os.walk(path):
118 if name.endswith('.py'):
119 with open(os.path.join(root, name), 'rt') as python_file:
120 count += sum(1 for line in python_file if line.strip())
124 This version is similar to the PyFilesystem code above, but would only
125 work with the OS filesystem. Any other filesystem would require an
126 entirely different API, and you would likely have to re-implement the
127 directory walking functionality of `os.walk`.
131 The following developers have contributed code and their time to this
142 660064febbccda264ae0b6bace80a8d1be9e089e0a5eb2427b7d517f9a91545c 135261 fs-2.4.16-py2.py3-none-any.whl