@@ -102,11 +102,13 @@ def _status(self, code):
102102
103103 :param code: the collection status code
104104 :type code: int
105- :returns: the collection status text
106- :rtype: str | unicode
105+ :returns: the collection status text or ``None``
106+ :rtype: str | unicode | None
107107 :raises arango.exceptions.CollectionBadStatusError: if the collection
108108 status code is unknown
109109 """
110+ if code is None : # pragma: no cover
111+ return None
110112 try :
111113 return self .STATUSES [code ]
112114 except KeyError :
@@ -217,10 +219,10 @@ def handler(res):
217219 def properties (self ):
218220 """Return the collection properties.
219221
220- :returns: the collection properties
222+ :returns: The collection properties.
221223 :rtype: dict
222- :raises arango.exceptions.CollectionPropertiesError: if the
223- collection properties cannot be retrieved
224+ :raises arango.exceptions.CollectionPropertiesError: If the
225+ collection properties cannot be retrieved.
224226 """
225227 request = Request (
226228 method = 'get' ,
@@ -230,24 +232,24 @@ def properties(self):
230232 def handler (res ):
231233 if res .status_code not in HTTP_OK :
232234 raise CollectionPropertiesError (res )
233- result = {
234- 'id' : res .body ['id' ],
235- 'name' : res .body ['name' ],
236- 'edge' : res .body ['type' ] == 3 ,
237- 'sync' : res .body ['waitForSync' ],
238- 'status' : self ._status (res .body ['status' ]),
239- 'compact' : res .body ['doCompact' ],
240- 'system' : res .body ['isSystem' ],
241- 'volatile' : res .body ['isVolatile' ],
242- 'journal_size' : res .body ['journalSize' ],
243- 'keygen' : res .body ['keyOptions' ]['type' ],
244- 'user_keys' : res .body ['keyOptions' ]['allowUserKeys' ],
235+
236+ key_options = res .body .get ('keyOptions' , {})
237+
238+ return {
239+ 'id' : res .body .get ('id' ),
240+ 'name' : res .body .get ('name' ),
241+ 'edge' : res .body .get ('type' ) == 3 ,
242+ 'sync' : res .body .get ('waitForSync' ),
243+ 'status' : self ._status (res .body .get ('status' )),
244+ 'compact' : res .body .get ('doCompact' ),
245+ 'system' : res .body .get ('isSystem' ),
246+ 'volatile' : res .body .get ('isVolatile' ),
247+ 'journal_size' : res .body .get ('journalSize' ),
248+ 'keygen' : key_options .get ('type' ),
249+ 'user_keys' : key_options .get ('allowUserKeys' ),
250+ 'key_increment' : key_options .get ('increment' ),
251+ 'key_offset' : key_options .get ('offset' )
245252 }
246- if 'increment' in res .body ['keyOptions' ]:
247- result ['key_increment' ] = res .body ['keyOptions' ]['increment' ]
248- if 'offset' in res .body ['keyOptions' ]:
249- result ['key_offset' ] = res .body ['keyOptions' ]['offset' ]
250- return result
251253
252254 return request , handler
253255
@@ -257,9 +259,9 @@ def configure(self, sync=None, journal_size=None):
257259
258260 Only *sync* and *journal_size* properties are configurable.
259261
260- :param sync: wait for the operation to sync to disk
262+ :param sync: Wait for the operation to sync to disk.
261263 :type sync: bool
262- :param journal_size: the journal size
264+ :param journal_size: The journal size.
263265 :type journal_size: int
264266 :returns: the new collection properties
265267 :rtype: dict
@@ -281,22 +283,24 @@ def configure(self, sync=None, journal_size=None):
281283 def handler (res ):
282284 if res .status_code not in HTTP_OK :
283285 raise CollectionConfigureError (res )
284- result = {
285- 'id' : res .body ['id' ],
286- 'name' : res .body ['name' ],
287- 'edge' : res .body ['type' ] == 3 ,
288- 'sync' : res .body ['waitForSync' ],
289- 'status' : self ._status (res .body ['status' ]),
290- 'compact' : res .body ['doCompact' ],
291- 'system' : res .body ['isSystem' ],
292- 'volatile' : res .body ['isVolatile' ],
293- 'journal_size' : res .body ['journalSize' ],
294- 'keygen' : res .body ['keyOptions' ]['type' ],
295- 'user_keys' : res .body ['keyOptions' ]['allowUserKeys' ],
296- 'key_increment' : res .body ['keyOptions' ].get ('increment' ),
297- 'key_offset' : res .body ['keyOptions' ].get ('offset' )
286+
287+ key_options = res .body .get ('keyOptions' , {})
288+
289+ return {
290+ 'id' : res .body .get ('id' ),
291+ 'name' : res .body .get ('name' ),
292+ 'edge' : res .body .get ('type' ) == 3 ,
293+ 'sync' : res .body .get ('waitForSync' ),
294+ 'status' : self ._status (res .body .get ('status' )),
295+ 'compact' : res .body .get ('doCompact' ),
296+ 'system' : res .body .get ('isSystem' ),
297+ 'volatile' : res .body .get ('isVolatile' ),
298+ 'journal_size' : res .body .get ('journalSize' ),
299+ 'keygen' : key_options .get ('type' ),
300+ 'user_keys' : key_options .get ('allowUserKeys' ),
301+ 'key_increment' : key_options .get ('increment' ),
302+ 'key_offset' : key_options .get ('offset' )
298303 }
299- return result
300304
301305 return request , handler
302306
0 commit comments