44
55from .. import core
66
7- UNAME_ATTRS = frozenset ("mnrsv" )
7+ # mapping of uname_result attribute name to option atttribute name
8+ UNAME_ATTRS = {
9+ "sysname" : "kernel_name" ,
10+ "nodename" : "nodename" ,
11+ "release" : "kernel_release" ,
12+ "version" : "kernel_version" ,
13+ "machine" : "machine" ,
14+ }
815
916
1017parser = core .create_parser (
@@ -75,21 +82,23 @@ def python_userland_uname(opts, args):
7582
7683 extras : list [str ] = []
7784
78- if opts .a :
79- for attr in UNAME_ATTRS :
80- setattr (opts , attr , True )
85+ if opts .all :
86+ for optname in UNAME_ATTRS . values () :
87+ setattr (opts , optname , True )
8188 else :
82- if opts .p :
89+ if opts .processor :
8390 extras .append ("unknown" )
8491
85- if opts .i :
92+ if opts .hardware_platform :
8693 extras .append ("unknown" )
8794
88- if opts .o :
95+ if opts .operating_system :
8996 extras .append ("unknown" )
9097
91- if not extras and not any ({getattr (opts , attr ) for attr in UNAME_ATTRS }):
92- opts .s = True
98+ if not extras and not any (
99+ {getattr (opts , optname ) for optname in UNAME_ATTRS .values ()}
100+ ):
101+ opts .kernel_name = True
93102
94103 uname = os .uname ()
95104
@@ -104,7 +113,7 @@ def python_userland_uname(opts, args):
104113 "version" ,
105114 "machine" ,
106115 ]
107- if getattr (opts , attribute [ 0 ])
116+ if getattr (opts , UNAME_ATTRS [ attribute ])
108117 ]
109118 + extras
110119 )
0 commit comments