Skip to content

Commit

Permalink
Merge pull request #80 from Hugovdberg/fallback_from_ipython_shell
Browse files Browse the repository at this point in the history
Improve usage outside IPython
  • Loading branch information
rasbt authored Jan 4, 2022
2 parents 414f14a + 7774adc commit 1cb8660
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions watermark/watermark.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def watermark(author=None, email=None, github_username=None,
updated=False, custom_time=None, python=False,
packages=None, hostname=False, machine=False,
githash=False, gitrepo=False, gitbranch=False,
watermark=False, iversions=False, watermark_self=None):
watermark=False, iversions=False, watermark_self=None,
globals_=None):

'''Function to print date/time stamps and various system information.
Expand Down Expand Up @@ -165,8 +166,16 @@ def watermark(author=None, email=None, github_username=None,
if args['gitbranch']:
output.append(_get_git_branch(bool(args['machine'])))
if args['iversions']:
output.append(_get_all_import_versions(
watermark_self.shell.user_ns))
if watermark_self:
ns = watermark_self.shell.user_ns
elif globals_:
ns = globals_
else:
raise RuntimeError(
"Either `watermark_self` or `globals_` must be provided "
"to show imported package versions."
)
output.append(_get_all_import_versions(ns))
if args['watermark']:
output.append({"Watermark": __version__})

Expand Down

0 comments on commit 1cb8660

Please # to comment.