Skip to content

Commit 7178d58

Browse files
yocaleboixhamza
authored andcommitted
__getstate__() -> asdict()
1 parent b5cf02d commit 7178d58

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

libzfs.pyx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ class DiffRecord(object):
377377
def __repr__(self):
378378
return str(self)
379379

380-
def __getstate__(self):
380+
def asdict(self):
381381
return {
382382
'timestamp': self.timestamp,
383383
'cmd': self.cmd.name,
@@ -474,8 +474,8 @@ cdef class ZFS(object):
474474
def __dealloc__(self):
475475
ZFS.__libzfs_fini(self)
476476

477-
def __getstate__(self):
478-
return [p.__getstate__() for p in self.pools]
477+
def asdict(self):
478+
return [p.asdict() for p in self.pools]
479479

480480
IF HAVE_ZPOOL_EVENTS_NEXT:
481481
def zpool_events(self, blocking=True, skip_existing_events=False):
@@ -1695,7 +1695,7 @@ cdef class ZPoolProperty(object):
16951695
def __init__(self):
16961696
raise RuntimeError('ZPoolProperty cannot be instantiated by the user')
16971697

1698-
def __getstate__(self):
1698+
def asdict(self):
16991699
return {
17001700
'value': self.value,
17011701
'rawvalue': self.rawvalue,
@@ -1785,7 +1785,7 @@ cdef class ZPoolFeature(object):
17851785
cdef NVList nvlist
17861786
cdef zfs.zfeature_info_t *feature
17871787

1788-
def __getstate__(self):
1788+
def asdict(self):
17891789
return {
17901790
'name': self.name,
17911791
'guid': self.guid,
@@ -1844,7 +1844,7 @@ cdef class ZFSProperty(object):
18441844
def __init__(self):
18451845
raise RuntimeError('ZFSProperty cannot be instantiated by the user')
18461846

1847-
def __getstate__(self):
1847+
def asdict(self):
18481848
return {
18491849
'value': self.value,
18501850
'rawvalue': self.rawvalue,
@@ -2033,7 +2033,7 @@ cdef class ZFSVdevStats(object):
20332033
cdef zfs.vdev_stat_t *vs;
20342034
cdef uint_t total
20352035

2036-
def __getstate__(self):
2036+
def asdict(self):
20372037
state = {
20382038
'timestamp': self.timestamp,
20392039
'read_errors': self.read_errors,
@@ -2143,18 +2143,18 @@ cdef class ZFSVdev(object):
21432143
def __repr__(self):
21442144
return str(self)
21452145

2146-
def __getstate__(self, recursive=True):
2146+
def asdict(self, recursive=True):
21472147
ret = {
21482148
'name': self.name,
21492149
'type': self.type,
21502150
'path': self.path,
21512151
'guid': str(self.guid),
21522152
'status': self.status,
2153-
'stats': self.stats.__getstate__()
2153+
'stats': self.stats.asdict()
21542154
}
21552155

21562156
if recursive:
2157-
ret['children'] = [i.__getstate__() for i in self.children]
2157+
ret['children'] = [i.asdict() for i in self.children]
21582158

21592159
return ret
21602160

@@ -2541,7 +2541,7 @@ cdef class ZPoolScrub(object):
25412541

25422542
return (<float>self.bytes_issued / <float>self.bytes_to_scan) * 100
25432543

2544-
def __getstate__(self):
2544+
def asdict(self):
25452545
return {
25462546
'function': self.function.name if self.function else None,
25472547
'state': self.state.name if self.stats != NULL else None,
@@ -2581,9 +2581,9 @@ cdef class ZFSPool(object):
25812581
def __repr__(self):
25822582
return str(self)
25832583

2584-
def __getstate__(self, datasets_recursive=True):
2584+
def asdict(self, datasets_recursive=True):
25852585
try:
2586-
root_ds = self.root_dataset.__getstate__(datasets_recursive)
2586+
root_ds = self.root_dataset.asdict(datasets_recursive)
25872587
except (ZFSException, AttributeError):
25882588
root_ds = None
25892589

@@ -2599,21 +2599,21 @@ cdef class ZFSPool(object):
25992599
'warning': self.warning,
26002600
'error_count': self.error_count,
26012601
'root_dataset': root_ds,
2602-
'properties': {k: p.__getstate__() for k, p in self.properties.items()} if self.properties else None,
2603-
'features': [i.__getstate__() for i in self.features] if self.features else None,
2604-
'scan': self.scrub.__getstate__(),
2605-
'root_vdev': self.root_vdev.__getstate__(False),
2602+
'properties': {k: p.asdict() for k, p in self.properties.items()} if self.properties else None,
2603+
'features': [i.asdict() for i in self.features] if self.features else None,
2604+
'scan': self.scrub.asdict(),
2605+
'root_vdev': self.root_vdev.asdict(False),
26062606
'groups': {
2607-
'data': [i.__getstate__() for i in self.data_vdevs if i.type not in filter_vdevs],
2608-
'log': [i.__getstate__() for i in self.log_vdevs if i.type not in filter_vdevs],
2609-
'cache': [i.__getstate__() for i in self.cache_vdevs if i.type not in filter_vdevs],
2610-
'spare': [i.__getstate__() for i in self.spare_vdevs if i.type not in filter_vdevs],
2607+
'data': [i.asdict() for i in self.data_vdevs if i.type not in filter_vdevs],
2608+
'log': [i.asdict() for i in self.log_vdevs if i.type not in filter_vdevs],
2609+
'cache': [i.asdict() for i in self.cache_vdevs if i.type not in filter_vdevs],
2610+
'spare': [i.asdict() for i in self.spare_vdevs if i.type not in filter_vdevs],
26112611
},
26122612
}
26132613
IF HAVE_ZPOOL_CONFIG_ALLOCATION_BIAS:
26142614
state['groups'].update({
2615-
'special': [i.__getstate__() for i in self.special_vdevs if i.type not in filter_vdevs],
2616-
'dedup': [i.__getstate__() for i in self.dedup_vdevs if i.type not in filter_vdevs],
2615+
'special': [i.asdict() for i in self.special_vdevs if i.type not in filter_vdevs],
2616+
'dedup': [i.asdict() for i in self.dedup_vdevs if i.type not in filter_vdevs],
26172617
})
26182618

26192619
if self.handle != NULL:
@@ -3328,13 +3328,13 @@ cdef class ZFSObject(object):
33283328
def __repr__(self):
33293329
return str(self)
33303330

3331-
def __getstate__(self):
3331+
def asdict(self):
33323332
return {
33333333
'id': self.name,
33343334
'name': self.name,
33353335
'pool': self.pool.name,
33363336
'type': self.type.name,
3337-
'properties': {k: p.__getstate__() for k, p in self.properties.items()},
3337+
'properties': {k: p.asdict() for k, p in self.properties.items()},
33383338
}
33393339

33403340
property name:
@@ -3535,18 +3535,18 @@ cdef class ZFSResource(ZFSObject):
35353535

35363536

35373537
cdef class ZFSDataset(ZFSResource):
3538-
def __getstate__(self, recursive=True, snapshots=False, snapshots_recursive=False):
3539-
ret = super(ZFSDataset, self).__getstate__()
3538+
def asdict(self, recursive=True, snapshots=False, snapshots_recursive=False):
3539+
ret = super(ZFSDataset, self).asdict()
35403540
ret['mountpoint'] = self.mountpoint
35413541

35423542
if recursive:
3543-
ret['children'] = [i.__getstate__() for i in self.children]
3543+
ret['children'] = [i.asdict() for i in self.children]
35443544

35453545
if snapshots:
3546-
ret['snapshots'] = [s.__getstate__() for s in self.snapshots]
3546+
ret['snapshots'] = [s.asdict() for s in self.snapshots]
35473547

35483548
if snapshots_recursive:
3549-
ret['snapshots_recursive'] = [s.__getstate__() for s in self.snapshots_recursive]
3549+
ret['snapshots_recursive'] = [s.asdict() for s in self.snapshots_recursive]
35503550

35513551
IF HAVE_ZFS_ENCRYPTION:
35523552
root = self.encryption_root
@@ -4125,8 +4125,8 @@ cdef class ZFSDataset(ZFSResource):
41254125

41264126

41274127
cdef class ZFSSnapshot(ZFSResource):
4128-
def __getstate__(self):
4129-
ret = super(ZFSSnapshot, self).__getstate__()
4128+
def asdict(self):
4129+
ret = super(ZFSSnapshot, self).asdict()
41304130
ret.update({
41314131
'holds': self.holds,
41324132
'dataset': self.parent.name,
@@ -4321,8 +4321,8 @@ cdef class ZFSSnapshot(ZFSResource):
43214321
raise NotImplementedError()
43224322

43234323
cdef class ZFSBookmark(ZFSObject):
4324-
def __getstate__(self):
4325-
ret = super(ZFSBookmark, self).__getstate__()
4324+
def asdict(self):
4325+
ret = super(ZFSBookmark, self).asdict()
43264326
ret.update({
43274327
'dataset': self.parent.name,
43284328
'bookmark_name': self.bookmark_name

0 commit comments

Comments
 (0)