| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b476d59 commit 5f28b7b
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1254,10 +1254,10 @@ def processor(): | |||
| 1254 | 1254 | def _sys_version(sys_version=None): | |
| 1255 | 1255 | ||
| 1256 | 1256 | """ Returns a parsed version of Python's sys.version as tuple | |
| 1257 | - (name, version, branch, revision, buildno, builddate, compiler) | ||
| 1258 | - referring to the Python implementation name, version, branch, | ||
| 1259 | - revision, build number, build date/time as string and the compiler | ||
| 1260 | - identification string. | ||
| 1257 | + (name, version, branch, revision, buildno, builddate, compiler) | ||
| 1258 | + referring to the Python implementation name, version, branch, | ||
| 1259 | + revision, build number, build date/time as string and the compiler | ||
| 1260 | + identification string. | ||
| 1261 | 1261 | ||
| 1262 | 1262 | Note that unlike the Python sys.version, the returned value | |
| 1263 | 1263 | for the Python version will always include the patchlevel (it | |
@@ -1359,8 +1359,6 @@ def python_version(): | |||
| 1359 | 1359 | will always include the patchlevel (it defaults to 0). | |
| 1360 | 1360 | ||
| 1361 | 1361 | """ | |
| 1362 | - if hasattr(sys, 'version_info'): | ||
| 1363 | - return '%i.%i.%i' % sys.version_info[:3] | ||
| 1364 | 1362 | return _sys_version()[1] | |
| 1365 | 1363 | ||
| 1366 | 1364 | def python_version_tuple(): | |
@@ -1372,8 +1370,6 @@ def python_version_tuple(): | |||
| 1372 | 1370 | will always include the patchlevel (it defaults to 0). | |
| 1373 | 1371 | ||
| 1374 | 1372 | """ | |
| 1375 | - if hasattr(sys, 'version_info'): | ||
| 1376 | - return sys.version_info[:3] | ||
| 1377 | 1373 | return tuple(_sys_version()[1].split('.')) | |
| 1378 | 1374 | ||
| 1379 | 1375 | def python_branch(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,39 +25,48 @@ def get(python): | |||
| 25 | 25 | finally: | |
| 26 | 26 | os.remove(link) | |
| 27 | 27 | ||
| 28 | - def test_machine(self): | ||
| 29 | - res = platform.machine() | ||
| 30 | - | ||
| 31 | - def test_node(self): | ||
| 32 | - res = platform.node() | ||
| 33 | - | ||
| 34 | 28 | def test_platform(self): | |
| 35 | 29 | for aliased in (False, True): | |
| 36 | 30 | for terse in (False, True): | |
| 37 | 31 | res = platform.platform(aliased, terse) | |
| 38 | 32 | ||
| 39 | - def test_processor(self): | ||
| 40 | - res = platform.processor() | ||
| 33 | + def test_system(self): | ||
| 34 | + res = platform.system() | ||
| 41 | 35 | ||
| 42 | - def test_python_build(self): | ||
| 43 | - res = platform.python_build() | ||
| 36 | + def test_node(self): | ||
| 37 | + res = platform.node() | ||
| 44 | 38 | ||
| 45 | - def test_python_compiler(self): | ||
| 46 | - res = platform.python_compiler() | ||
| 39 | + def test_release(self): | ||
| 40 | + res = platform.release() | ||
| 47 | 41 | ||
| 48 | 42 | def test_version(self): | |
| 49 | - res1 = platform.version() | ||
| 50 | - res2 = platform.version_tuple() | ||
| 43 | + res = platform.version() | ||
| 44 | + | ||
| 45 | + def test_machine(self): | ||
| 46 | + res = platform.machine() | ||
| 47 | + | ||
| 48 | + def test_processor(self): | ||
| 49 | + res = platform.processor() | ||
| 50 | + | ||
| 51 | + def test_python_implementation(self): | ||
| 52 | + res = platform.python_implementation() | ||
| 53 | + | ||
| 54 | + def test_python_version(self): | ||
| 55 | + res1 = platform.python_version() | ||
| 56 | + res2 = platform.python_version_tuple() | ||
| 51 | 57 | self.assertEqual(res1, ".".join(res2)) | |
| 52 | 58 | ||
| 53 | - def test_release(self): | ||
| 54 | - res = platform.release() | ||
| 59 | + def test_python_branch(self): | ||
| 60 | + res = platform.python_branch() | ||
| 55 | 61 | ||
| 56 | - def test_system(self): | ||
| 57 | - res = platform.system() | ||
| 62 | + def test_python_revision(self): | ||
| 63 | + res = platform.python_revision() | ||
| 58 | 64 | ||
| 59 | - def test_version(self): | ||
| 60 | - res = platform.version() | ||
| 65 | + def test_python_build(self): | ||
| 66 | + res = platform.python_build() | ||
| 67 | + | ||
| 68 | + def test_python_compiler(self): | ||
| 69 | + res = platform.python_compiler() | ||
| 61 | 70 | ||
| 62 | 71 | def test_system_alias(self): | |
| 63 | 72 | res = platform.system_alias( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1474,41 +1474,45 @@ def retrieve(self, url, filename=None, reporthook=None, data=None): | |||
| 1474 | 1474 | except IOError as msg: | |
| 1475 | 1475 | pass | |
| 1476 | 1476 | fp = self.open(url, data) | |
| 1477 | - headers = fp.info() | ||
| 1478 | - if filename: | ||
| 1479 | - tfp = open(filename, 'wb') | ||
| 1480 | - else: | ||
| 1481 | - import tempfile | ||
| 1482 | - garbage, path = splittype(url) | ||
| 1483 | - garbage, path = splithost(path or "") | ||
| 1484 | - path, garbage = splitquery(path or "") | ||
| 1485 | - path, garbage = splitattr(path or "") | ||
| 1486 | - suffix = os.path.splitext(path)[1] | ||
| 1487 | - (fd, filename) = tempfile.mkstemp(suffix) | ||
| 1488 | - self.__tempfiles.append(filename) | ||
| 1489 | - tfp = os.fdopen(fd, 'wb') | ||
| 1490 | - result = filename, headers | ||
| 1491 | - if self.tempcache is not None: | ||
| 1492 | - self.tempcache[url] = result | ||
| 1493 | - bs = 1024*8 | ||
| 1494 | - size = -1 | ||
| 1495 | - read = 0 | ||
| 1496 | - blocknum = 0 | ||
| 1497 | - if reporthook: | ||
| 1498 | - if "content-length" in headers: | ||
| 1499 | - size = int(headers["Content-Length"]) | ||
| 1500 | - reporthook(blocknum, bs, size) | ||
| 1501 | - while 1: | ||
| 1502 | - block = fp.read(bs) | ||
| 1503 | - if not block: | ||
| 1504 | - break | ||
| 1505 | - read += len(block) | ||
| 1506 | - tfp.write(block) | ||
| 1507 | - blocknum += 1 | ||
| 1508 | - if reporthook: | ||
| 1509 | - reporthook(blocknum, bs, size) | ||
| 1510 | - fp.close() | ||
| 1511 | - tfp.close() | ||
| 1477 | + try: | ||
| 1478 | + headers = fp.info() | ||
| 1479 | + if filename: | ||
| 1480 | + tfp = open(filename, 'wb') | ||
| 1481 | + else: | ||
| 1482 | + import tempfile | ||
| 1483 | + garbage, path = splittype(url) | ||
| 1484 | + garbage, path = splithost(path or "") | ||
| 1485 | + path, garbage = splitquery(path or "") | ||
| 1486 | + path, garbage = splitattr(path or "") | ||
| 1487 | + suffix = os.path.splitext(path)[1] | ||
| 1488 | + (fd, filename) = tempfile.mkstemp(suffix) | ||
| 1489 | + self.__tempfiles.append(filename) | ||
| 1490 | + tfp = os.fdopen(fd, 'wb') | ||
| 1491 | + try: | ||
| 1492 | + result = filename, headers | ||
| 1493 | + if self.tempcache is not None: | ||
| 1494 | + self.tempcache[url] = result | ||
| 1495 | + bs = 1024*8 | ||
| 1496 | + size = -1 | ||
| 1497 | + read = 0 | ||
| 1498 | + blocknum = 0 | ||
| 1499 | + if reporthook: | ||
| 1500 | + if "content-length" in headers: | ||
| 1501 | + size = int(headers["Content-Length"]) | ||
| 1502 | + reporthook(blocknum, bs, size) | ||
| 1503 | + while 1: | ||
| 1504 | + block = fp.read(bs) | ||
| 1505 | + if not block: | ||
| 1506 | + break | ||
| 1507 | + read += len(block) | ||
| 1508 | + tfp.write(block) | ||
| 1509 | + blocknum += 1 | ||
| 1510 | + if reporthook: | ||
| 1511 | + reporthook(blocknum, bs, size) | ||
| 1512 | + finally: | ||
| 1513 | + tfp.close() | ||
| 1514 | + finally: | ||
| 1515 | + fp.close() | ||
| 1512 | 1516 | del fp | |
| 1513 | 1517 | del tfp | |
| 1514 | 1518 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | .TH PYTHON "1" "$Date$" | |
| 2 | 2 | ||
| 3 | - ./" To view this file while editing, run it through groff: | ||
| 4 | - ./" groff -Tascii -man python.man | less | ||
| 3 | + .\" To view this file while editing, run it through groff: | ||
| 4 | + .\" groff -Tascii -man python.man | less | ||
| 5 | 5 | ||
| 6 | 6 | .SH NAME | |
| 7 | 7 | python \- an interpreted, interactive, object-oriented programming language | |
| Back | FazBrowse Home | New Git URL |
0 commit comments