1 |
On Wed, Oct 29, 2008 at 4:51 PM, Andrey Vul <andrey.vul@×××××.com> wrote: |
2 |
|
3 |
> Found the code, and it's actually part of python (as of 2.4). |
4 |
> Gentoo sets aliased to 1 when printing the system uname. |
5 |
> /usr/lib/python2.{4,5,6}/platform.py: |
6 |
> |
7 |
> def _platform(*args): |
8 |
> |
9 |
> """ Helper to format the platform string in a filename |
10 |
> compatible format e.g. "system-version-machine". |
11 |
> """ |
12 |
> # Format the platform string |
13 |
> platform = string.join( |
14 |
> map(string.strip, |
15 |
> filter(len,args)), |
16 |
> '-') |
17 |
> |
18 |
> # Cleanup some possible filename obstacles... |
19 |
> replace = string.replace |
20 |
> platform = replace(platform,' ','_') |
21 |
> platform = replace(platform,'/','-') |
22 |
> platform = replace(platform,'\\','-') |
23 |
> platform = replace(platform,':','-') |
24 |
> platform = replace(platform,';','-') |
25 |
> platform = replace(platform,'"','-') |
26 |
> platform = replace(platform,'(','-') |
27 |
> platform = replace(platform,')','-') |
28 |
> |
29 |
> # No need to report 'unknown' information... |
30 |
> platform = replace(platform,'unknown','') |
31 |
> |
32 |
> # Fold '--'s and remove trailing '-' |
33 |
> while 1: |
34 |
> cleaned = replace(platform,'--','-') |
35 |
> if cleaned == platform: |
36 |
> break |
37 |
> platform = cleaned |
38 |
> while platform[-1] == '-': |
39 |
> platform = platform[:-1] |
40 |
> |
41 |
> return platform |
42 |
> |
43 |
> def platform(aliased=0, terse=0): |
44 |
> |
45 |
> """ Returns a single string identifying the underlying platform |
46 |
> with as much useful information as possible (but no more :). |
47 |
> |
48 |
> The output is intended to be human readable rather than |
49 |
> machine parseable. It may look different on different |
50 |
> platforms and this is intended. |
51 |
> |
52 |
> If "aliased" is true, the function will use aliases for |
53 |
> various platforms that report system names which differ from |
54 |
> their common names, e.g. SunOS will be reported as |
55 |
> Solaris. The system_alias() function is used to implement |
56 |
> this. |
57 |
> |
58 |
> Setting terse to true causes the function to return only the |
59 |
> absolute minimum information needed to identify the platform. |
60 |
> |
61 |
> """ |
62 |
> result = _platform_cache.get((aliased, terse), None) |
63 |
> if result is not None: |
64 |
> return result |
65 |
> |
66 |
> # Get uname information and then apply platform specific cosmetics |
67 |
> # to it... |
68 |
> system,node,release,version,machine,processor = uname() |
69 |
> if machine == processor: |
70 |
> processor = '' |
71 |
> if aliased: |
72 |
> system,release,version = system_alias(system,release,version) |
73 |
> |
74 |
> if system == 'Windows': |
75 |
> # MS platforms |
76 |
> rel,vers,csd,ptype = win32_ver(version) |
77 |
> if terse: |
78 |
> platform = _platform(system,release) |
79 |
> else: |
80 |
> platform = _platform(system,release,version,csd) |
81 |
> |
82 |
> elif system in ('Linux',): |
83 |
> # Linux based systems |
84 |
> distname,distversion,distid = dist('') |
85 |
> if distname and not terse: |
86 |
> platform = _platform(system,release,machine,processor, |
87 |
> 'with', |
88 |
> distname,distversion,distid) |
89 |
> else: |
90 |
> # If the distribution name is unknown check for libc vs. glibc |
91 |
> libcname,libcversion = libc_ver(sys.executable) |
92 |
> platform = _platform(system,release,machine,processor, |
93 |
> 'with', |
94 |
> libcname+libcversion) |
95 |
> elif system == 'Java': |
96 |
> # Java platforms |
97 |
> r,v,vminfo,(os_name,os_version,os_arch) = java_ver() |
98 |
> if terse: |
99 |
> platform = _platform(system,release,version) |
100 |
> else: |
101 |
> platform = _platform(system,release,version, |
102 |
> 'on', |
103 |
> os_name,os_version,os_arch) |
104 |
> |
105 |
> elif system == 'MacOS': |
106 |
> # MacOS platforms |
107 |
> if terse: |
108 |
> platform = _platform(system,release) |
109 |
> else: |
110 |
> platform = _platform(system,release,machine) |
111 |
> |
112 |
> else: |
113 |
> # Generic handler |
114 |
> if terse: |
115 |
> platform = _platform(system,release) |
116 |
> else: |
117 |
> bits,linkage = architecture(sys.executable) |
118 |
> platform = |
119 |
> _platform(system,release,machine,processor,bits,linkage) |
120 |
> |
121 |
> _platform_cache[(aliased, terse)] = platform |
122 |
> return platform |
123 |
> |
124 |
> |
125 |
> Proof: run /usr/lib/python2.{4,5,6}/platform.py |
126 |
> aliased and terse have no effect wrt output |
127 |
> (kernel_version-with-libc_version) |
128 |
> -- |
129 |
> Andrey Vul |
130 |
> |
131 |
> A: Because it messes up the order in which people normally read text. |
132 |
> Q: Why is top-posting such a bad thing? |
133 |
> A: Top-posting. |
134 |
> Q: What is the most annoying thing in e-mail? |
135 |
> |
136 |
> |
137 |
Good digging around :). So this is a python bug then? Or does portage need |
138 |
to be update for some change that went into python? Actually, is this really |
139 |
even a bug...its just a minor cosmetic problem really. |