# Path: pyfits/util.py
# def fill(text, width, *args, **kwargs):
#     """
#     Like :func:`textwrap.wrap` but preserves existing paragraphs which
#     :func:`textwrap.wrap` does not otherwise handle well.  Also handles section
#     headers.
#     """
# 
#     paragraphs = text.split('\n\n')
# 
#     def maybe_fill(t):
#         if all(len(l) < width for l in t.splitlines()):
#             return t
#         else:
#             return textwrap.fill(t, width, *args, **kwargs)
# 
#     return '\n\n'.join(maybe_fill(p) for p in paragraphs)


import glob
import logging
import optparse
import os
import sys
import textwrap
import pyfits.diff
from pyfits.util import fill
""".strip()


EPILOG = """
If the two files are identical within the specified conditions, it will report
"No difference is found." If the value(s) of -c and -k takes the form
'@filename', list is in the text file 'filename', and each line in that text
file contains one keyword.

Example
-------

    fitsdiff -k filename,filtnam1 -n 5 -d 1.e-6 test1.fits test2

This command will compare files test1.fits and test2.fits, report maximum of 5
different pixels values per extension, only report data values larger than
1.e-6 relative to each other, and will neglect the different values of keywords
FILENAME and FILTNAM1 (or their very existence).

fitsdiff command-line arguments can also be set using the environment variable
FITSDIFF_SETTINGS.  If the FITSDIFF_SETTINGS environment variable is present,
each argument present will override the corresponding argument on the
command-line unless the --exact option is specified.  The FITSDIFF_SETTINGS
environment variable exists to make it easier to change the
behavior of fitsdiff on a global level, such as in a set of regression tests.
""".strip()


class HelpFormatter(optparse.TitledHelpFormatter):
    def format_epilog(self, epilog):

# Path: pyfits/util.py
# def fill(text, width, *args, **kwargs):
#     """
#     Like :func:`textwrap.wrap` but preserves existing paragraphs which
#     :func:`textwrap.wrap` does not otherwise handle well.  Also handles section
#     headers.
#     """
# 
#     paragraphs = text.split('\n\n')
# 
#     def maybe_fill(t):
#         if all(len(l) < width for l in t.splitlines()):
#             return t
#         else:
#             return textwrap.fill(t, width, *args, **kwargs)
# 
#     return '\n\n'.join(maybe_fill(p) for p in paragraphs)


# Path: pyfits/scripts/fitsdiff.py
import glob
import logging
import optparse
import os
import sys
import textwrap
import pyfits.diff
from pyfits.util import fill

""".strip()


EPILOG = """
If the two files are identical within the specified conditions, it will report
"No difference is found." If the value(s) of -c and -k takes the form
'@filename', list is in the text file 'filename', and each line in that text
file contains one keyword.

Example
-------

    fitsdiff -k filename,filtnam1 -n 5 -d 1.e-6 test1.fits test2

This command will compare files test1.fits and test2.fits, report maximum of 5
different pixels values per extension, only report data values larger than
1.e-6 relative to each other, and will neglect the different values of keywords
FILENAME and FILTNAM1 (or their very existence).

fitsdiff command-line arguments can also be set using the environment variable
FITSDIFF_SETTINGS.  If the FITSDIFF_SETTINGS environment variable is present,
each argument present will override the corresponding argument on the
command-line unless the --exact option is specified.  The FITSDIFF_SETTINGS
environment variable exists to make it easier to change the
behavior of fitsdiff on a global level, such as in a set of regression tests.
""".strip()


class HelpFormatter(optparse.TitledHelpFormatter):
    def format_epilog(self, epilog):

        return '\n%s\n' % fill(epilog, self.width)