Commit e47b93f4 authored by Sophie Herold's avatar Sophie Herold
Browse files

Fixes |sort() filter (python3 incompatibility)

parent a362324d
......@@ -7,7 +7,11 @@ data = [
{ 'name': 'test1'
, 'password': '*'
, 'uid': 10000
, 'gid': 10000 }
, 'gid': 10000 },
{ 'name': 'name1'
, 'password': '*'
, 'uid': 10001
, 'gid': 10001 }
]
# write /etc/passwd style file
......@@ -16,6 +20,7 @@ data = [
| add_from_value('gecos', '')
| add_from_value('shell', '/bin/false')
| add_from_value('home', '/home/%(name)s')
| sort(key=lambda x: x['name'])
| to_passwd_line()
> 'passwd.test'
)
......@@ -188,14 +188,13 @@ class skip_while(base.Filter):
return chunk
class sort(base.FilterNeedsAll):
def __init__(self, cmp_=None, key=None, reverse=False):
def __init__(self, key=None, reverse=False):
base.FilterNeedsAll.__init__(self)
self._cmp = cmp_
self._key = key
self._reverse = reverse
def _process(self, _input):
return sorted(_input, self._cmp, self._key, self._reverse)
return sorted(_input, key=self._key, reverse=self._reverse)
class reverse(base.FilterNeedsAll):
def _process(self, _input):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment