├── .gitignore
├── README.md
├── example.ipynb
├── setup.py
├── version_information.py
└── version_information
├── __init__.py
└── version_information.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.py[cod]
2 |
3 | # C extensions
4 | *.so
5 |
6 | # Packages
7 | *.egg
8 | *.egg-info
9 | dist
10 | build
11 | eggs
12 | parts
13 | bin
14 | var
15 | sdist
16 | develop-eggs
17 | .installed.cfg
18 | lib
19 | lib64
20 |
21 | # Installer logs
22 | pip-log.txt
23 |
24 | # Unit test / coverage reports
25 | .coverage
26 | .tox
27 | nosetests.xml
28 |
29 | # Translations
30 | *.mo
31 |
32 | # Mr Developer
33 | .mr.developer.cfg
34 | .project
35 | .pydevproject
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | %version_information
2 | ====================
3 |
4 | IPython magic extension for showing version information for dependency modules in
5 | a notebook.
6 |
7 | See the
8 | [example notebook](http://nbviewer.ipython.org/urls/raw.github.com/jrjohansson/version_information/master/example.ipynb)
9 | for intallation instruction and example of how to use this magic extension.
10 |
11 |
12 |
13 | License
14 | =======
15 |
16 | This work is licensed under a [Creative Commons Attribution 3.0 Unported License.](http://creativecommons.org/licenses/by/3.0/)
17 |
--------------------------------------------------------------------------------
/example.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# IPython extension version_information"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "Use the '%version_information' IPython magic extension in a notebook to display information about which versions of dependency package that was used to run the notebook."
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "## Installation"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "Install the `version_information` package using pip:\n",
29 | " \n",
30 | " pip install version_information\n",
31 | "\n",
32 | "or, alternatively, use the `%install_ext` IPython command (deprecated):\n",
33 | "\n",
34 | " %install_ext http://raw.github.com/jrjohansson/version_information/master/version_information.py"
35 | ]
36 | },
37 | {
38 | "cell_type": "markdown",
39 | "metadata": {},
40 | "source": [
41 | "## Use"
42 | ]
43 | },
44 | {
45 | "cell_type": "code",
46 | "execution_count": 1,
47 | "metadata": {
48 | "collapsed": false
49 | },
50 | "outputs": [],
51 | "source": [
52 | "%load_ext version_information"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": 2,
58 | "metadata": {
59 | "collapsed": false
60 | },
61 | "outputs": [
62 | {
63 | "data": {
64 | "application/json": {
65 | "Software versions": [
66 | {
67 | "module": "Python",
68 | "version": "2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)]"
69 | },
70 | {
71 | "module": "IPython",
72 | "version": "3.2.0"
73 | },
74 | {
75 | "module": "OS",
76 | "version": "Darwin 14.1.0 x86_64 i386 64bit"
77 | }
78 | ]
79 | },
80 | "text/html": [
81 | "
Software | Version |
---|
Python | 2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)] |
IPython | 3.2.0 |
OS | Darwin 14.1.0 x86_64 i386 64bit |
Tue Jul 21 23:39:04 2015 JST |
"
82 | ],
83 | "text/latex": [
84 | "\\begin{tabular}{|l|l|}\\hline\n",
85 | "{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n",
86 | "Python & 2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)] \\\\ \\hline\n",
87 | "IPython & 3.2.0 \\\\ \\hline\n",
88 | "OS & Darwin 14.1.0 x86\\_64 i386 64bit \\\\ \\hline\n",
89 | "\\hline \\multicolumn{2}{|l|}{Tue Jul 21 23:39:04 2015 JST} \\\\ \\hline\n",
90 | "\\end{tabular}\n"
91 | ],
92 | "text/plain": [
93 | "Software versions\n",
94 | "Python 2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)]\n",
95 | "IPython 3.2.0\n",
96 | "OS Darwin 14.1.0 x86_64 i386 64bit\n",
97 | "Tue Jul 21 23:39:04 2015 JST"
98 | ]
99 | },
100 | "execution_count": 2,
101 | "metadata": {},
102 | "output_type": "execute_result"
103 | }
104 | ],
105 | "source": [
106 | "%version_information"
107 | ]
108 | },
109 | {
110 | "cell_type": "code",
111 | "execution_count": 3,
112 | "metadata": {
113 | "collapsed": false
114 | },
115 | "outputs": [
116 | {
117 | "data": {
118 | "application/json": {
119 | "Software versions": [
120 | {
121 | "module": "Python",
122 | "version": "2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)]"
123 | },
124 | {
125 | "module": "IPython",
126 | "version": "3.2.0"
127 | },
128 | {
129 | "module": "OS",
130 | "version": "Darwin 14.1.0 x86_64 i386 64bit"
131 | },
132 | {
133 | "module": "scipy",
134 | "version": "0.15.1"
135 | },
136 | {
137 | "module": "numpy",
138 | "version": "1.9.2"
139 | },
140 | {
141 | "module": "Cython",
142 | "version": "0.22.1"
143 | },
144 | {
145 | "module": "matplotlib",
146 | "version": "1.4.3"
147 | },
148 | {
149 | "module": "qutip",
150 | "version": "3.1.0"
151 | },
152 | {
153 | "module": "version_information",
154 | "version": "1.0.3"
155 | }
156 | ]
157 | },
158 | "text/html": [
159 | "Software | Version |
---|
Python | 2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)] |
IPython | 3.2.0 |
OS | Darwin 14.1.0 x86_64 i386 64bit |
scipy | 0.15.1 |
numpy | 1.9.2 |
Cython | 0.22.1 |
matplotlib | 1.4.3 |
qutip | 3.1.0 |
version_information | 1.0.3 |
Tue Jul 21 23:39:06 2015 JST |
"
160 | ],
161 | "text/latex": [
162 | "\\begin{tabular}{|l|l|}\\hline\n",
163 | "{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n",
164 | "Python & 2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)] \\\\ \\hline\n",
165 | "IPython & 3.2.0 \\\\ \\hline\n",
166 | "OS & Darwin 14.1.0 x86\\_64 i386 64bit \\\\ \\hline\n",
167 | "scipy & 0.15.1 \\\\ \\hline\n",
168 | "numpy & 1.9.2 \\\\ \\hline\n",
169 | "Cython & 0.22.1 \\\\ \\hline\n",
170 | "matplotlib & 1.4.3 \\\\ \\hline\n",
171 | "qutip & 3.1.0 \\\\ \\hline\n",
172 | "version_information & 1.0.3 \\\\ \\hline\n",
173 | "\\hline \\multicolumn{2}{|l|}{Tue Jul 21 23:39:06 2015 JST} \\\\ \\hline\n",
174 | "\\end{tabular}\n"
175 | ],
176 | "text/plain": [
177 | "Software versions\n",
178 | "Python 2.7.10 64bit [GCC 4.2.1 (Apple Inc. build 5577)]\n",
179 | "IPython 3.2.0\n",
180 | "OS Darwin 14.1.0 x86_64 i386 64bit\n",
181 | "scipy 0.15.1\n",
182 | "numpy 1.9.2\n",
183 | "Cython 0.22.1\n",
184 | "matplotlib 1.4.3\n",
185 | "qutip 3.1.0\n",
186 | "version_information 1.0.3\n",
187 | "Tue Jul 21 23:39:06 2015 JST"
188 | ]
189 | },
190 | "execution_count": 3,
191 | "metadata": {},
192 | "output_type": "execute_result"
193 | }
194 | ],
195 | "source": [
196 | "%version_information scipy, numpy, Cython, matplotlib, qutip, version_information"
197 | ]
198 | }
199 | ],
200 | "metadata": {
201 | "kernelspec": {
202 | "display_name": "Python 2",
203 | "language": "python",
204 | "name": "python2"
205 | },
206 | "language_info": {
207 | "codemirror_mode": {
208 | "name": "ipython",
209 | "version": 2
210 | },
211 | "file_extension": ".py",
212 | "mimetype": "text/x-python",
213 | "name": "python",
214 | "nbconvert_exporter": "python",
215 | "pygments_lexer": "ipython2",
216 | "version": "2.7.10"
217 | }
218 | },
219 | "nbformat": 4,
220 | "nbformat_minor": 0
221 | }
222 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Version information:
3 |
4 | IPython extension command for displaying version information about selected
5 | Python modules.
6 | """
7 |
8 | DOCLINES = __doc__.split('\n')
9 |
10 | CLASSIFIERS = """\
11 | License :: OSI Approved :: BSD License
12 | Programming Language :: Python
13 | Programming Language :: Python :: 3
14 | Operating System :: MacOS
15 | Operating System :: POSIX
16 | Operating System :: Unix
17 | Operating System :: Microsoft :: Windows
18 | """
19 |
20 | import os
21 | from setuptools import setup
22 |
23 | NAME = "version_information"
24 | MAJOR = 1
25 | MINOR = 0
26 | MICRO = 4
27 | VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
28 | AUTHOR = "J. Robert Johansson"
29 | AUTHOR_EMAIL = "jrjohansson@gmail.com"
30 | LICENSE = "BSD"
31 | DESCRIPTION = DOCLINES[0]
32 | LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
33 | URL = "https://github.com/jrjohansson/version_information"
34 | PLATFORMS = ["Linux", "Mac OSX", "Unix", "Windows"]
35 |
36 | def write_version_py(filename=NAME+'/version.py'):
37 | cnt = """\
38 | # THIS FILE IS GENERATED FROM SETUP.PY
39 | version = '%(version)s'
40 | """
41 | with open(filename, 'w') as f:
42 | f.write(cnt % {'version': VERSION})
43 |
44 | write_version_py()
45 |
46 | setup(
47 | name=NAME,
48 | version=VERSION,
49 | packages=["version_information"],
50 | author=AUTHOR,
51 | author_email=AUTHOR_EMAIL,
52 | license=LICENSE,
53 | description=DESCRIPTION,
54 | long_description=LONG_DESCRIPTION,
55 | url=URL,
56 | platforms=PLATFORMS,
57 | )
58 |
--------------------------------------------------------------------------------
/version_information.py:
--------------------------------------------------------------------------------
1 | """
2 | An IPython extension that provides a magic command that displays
3 | a table with information about versions of installed modules.
4 |
5 | This makes it much easier to determine which versions of modules
6 | were installed in the source IPython interpreter's environment.
7 |
8 | Produces output in:
9 |
10 | * Plaintext (IPython [qt]console)
11 | * HTML (IPython notebook, ``nbconvert --to html``, ``--to slides``)
12 | * JSON (IPython notebook ``.ipynb`` files)
13 | * LaTeX (e.g. ``ipython nbconvert example.ipynb --to LaTeX --post PDF``)
14 |
15 | Usage
16 | ======
17 |
18 | .. sourcecode:: ipython
19 |
20 | In [1]: %load_ext version_information
21 |
22 | In [2]: %version_information
23 | Out[2]:
24 | Software versions
25 | Python 2.7.3 (default, Sep 26 2013, 20:08:41) [GCC 4.6.3]
26 | IPython 2.0.0-dev
27 | OS posix [linux2]
28 |
29 | Mon Dec 09 10:21:40 2013 CST
30 |
31 | In [3]: %version_information sphinx, jinja2
32 | Out[3]:
33 | Software versions
34 | Python 2.7.3 (default, Sep 26 2013, 20:08:41) [GCC 4.6.3]
35 | IPython 2.0.0-dev
36 | OS posix [linux2]
37 | sphinx 1.2b3
38 | jinja2 2.7.1
39 |
40 | Mon Dec 09 10:21:52 2013 CST
41 |
42 | .. note:: ``%version_information`` expects to find the module version in
43 | ``.__version__``.
44 |
45 | If ``.__version__`` is not set, it attempts to get a version
46 | string with ``pkg_resources.require('')[0].version``
47 | (the ``version`` field from ``setup.py``).
48 |
49 | """
50 | import cgi
51 | import json
52 | import sys
53 | import time
54 | import locale
55 | import IPython
56 | import platform
57 | from IPython.core.magic import magics_class, line_magic, Magics
58 |
59 | try:
60 | import pkg_resources
61 | except ImportError:
62 | pkg_resources = None
63 |
64 | timefmt = '%a %b %d %H:%M:%S %Y %Z'
65 |
66 |
67 | def _date_format_encoding():
68 | return locale.getlocale(locale.LC_TIME)[1] or locale.getpreferredencoding()
69 |
70 |
71 | @magics_class
72 | class VersionInformation(Magics):
73 |
74 | @line_magic
75 | def version_information(self, line=''):
76 | """Show information about versions of modules.
77 |
78 | Usage:
79 |
80 | %version_information [optional comma-separated list of modules]
81 |
82 | """
83 | self.packages = [
84 | ("Python", "{version} {arch} [{compiler}]".format(
85 | version=platform.python_version(),
86 | arch=platform.architecture()[0],
87 | compiler=platform.python_compiler())),
88 | ("IPython", IPython.__version__),
89 | ("OS", platform.platform().replace('-', ' '))
90 | ]
91 |
92 | modules = line.replace(' ', '').split(",")
93 |
94 | for module in modules:
95 | if len(module) > 0:
96 | try:
97 | code = ("import %s; version=str(%s.__version__)" %
98 | (module, module))
99 | ns_g = ns_l = {}
100 | exec(compile(code, "", "exec"), ns_g, ns_l)
101 | self.packages.append((module, ns_l["version"]))
102 | except Exception as e:
103 | try:
104 | if pkg_resources is None:
105 | raise
106 | version = pkg_resources.require(module)[0].version
107 | self.packages.append((module, version))
108 | except Exception as e:
109 | self.packages.append((module, str(e)))
110 |
111 | return self
112 |
113 | def _repr_json_(self):
114 | obj = {
115 | 'Software versions': [
116 | {'module': name, 'version': version} for
117 | (name, version) in self.packages]}
118 | if IPython.version_info[0] >= 3:
119 | return obj
120 | else:
121 | return json.dumps(obj)
122 |
123 | def _repr_html_(self):
124 |
125 | html = ""
126 | html += "Software | Version |
"
127 | for name, version in self.packages:
128 | _version = cgi.escape(version)
129 | html += "%s | %s |
" % (name, _version)
130 |
131 | try:
132 | html += "%s |
" % time.strftime(timefmt)
133 | except:
134 | html += "%s |
" % \
135 | time.strftime(timefmt).decode(_date_format_encoding())
136 | html += "
"
137 |
138 | return html
139 |
140 | @staticmethod
141 | def _latex_escape(str_):
142 | CHARS = {
143 | '&': r'\&',
144 | '%': r'\%',
145 | '$': r'\$',
146 | '#': r'\#',
147 | '_': r'\_',
148 | '{': r'\letteropenbrace{}',
149 | '}': r'\letterclosebrace{}',
150 | '~': r'\lettertilde{}',
151 | '^': r'\letterhat{}',
152 | '\\': r'\letterbackslash{}',
153 | '>': r'\textgreater',
154 | '<': r'\textless',
155 | }
156 | return u"".join([CHARS.get(c, c) for c in str_])
157 |
158 | def _repr_latex_(self):
159 |
160 | latex = r"\begin{tabular}{|l|l|}\hline" + "\n"
161 | latex += r"{\bf Software} & {\bf Version} \\ \hline\hline" + "\n"
162 | for name, version in self.packages:
163 | _version = self._latex_escape(version)
164 | latex += r"%s & %s \\ \hline" % (name, _version) + "\n"
165 |
166 | try:
167 | latex += r"\hline \multicolumn{2}{|l|}{%s} \\ \hline" % \
168 | time.strftime(timefmt) + "\n"
169 | except:
170 | latex += r"\hline \multicolumn{2}{|l|}{%s} \\ \hline" % \
171 | time.strftime(timefmt).decode(_date_format_encoding()) + "\n"
172 |
173 | latex += r"\end{tabular}" + "\n"
174 |
175 | return latex
176 |
177 | def _repr_pretty_(self, pp, cycle):
178 |
179 | text = "Software versions\n"
180 | for name, version in self.packages:
181 | text += "%s %s\n" % (name, version)
182 |
183 | try:
184 | text += "%s" % time.strftime(timefmt)
185 | except:
186 | text += "%s" % \
187 | time.strftime(timefmt).decode(_date_format_encoding())
188 |
189 | pp.text(text)
190 |
191 |
192 | def load_ipython_extension(ipython):
193 | ipython.register_magics(VersionInformation)
194 |
--------------------------------------------------------------------------------
/version_information/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | from version_information.version import version as __version__
3 | from version_information.version_information import *
4 |
--------------------------------------------------------------------------------
/version_information/version_information.py:
--------------------------------------------------------------------------------
1 | """
2 | An IPython extension that provides a magic command that displays
3 | a table with information about versions of installed modules.
4 |
5 | This makes it much easier to determine which versions of modules
6 | were installed in the source IPython interpreter's environment.
7 |
8 | Produces output in:
9 |
10 | * Plaintext (IPython [qt]console)
11 | * HTML (IPython notebook, ``nbconvert --to html``, ``--to slides``)
12 | * JSON (IPython notebook ``.ipynb`` files)
13 | * LaTeX (e.g. ``ipython nbconvert example.ipynb --to LaTeX --post PDF``)
14 |
15 | Usage
16 | ======
17 |
18 | .. sourcecode:: ipython
19 |
20 | In [1]: %load_ext version_information
21 |
22 | In [2]: %version_information
23 | Out[2]:
24 | Software versions
25 | Python 2.7.3 (default, Sep 26 2013, 20:08:41) [GCC 4.6.3]
26 | IPython 2.0.0-dev
27 | OS posix [linux2]
28 |
29 | Mon Dec 09 10:21:40 2013 CST
30 |
31 | In [3]: %version_information sphinx, jinja2
32 | Out[3]:
33 | Software versions
34 | Python 2.7.3 (default, Sep 26 2013, 20:08:41) [GCC 4.6.3]
35 | IPython 2.0.0-dev
36 | OS posix [linux2]
37 | sphinx 1.2b3
38 | jinja2 2.7.1
39 |
40 | Mon Dec 09 10:21:52 2013 CST
41 |
42 | .. note:: ``%version_information`` expects to find the module version in
43 | ``.__version__``.
44 |
45 | If ``.__version__`` is not set, it attempts to get a version
46 | string with ``pkg_resources.require('')[0].version``
47 | (the ``version`` field from ``setup.py``).
48 |
49 | """
50 | import html
51 | import json
52 | import subprocess
53 | import sys
54 | import time
55 | import locale
56 | import IPython
57 | import platform
58 | from IPython.core.magic import magics_class, line_magic, Magics
59 |
60 | try:
61 | import pkg_resources
62 | except ImportError:
63 | pkg_resources = None
64 |
65 | timefmt = '%a %b %d %H:%M:%S %Y %Z'
66 |
67 |
68 | def _date_format_encoding():
69 | return locale.getlocale(locale.LC_TIME)[1] or locale.getpreferredencoding()
70 |
71 |
72 | @magics_class
73 | class VersionInformation(Magics):
74 |
75 | def get_non_python_package_version(self, package):
76 | try:
77 | result = subprocess.getoutput(package + " --version")
78 | except Exception as e:
79 | result = "Package not found " + str(e)
80 | self.packages.append((package, result))
81 |
82 |
83 | def get_module_version(self, module):
84 | try:
85 | code = ("import %s; version=str(%s.__version__)" %
86 | (module, module))
87 | ns_g = ns_l = {}
88 | exec(compile(code, "", "exec"), ns_g, ns_l)
89 | self.packages.append((module, ns_l["version"]))
90 | except Exception as e:
91 | try:
92 | if pkg_resources is None:
93 | raise
94 | version = pkg_resources.require(module)[0].version
95 | self.packages.append((module, version))
96 | except Exception as e:
97 | self.packages.append((module, str(e)))
98 |
99 |
100 |
101 | @line_magic
102 | def version_information(self, line=''):
103 | """Show information about versions of modules.
104 |
105 | Usage:
106 |
107 | %version_information [optional comma-separated list of modules]
108 |
109 | """
110 | self.packages = [
111 | ("Python", "{version} {arch} [{compiler}]".format(
112 | version=platform.python_version(),
113 | arch=platform.architecture()[0],
114 | compiler=platform.python_compiler())),
115 | ("IPython", IPython.__version__),
116 | ("OS", platform.platform().replace('-', ' '))
117 | ]
118 |
119 | modules = line.replace(' ', '').split(",")
120 |
121 | for module in modules:
122 | if len(module) > 0:
123 | if(module.startswith('!')):
124 | self.get_non_python_package_version(module[1:])
125 | else:
126 | self.get_module_version(module)
127 |
128 | return self
129 |
130 | def _repr_json_(self):
131 | obj = {
132 | 'Software versions': [
133 | {'module': name, 'version': version} for
134 | (name, version) in self.packages]}
135 | if IPython.version_info[0] >= 3:
136 | return obj
137 | else:
138 | return json.dumps(obj)
139 |
140 | @staticmethod
141 | def _htmltable_escape(str_):
142 | CHARS = {
143 | '&': r'\&',
144 | '%': r'\%',
145 | '$': r'\$',
146 | '#': r'\#',
147 | '_': r'\_',
148 | '{': r'\letteropenbrace{}',
149 | '}': r'\letterclosebrace{}',
150 | '~': r'\lettertilde{}',
151 | '^': r'\letterhat{}',
152 | '\\': r'\letterbackslash{}',
153 | '>': r'\textgreater',
154 | '<': r'\textless',
155 | }
156 | return u"".join([CHARS.get(c, c) for c in str_])
157 |
158 | def _repr_html_(self):
159 |
160 | html_table = ""
161 | html_table += "Software | Version |
"
162 | for name, version in self.packages:
163 | _version = self._htmltable_escape(version)
164 | html_table += "%s | %s |
" % (name, _version)
165 |
166 | try:
167 | html_table += "%s |
" % time.strftime(timefmt)
168 | except:
169 | html_table += "%s |
" % \
170 | time.strftime(timefmt).decode(_date_format_encoding())
171 | html_table += "
"
172 |
173 | return html_table
174 |
175 | @staticmethod
176 | def _latex_escape(str_):
177 | CHARS = {
178 | '&': r'\&',
179 | '%': r'\%',
180 | '$': r'\$',
181 | '#': r'\#',
182 | '_': r'\_',
183 | '{': r'\letteropenbrace{}',
184 | '}': r'\letterclosebrace{}',
185 | '~': r'\lettertilde{}',
186 | '^': r'\letterhat{}',
187 | '\\': r'\letterbackslash{}',
188 | '>': r'\textgreater',
189 | '<': r'\textless',
190 | }
191 | return u"".join([CHARS.get(c, c) for c in str_])
192 |
193 | def _repr_latex_(self):
194 |
195 | latex = r"\begin{tabular}{|l|l|}\hline" + "\n"
196 | latex += r"{\bf Software} & {\bf Version} \\ \hline\hline" + "\n"
197 | for name, version in self.packages:
198 | _version = self._latex_escape(version)
199 | latex += r"%s & %s \\ \hline" % (name, _version) + "\n"
200 |
201 | try:
202 | latex += r"\hline \multicolumn{2}{|l|}{%s} \\ \hline" % \
203 | time.strftime(timefmt) + "\n"
204 | except:
205 | latex += r"\hline \multicolumn{2}{|l|}{%s} \\ \hline" % \
206 | time.strftime(timefmt).decode(_date_format_encoding()) + "\n"
207 |
208 | latex += r"\end{tabular}" + "\n"
209 |
210 | return latex
211 |
212 | def _repr_pretty_(self, pp, cycle):
213 |
214 | text = "Software versions\n"
215 | for name, version in self.packages:
216 | text += "%s %s\n" % (name, version)
217 |
218 | try:
219 | text += "%s" % time.strftime(timefmt)
220 | except:
221 | text += "%s" % \
222 | time.strftime(timefmt).decode(_date_format_encoding())
223 |
224 | pp.text(text)
225 |
226 |
227 | def load_ipython_extension(ipython):
228 | ipython.register_magics(VersionInformation)
229 |
--------------------------------------------------------------------------------