PK:KGɬiversions/__init__.py"""A cell magic command for IPython/Jupyter to display name and version of the imported modules""" __version__ = "0.0.10" __all__ = ['iversions'] from .iversions import IVersions def load_ipython_extension(ipython): ipython.register_magics(IVersions) PKKMWiversions/iversions.py#!/usr/bin/env python # -*- coding: utf-8 -*- # Aziz Alto # Aug. 26, 2017 """ iversions is a simple cell magic command for IPython/Jupyter, to display name and version of all imported modules (non built-in) in the current environment. Usage: after loading it `%load_ext iversions` and importing some modules, just type: %iversions Note: Currently, it does not work with non-module imports `from X import Y` :( """ from sys import version_info as ver_info import types from datetime import datetime PYTHON_VER = '.'.join(map(str, [ver_info.major, ver_info.minor, ver_info.micro])) def now(): return datetime.strftime(datetime.now(), '%a %b %d, %Y %H:%M:%S %Z') def print_versions(symbol_table=locals()): """:param symbol_table: globals() or locals() """ for val in symbol_table.values(): if isinstance(val, types.ModuleType): try: print('{:>10} {}'.format(val.__name__, val.__version__)) except AttributeError: # built-ins will be excepted continue print('\nPython {} [{}]'.format(PYTHON_VER, now().strip())) # notebook cellmagic interface from IPython.core.magic import Magics from IPython.core.magic import magics_class from IPython.core.magic import line_magic, register_line_magic, cell_magic @magics_class class IVersions(Magics): @line_magic def iversions(self, line): """ Display name and version of the imported modules in current environment. Usage: import some modules, just type %iversions enjoy :-) """ print_versions(self.shell.user_ns) PKhK(ld44"iversions-0.0.10.dist-info/LICENSEThe MIT License (MIT) Copyright (c) 2017 Aziz Alto Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!H١Wd iversions-0.0.10.dist-info/WHEEL HM K-*ϳR03rOK-J,/RH,Q0343 /, (-JLR()*M ILR(4KM̫#DPK!Hr#iversions-0.0.10.dist-info/METADATATێ0}WH Q7iVQE.-u'u/ݯgAx`dfq/g['!2f nڜ#bB&ddvVAJ`1 (ѧ_ks ^C!Cу.9iPsGi{U(eqy_ KL{q?(V\9O0*]%5RPWUk9'JqBd:1VߠF]ʄT!i;!~;&AԾ'ݲ@U+M )瑀y<(EUY̭ `A:rx/ؑtZb1~0vPA-02t_6,cSu׶mS=ڝʺ푠Q|ڤ[am4hӝ $4#؝Ѥn2z C'0HsHieYNH<1#,8TU5w9y/AH`}.OF+wjc7z͔sty#-C?ϓ,{"ɛ i0(9:x|XX+}쨿㍆tzvJqU ;(4(VHN+< PK!H8*(!iversions-0.0.10.dist-info/RECORD}лv0g!28 79 5"Y8"(ҧom'[G1il;2]