4
4
5
5
from .. import core
6
6
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
+ }
8
15
9
16
10
17
parser = core .create_parser (
@@ -75,21 +82,23 @@ def python_userland_uname(opts, args):
75
82
76
83
extras : list [str ] = []
77
84
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 )
81
88
else :
82
- if opts .p :
89
+ if opts .processor :
83
90
extras .append ("unknown" )
84
91
85
- if opts .i :
92
+ if opts .hardware_platform :
86
93
extras .append ("unknown" )
87
94
88
- if opts .o :
95
+ if opts .operating_system :
89
96
extras .append ("unknown" )
90
97
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
93
102
94
103
uname = os .uname ()
95
104
@@ -104,7 +113,7 @@ def python_userland_uname(opts, args):
104
113
"version" ,
105
114
"machine" ,
106
115
]
107
- if getattr (opts , attribute [ 0 ])
116
+ if getattr (opts , UNAME_ATTRS [ attribute ])
108
117
]
109
118
+ extras
110
119
)
0 commit comments