MCPcopy Index your code
hub / github.com/python/cpython / platform

Function platform

Lib/platform.py:1260–1326  ·  view source on GitHub ↗

Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended.

(aliased=False, terse=False)

Source from the content-addressed store, hash-verified

1258_platform_cache = {}
1259
1260def platform(aliased=False, terse=False):
1261
1262 """ Returns a single string identifying the underlying platform
1263 with as much useful information as possible (but no more :).
1264
1265 The output is intended to be human readable rather than
1266 machine parseable. It may look different on different
1267 platforms and this is intended.
1268
1269 If "aliased" is true, the function will use aliases for
1270 various platforms that report system names which differ from
1271 their common names, e.g. SunOS will be reported as
1272 Solaris. The system_alias() function is used to implement
1273 this.
1274
1275 Setting terse to true causes the function to return only the
1276 absolute minimum information needed to identify the platform.
1277
1278 """
1279 result = _platform_cache.get((aliased, terse), None)
1280 if result is not None:
1281 return result
1282
1283 # Get uname information and then apply platform specific cosmetics
1284 # to it...
1285 system, node, release, version, machine, processor = uname()
1286 if machine == processor:
1287 processor = ''
1288 if aliased:
1289 system, release, version = system_alias(system, release, version)
1290
1291 if system == 'Darwin':
1292 # macOS and iOS both report as a "Darwin" kernel
1293 if sys.platform == "ios":
1294 system, release, _, _ = ios_ver()
1295 else:
1296 macos_release = mac_ver()[0]
1297 if macos_release:
1298 system = 'macOS'
1299 release = macos_release
1300
1301 if system == 'Windows':
1302 # MS platforms
1303 rel, vers, csd, ptype = win32_ver(version)
1304 if terse:
1305 platform = _platform(system, release)
1306 else:
1307 platform = _platform(system, release, version, csd)
1308
1309 elif system == 'Linux':
1310 # check for libc vs. glibc
1311 libcname, libcversion = libc_ver()
1312 platform = _platform(system, release, machine, processor,
1313 'with',
1314 libcname+libcversion)
1315
1316 else:
1317 # Generic handler

Callers 1

_mainFunction · 0.85

Calls 9

unameFunction · 0.85
system_aliasFunction · 0.85
ios_verFunction · 0.85
mac_verFunction · 0.85
win32_verFunction · 0.85
_platformFunction · 0.85
libc_verFunction · 0.85
architectureFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…