Skip to content

Commit

Permalink
Merged in cbillington/labscript_utils/allow-double-imports (pull requ…
Browse files Browse the repository at this point in the history
…est labscript-suite#46)

Issue labscript-suite#19, --allow-double-imports command line flag

Approved-by: Philip Starkey <[email protected]>
Approved-by: Jan Werkmann <[email protected]>
  • Loading branch information
chrisjbillington committed Apr 30, 2018
2 parents a5c2833 + 520a029 commit 3c2f643
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions double_import_denier.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ def _raise_error(self, path, name, tb, other_name, other_tb):
_denier = None

def enable():
if '--allow-double-imports' in sys.argv:
# Calls to enable/disable the double import denier are ignored if this
# command line argument is present.
return
global _denier
if _denier is None:
_denier = DoubleImportDenier()
Expand All @@ -172,6 +176,10 @@ def enable():
_denier.enabled = True

def disable():
if '--allow-double-imports' in sys.argv:
# Calls to enable/disable the double import denier are ignored if this
# command line argument is present.
return
if not _denier.enabled:
raise RuntimeError('not enabled')
sys.meta_path.remove(_denier)
Expand Down

0 comments on commit 3c2f643

Please sign in to comment.