mirror of
https://github.com/topjohnwu/selinux.git
synced 2025-04-01 06:11:36 +00:00
sepolgen: Use sort function with key parameter.
Since Python 2.4 .sort() as well as the new sorted() function take a key parameter which should be a function that returns a sorting key. Signed-off-by: Robert Kuska <rkuska@redhat.com>
This commit is contained in:
parent
467c2a45b9
commit
788f5dba54
@ -635,11 +635,11 @@ def lex(module=None,object=None,debug=0,optimize=0,lextab="lextab",reflags=0,now
|
||||
|
||||
# Sort the functions by line number
|
||||
for f in funcsym.values():
|
||||
f.sort(lambda x,y: cmp(x[1].__code__.co_firstlineno,y[1].__code__.co_firstlineno))
|
||||
f.sort(key=lambda x: x[1].__code__.co_firstlineno)
|
||||
|
||||
# Sort the strings by regular expression length
|
||||
for s in strsym.values():
|
||||
s.sort(lambda x,y: (len(x[1]) < len(y[1])) - (len(x[1]) > len(y[1])))
|
||||
s.sort(key=lambda x: len(x[1]))
|
||||
|
||||
regexs = { }
|
||||
|
||||
|
@ -2100,7 +2100,7 @@ def yacc(method=default_lr, debug=yaccdebug, module=None, tabmodule=tab_module,
|
||||
raise YaccError,"no rules of the form p_rulename are defined."
|
||||
|
||||
# Sort the symbols by line number
|
||||
symbols.sort(lambda x,y: cmp(x.__code__.co_firstlineno,y.__code__.co_firstlineno))
|
||||
symbols.sort(key=lambda x: x.__code__.co_firstlineno)
|
||||
|
||||
# Add all of the symbols to the grammar
|
||||
for f in symbols:
|
||||
|
Loading…
x
Reference in New Issue
Block a user