- from getopt import getopt, GetoptError
-
- try:
- options, arguments = getopt(sys.argv[1:], "0nsw:",
- ["null", "no-newline", "space", "width="])
- except GetoptError:
- usage(1)
-
- print0 = False
- newline = True
- space = ''
- width = None
-
- for option, value in options:
- if option in ("-h", "--help"):
- usage()
- elif option in ("-0", "--null"):
- print0 = True
- elif option in ("-n", "--no-newline"):
- newline = False
- elif option in ("-s", "--space"):
- space = u' '
- elif option in ("-w", "--width"):
- width = int(value)
- else:
- usage(2)
-
- if arguments:
- if width is not None:
- usage(3)
- elif len(arguments) > 1:
- usage(4)
- else:
- width = int(arguments[0])
-
- return print0, newline, space, width
+ from getopt import getopt, GetoptError
+
+ try:
+ options, arguments = getopt(
+ sys.argv[1:], "0nsw:",
+ ["null", "no-newline", "space", "width="])
+ except GetoptError:
+ usage(1)
+
+ print0 = False
+ newline = True
+ space = ''
+ width = None
+
+ for option, value in options:
+ if option in ("-h", "--help"):
+ usage()
+ elif option in ("-0", "--null"):
+ print0 = True
+ elif option in ("-n", "--no-newline"):
+ newline = False
+ elif option in ("-s", "--space"):
+ space = u' '
+ elif option in ("-w", "--width"):
+ width = int(value)
+ else:
+ usage(2)
+
+ if arguments:
+ if width is not None:
+ usage(3)
+ elif len(arguments) > 1:
+ usage(4)
+ else:
+ width = int(arguments[0])
+
+ return print0, newline, space, width