Merge lp:~jderose/filestore/docs-update into lp:filestore

Proposed by Jason Gerard DeRose
Status: Merged
Merged at revision: 231
Proposed branch: lp:~jderose/filestore/docs-update
Merge into: lp:filestore
Diff against target: 194 lines (+96/-13)
2 files modified
doc/conf.py (+1/-1)
doc/filestore.rst (+95/-12)
To merge this branch: bzr merge lp:~jderose/filestore/docs-update
Reviewer Review Type Date Requested Status
dmedia Dev Pending
Review via email: mp+84924@code.launchpad.net

Description of the change

Updates the docs in a few places where they no longer reflected the current API.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/conf.py'
2--- doc/conf.py 2011-11-09 00:46:01 +0000
3+++ doc/conf.py 2011-12-08 11:35:30 +0000
4@@ -48,7 +48,7 @@
5 # built documents.
6 #
7 # The short X.Y version.
8-version = '11.11'
9+version = '11.12'
10 # The full version, including alpha/beta/rc tags.
11 release = version
12
13
14=== modified file 'doc/filestore.rst'
15--- doc/filestore.rst 2011-09-22 10:42:13 +0000
16+++ doc/filestore.rst 2011-12-08 11:35:30 +0000
17@@ -99,7 +99,7 @@
18 A ``bytes`` instance containing the concatenated leaf-hashes
19
20
21-.. class:: Stat(id, size, mtime)
22+.. class:: Stat(id, name, size, mtime)
23
24 Returned by :meth:`FileStore.stat()`, yielded by :meth:`FileStore.__iter__()`.
25
26@@ -107,6 +107,10 @@
27
28 The dmedia file ID
29
30+ .. attribute:: name
31+
32+ The absolute path of the file as returned by :meth:`FileStore.path()`
33+
34 .. attribute:: size
35
36 The file-size in bytes as reported by the file-system
37@@ -135,7 +139,7 @@
38
39 .. class:: Batch(files, size, count)
40
41- Returned by :func:`scandir()`.
42+ Returned by :func:`scandir()`, argument for :func:`batch_import_iter()`.
43
44 .. attribute:: files
45
46@@ -164,16 +168,12 @@
47 A ``bytes`` instance with the leaf content
48
49
50-.. class:: StatVFS(avail, size, used)
51+.. class:: StatVFS(size, used, avail, readonly, frsize)
52
53- Returned by :meth:`FileStore.statvfs()`.
54+ Returned by :func:`statvfs()` and :meth:`FileStore.statvfs()`.
55
56 All sizes are in bytes:
57
58- .. attribute:: avail
59-
60- Free space available to non-privileged users
61-
62 .. attribute:: size
63
64 Total file-system size
65@@ -182,6 +182,20 @@
66
67 Space consumed by existing files on file-system
68
69+ .. attribute:: avail
70+
71+ Free space available to non-privileged users
72+
73+ .. attribute:: readonly
74+
75+ ``True`` if filesystem is mounted read-only
76+
77+ .. attribute:: frsize
78+
79+ Block-size from ``os.statvfs()``, useful for deciding if an import batch
80+ will fit in a given :class:`FileStore`
81+
82+
83
84
85 Exceptions
86@@ -512,7 +526,7 @@
87 Read leaves from all files in *batch* and put them into the *queue*.
88
89
90-.. function:: batch_import_iter(batch, *filestores)
91+.. function:: batch_import_iter(batch, *filestores, callback=None)
92
93 Import the files in *batch* into one or more destination *filestores*.
94
95@@ -546,19 +560,86 @@
96 code in dmedia. However, the empty file does not get copied into the target
97 *filestores*.
98
99+ If you supply the *callback* keyword argument, it must be a callable that
100+ takes two arguments, like this:
101+
102+ >>> def progress(count, size):
103+ ... print(count, size)
104+
105+ Where *count* is the number of files that have been completely imported, and
106+ *size* is total bytes thus far imported.
107+
108+ The callback is called at the end of processing each file, plus whenever the
109+ next 128 MiB (16 leaves) have been completed and at least one more leaf
110+ remains.
111+
112+ For example, say you have a batch with one file and the file is exactly 33
113+ leaves in size (264 MiB). The callback would be called 3 times, like this:
114+
115+ >>> MiB = 1024 * 1024
116+ >>> progress(0, 128 * MiB)
117+ 0 134217728
118+ >>> progress(0, 256 * MiB)
119+ 0 268435456
120+ >>> progress(1, 264 * MiB)
121+ 1 276824064
122+
123+
124+
125+Misc functions
126+--------------
127+
128+
129+.. function:: ensuredir(dirname)
130+
131+ Ensure that *dirname* exists, is a directory, and is not a symlink.
132+
133+ This function is used by :meth:`FileStore.init_dirs()`.
134+
135+
136+.. function:: statvfs(pathname)
137+
138+ Return usage information for filesystem containing *pathname*.
139+
140+ This takes the information from ``os.statvfs()`` and presents it in a
141+ slightly higher-level way more fitting for filestore and Dmedia. A
142+ :class:`StatVFS` namedtuple is returned with the following attributes:
143+
144+ * size - the filesystem size in bytes
145+ * used - space in bytes consumed by existing files
146+ * avail - space in bytes available to non-privileged users
147+ * readonly - ``True`` if filesystem is mounted read-only
148+ * frsize - filesystem block size
149+
150+ This function is used by :meth:`FileStore.statvfs()`.
151+
152
153
154 The :class:`FileStore` class
155 ----------------------------
156
157
158-.. class:: FileStore(parentdir)
159+.. class:: FileStore(parentdir, _id=None, copies=0)
160
161 Arranges files in a special layout according to their content-hash.
162
163 .. attribute:: parentdir
164
165- The parent directory provided when this instance was created.
166+ The parent directory provided when instance was created.
167+
168+ .. attribute:: id
169+
170+ ID of file-store provided when instance was created.
171+
172+ This can be used by higher-level code like Dmedia, but is ignored by the
173+ :class:`FileStore` itself.
174+
175+ .. attribute:: copies
176+
177+ Durability of file-store as provided when instance was created.
178+
179+ This can be used by higher-level code like Dmedia, but is ignored by the
180+ :class:`FileStore` itself.
181
182 .. attribute:: basedir
183
184@@ -585,7 +666,9 @@
185
186 >>> fs = FileStore('/home/jderose') #doctest: +SKIP
187 >>> fs.statvfs() #doctest: +SKIP
188- StatVFS(avail=1791768784896, size=1936526733312, used=46388051968)
189+ StatVFS(size=1965511450624, used=812883484672, avail=1054258069504, readonly=False, frsize=4096)
190+
191+ This method uses the :func:`statvfs()` function.
192
193
194 .. method:: catch_traversal(untrusted)

Subscribers

People subscribed via source and target branches