aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/commandline.py31
1 files changed, 2 insertions, 29 deletions
diff --git a/markdown/commandline.py b/markdown/commandline.py
index 78dfc5a..7acc06d 100644
--- a/markdown/commandline.py
+++ b/markdown/commandline.py
@@ -2,47 +2,20 @@
COMMAND-LINE SPECIFIC STUFF
=============================================================================
-The rest of the code is specifically for handling the case where Python
-Markdown is called from the command line.
"""
import markdown
import sys
+import optparse
import logging
from logging import DEBUG, INFO, WARN, ERROR, CRITICAL
-EXECUTABLE_NAME_FOR_USAGE = "python markdown"
-""" The name used in the usage statement displayed for python versions < 2.3.
-(With python 2.3 and higher the usage statement is generated by optparse
-and uses the actual name of the executable called.) """
-
-OPTPARSE_WARNING = """
-Python 2.3 or higher required for advanced command line options.
-For lower versions of Python use:
-
- %s INPUT_FILE > OUTPUT_FILE
-
-""" % EXECUTABLE_NAME_FOR_USAGE
-
def parse_options():
"""
Define and parse `optparse` options for command-line usage.
"""
- try:
- optparse = __import__("optparse")
- except:
- if len(sys.argv) == 2:
- return {'input': sys.argv[1],
- 'output': None,
- 'safe': False,
- 'extensions': [],
- 'encoding': None }, CRITICAL
- else:
- print OPTPARSE_WARNING
- return None, None
-
- parser = optparse.OptionParser(usage="%prog INPUTFILE [options]",
+ parser = optparse.OptionParser(usage="%prog [options] INPUTFILE",
version="%%prog %s" % markdown.version)
parser.add_option("-f", "--file", dest="filename", default=sys.stdout,
help="write output to OUTPUT_FILE",