summaryrefslogtreecommitdiff
path: root/asciidoc/asciidoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'asciidoc/asciidoc.py')
-rw-r--r--asciidoc/asciidoc.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/asciidoc/asciidoc.py b/asciidoc/asciidoc.py
index bcafdcd..da5769f 100644
--- a/asciidoc/asciidoc.py
+++ b/asciidoc/asciidoc.py
@@ -187,7 +187,7 @@ class Message:
if msg == self.prev_msg: # Suppress repeated messages.
return
self.messages.append(msg)
- if __name__ == '__main__':
+ if APPLICATION_CALLER == '__main__':
sys.stderr.write('%s: %s%s' % (self.PROG, msg, os.linesep))
self.prev_msg = msg
@@ -6083,6 +6083,7 @@ class Plugin:
# ---------
USER_DIR = None # ~/.asciidoc
HELP_FILE = 'help.conf' # Default (English) help file.
+APPLICATION_CALLER = __name__
# Globals
# -------
@@ -6105,6 +6106,11 @@ trace = Trace() # Implements trace attribute processing.
messages = message.messages
+def set_caller(name):
+ global APPLICATION_CALLER
+ APPLICATION_CALLER = name
+
+
def reset_asciidoc():
global document, config, reader, writer, message
global paragraphs, lists, blocks, tables_OLD, tables
@@ -6284,7 +6290,7 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options):
if isinstance(e, EAsciiDoc):
message.stderr('%s%s' % (msg, str(e)))
else:
- if __name__ == '__main__':
+ if APPLICATION_CALLER == '__main__':
message.stderr(msg + 'unexpected error:')
message.stderr('-' * 60)
traceback.print_exc(file=sys.stderr)