Skip to content

Commit

Permalink
fix bad formatting of examples
Browse files Browse the repository at this point in the history
- uses inspect.cleandoc() to properly strip away whitespace
- reformat a few to avoid lines longer than 80 cols
  • Loading branch information
kosack committed Aug 3, 2023
1 parent e0bda66 commit cecb9d7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
17 changes: 10 additions & 7 deletions ctapipe/tools/fileinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Display information about ctapipe output files (DL1 or DL2)
"""

from inspect import cleandoc
from pathlib import Path

import tables
Expand Down Expand Up @@ -31,16 +32,18 @@ class FileInfoTool(Tool):

name = "ctapipe-fileinfo"
description = __doc__
examples = """To get YAML output of all metadata in HDF5 files in the
current directory
examples = cleandoc(
"""To get YAML output of all metadata in HDF5 files in the
current directory
> ctapipe fileinfo *.h5
> ctapipe fileinfo *.h5
Generate an index table of all metadata: Note that you can
use any table format allowed by astropy.table. However, formats
with metadata like fits or ecsv are recommended.
Generate an index table of all metadata: Note that you can
use any table format allowed by astropy.table. However, formats
with metadata like fits or ecsv are recommended.
> ctapipe fileinfo --output-table index.fits *.h5"""
> ctapipe fileinfo --output-table index.fits *.h5"""
)

input_files = traits.List(
traits.Path(exists=True, directory_ok=False),
Expand Down
22 changes: 14 additions & 8 deletions ctapipe/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import sys
from argparse import ArgumentParser
from inspect import cleandoc
from pathlib import Path

from tqdm.auto import tqdm
Expand All @@ -25,18 +26,23 @@ class MergeTool(Tool):
name = "ctapipe-merge"
description = "Merge multiple ctapipe HDF5 files into one"

examples = """
To merge several files in the current directory:
examples = cleandoc(
"""
To merge several files in the current directory:
> ctapipe-merge file1.h5 file2.h5 file3.h5 --output=/path/output_file.h5 --progress
> ctapipe-merge file1.h5 file2.h5 file3.h5 \\
--output=/path/output_file.h5 --progress
For merging files from a specific directory with a specific pattern, use:
For merging files from a specific directory with a specific pattern,
use:
> ctapipe-merge --input-dir=/input/dir/ --output=/path/output_file.h5 --progress
--pattern='*.dl1.h5'
> ctapipe-merge --input-dir=/input/dir/ \\
--output=/path/output_file.h5 --progress \\
--pattern='*.dl1.h5'
If no pattern is given, all .h5 files in the given directory will be taken as input.
"""
If no pattern is given, all .h5 files in the given directory will be
taken as input. """
)
input_dir = traits.Path(
default_value=None,
help="Input directory",
Expand Down
22 changes: 14 additions & 8 deletions ctapipe/tools/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
# pylint: disable=W0201
import sys
from inspect import cleandoc

from tqdm.auto import tqdm

Expand Down Expand Up @@ -54,16 +55,21 @@ class ProcessorTool(Tool):
description = (
__doc__ + f" This currently uses data model version {DATA_MODEL_VERSION}"
)
examples = """
To process data with all default values:
> ctapipe-process --input events.simtel.gz --output events.dl1.h5 --progress
examples = cleandoc(
"""
To process data with all default values:
Or use an external configuration file, where you can specify all options:
> ctapipe-process --config stage1_config.json --progress
> ctapipe-process --input events.simtel.gz --output events.dl1.h5 --progress
The config file should be in JSON or python format (see traitlets docs). For an
example, see ctapipe/examples/stage1_config.json in the main code repo.
"""
Or use an external configuration file, where you can specify all
options:
> ctapipe-process --config stage1_config.json --progress
The config file should be in JSON or python format (see traitlets docs).
For an example, see ctapipe/examples/stage1_config.json in the main code
repo. """
)

progress_bar = Bool(
help="show progress bar during processing", default_value=False
Expand Down
17 changes: 11 additions & 6 deletions ctapipe/tools/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
except ImportError:
from importlib_resources import files

from inspect import cleandoc
from pathlib import Path

from ..core import Provenance, Tool, traits
Expand Down Expand Up @@ -103,15 +104,19 @@ class QuickStartTool(Tool):

name = "ctapipe-quickstart"
description = __doc__
examples = """
To be prompted for contact info:
examples = cleandoc(
"""
To be prompted for contact info:
ctapipe-quickstart --workdir MyProduction
> ctapipe-quickstart --workdir MyProduction
Or specify it all in the command-line:
Or specify it all in the command-line:
ctapipe-quickstart --name "my name" --email "me@thing.com" --org "My Organization" --workdir Work
"""
> ctapipe-quickstart --name "my name" \\
--email "me@thing.com" --org "My Organization" \\
--workdir Work
"""
)

workdir = traits.Path(
default_value="./Work",
Expand Down

0 comments on commit cecb9d7

Please sign in to comment.