@@ -41,7 +41,7 @@ class Info(object):
41
41
raw_info (dict): A dict containing resource info.
42
42
to_datetime (callable): A callable that converts an
43
43
epoch time to a datetime object. The default uses
44
- :func: `~fs.time.epoch_to_datetime`.
44
+ `~fs.time.epoch_to_datetime`.
45
45
46
46
"""
47
47
@@ -132,7 +132,8 @@ def is_writeable(self, namespace, key):
132
132
# type: (Text, Text) -> bool
133
133
"""Check if a given key in a namespace is writable.
134
134
135
- Uses `~fs.base.FS.setinfo`.
135
+ When creating an `Info` object, you can add a ``_write`` key to
136
+ each raw namespace that lists which keys are writable or not.
136
137
137
138
Arguments:
138
139
namespace (str): A namespace identifier.
@@ -141,6 +142,24 @@ def is_writeable(self, namespace, key):
141
142
Returns:
142
143
bool: `True` if the key can be modified, `False` otherwise.
143
144
145
+ Example:
146
+ Create an `Info` object that marks only the ``modified`` key
147
+ as writable in the ``details`` namespace::
148
+
149
+ >>> now = time.time()
150
+ >>> info = Info({
151
+ ... "basic": {"name": "foo", "is_dir": False},
152
+ ... "details": {
153
+ ... "modified": now,
154
+ ... "created": now,
155
+ ... "_write": ["modified"],
156
+ ... }
157
+ ... })
158
+ >>> info.is_writeable("details", "created")
159
+ False
160
+ >>> info.is_writeable("details", "modified")
161
+ True
162
+
144
163
"""
145
164
_writeable = self .get (namespace , "_write" , ())
146
165
return key in _writeable
0 commit comments