• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PyMassSpec / notebook2script / 14915518696

08 May 2025 08:28PM UTC coverage: 90.698% (-0.3%) from 90.96%
14915518696

push

github

web-flow
Updated files with 'repo_helper'. (#53)

Co-authored-by: repo-helper[bot] <74742576+repo-helper[bot]@users.noreply.github.com>

156 of 172 relevant lines covered (90.7%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.12
/notebook2script/__main__.py
1
#!/usr/bin/env python3
2
#
3
#  __main__.py
4
"""
5
CLI entry point.
6
"""
7
#
8
#  Copyright © 2020 Dominic Davis-Foster <dominic@davis-foster.co.uk>
9
#
10
#  This program is free software; you can redistribute it and/or modify
11
#  it under the terms of the GNU General Public License version 2
12
#  as published by the Free Software Foundation.
13
#
14
#  This program is distributed in the hope that it will be useful,
15
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
#  GNU General Public License for more details.
18
#
19
#  You should have received a copy of the GNU General Public License
20
#  along with this program; if not, write to the Free Software
21
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
#  MA 02110-1301, USA.
23
#
24

25
# stdlib
26
import sys
1✔
27
from typing import Tuple
1✔
28

29
# 3rd party
30
import click
1✔
31
from consolekit import click_command
1✔
32

33
__all__ = ["main"]
1✔
34

35

36
@click.argument("notebooks", metavar="NOTEBOOK", type=click.STRING, nargs=-1)
1✔
37
@click.option("-o", "--outdir", type=click.STRING, default='.', help="Directory to save the output scripts in.")
1✔
38
@click.option("-f", "--overwrite", is_flag=True, default=False, help="Overwrite existing files.")
1✔
39
@click_command()
1✔
40
def main(notebooks: Tuple[str, ...], outdir: str = '.', overwrite: bool = False) -> None:
1✔
41
        """
42
        Convert Jupyter Notebooks to Python scripts.
43
        """
44

45
        # stdlib
46
        import glob
1✔
47
        from itertools import chain
1✔
48

49
        # this package
50
        from notebook2script import process_multiple_notebooks
1✔
51

52
        notebooks = tuple(chain.from_iterable(glob.glob(notebook) for notebook in notebooks))
1✔
53

54
        # print(notebooks)
55
        # print(notebooks[0])
56

57
        if not notebooks:
1✔
58
                sys.exit(0)
×
59
        else:
60
                sys.exit(process_multiple_notebooks(notebooks, outdir, overwrite=overwrite))
1✔
61

62

63
if __name__ == "__main__":
64
        try:
65
                sys.exit(main())
66
        except KeyboardInterrupt:
67
                sys.exit(1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc