summaryrefslogtreecommitdiff
path: root/src/flake8/utils.py
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-06-28 13:02:50 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-06-28 13:02:50 -0500
commitc9fb680dffa37517bbda76cc2b572d6f192508bd (patch)
tree4d8c1f93ab2be6618eb358b603db62839e40ca03 /src/flake8/utils.py
parent2d3e277b1e0c0a24c30c611558692f95d14a8470 (diff)
downloadflake8-c9fb680dffa37517bbda76cc2b572d6f192508bd.tar.gz
Add python and platform details to --version
On Flake8 2.x we added the information about the implementation, version, and operating system to the --version output to make helping users easier. In short they can pretty simply just give us the output from flake8 --version And we can get a lot of the information that we need.
Diffstat (limited to 'src/flake8/utils.py')
-rw-r--r--src/flake8/utils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/flake8/utils.py b/src/flake8/utils.py
index fbd15b9..68ed530 100644
--- a/src/flake8/utils.py
+++ b/src/flake8/utils.py
@@ -4,6 +4,7 @@ import fnmatch as _fnmatch
import inspect
import io
import os
+import platform
import re
import sys
@@ -290,3 +291,19 @@ def parameters_for(plugin):
parameters.pop('self', None)
return parameters
+
+
+def get_python_version():
+ """Find and format the python implementation and version.
+
+ :returns:
+ Implementation name, version, and platform as a string.
+ :rtype:
+ str
+ """
+ # The implementation isn't all that important.
+ try:
+ impl = platform.python_implementation() + " "
+ except AttributeError: # Python 2.5
+ impl = ''
+ return '%s%s on %s' % (impl, platform.python_version(), platform.system())