|
1 | | -import re |
2 | | -import shutil |
| 1 | +from collections.abc import Mapping, Sequence |
3 | 2 | from fnmatch import fnmatch |
4 | 3 | from itertools import chain |
5 | 4 | from pathlib import Path, PurePosixPath |
6 | | -from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Union |
| 5 | +import re |
| 6 | +import shutil |
| 7 | +from typing import Any, Dict, List, Optional, Tuple, Union |
7 | 8 |
|
8 | 9 | import yaml |
9 | 10 |
|
@@ -61,11 +62,11 @@ def create_site_from_toc( |
61 | 62 | for docname in chain(site_map, additional_files): |
62 | 63 | # create document |
63 | 64 | filename = docname |
64 | | - if not any(docname.endswith(ext) for ext in {".rst", ".md"}): |
| 65 | + if not any(docname.endswith(ext) for ext in (".rst", ".md")): |
65 | 66 | filename += default_ext |
66 | 67 | docpath = root_path.joinpath(PurePosixPath(filename)) |
67 | 68 | if docpath.exists() and not overwrite: |
68 | | - raise IOError(f"Path already exists: {docpath}") |
| 69 | + raise OSError(f"Path already exists: {docpath}") |
69 | 70 | docpath.parent.mkdir(parents=True, exist_ok=True) |
70 | 71 |
|
71 | 72 | content = [] |
@@ -116,7 +117,7 @@ def create_site_map_from_path( |
116 | 117 | root_path, suffixes, default_index, ignore_matches |
117 | 118 | ) |
118 | 119 | if not root_index: |
119 | | - raise IOError(f"path does not contain a root file: {root_path}") |
| 120 | + raise OSError(f"path does not contain a root file: {root_path}") |
120 | 121 |
|
121 | 122 | # create root item and child folders |
122 | 123 | root_item, indexed_folders = _doc_item_from_path( |
@@ -232,7 +233,7 @@ def _assess_folder( |
232 | 233 | :returns: (index file name, other file names, folders) |
233 | 234 | """ |
234 | 235 | if not folder.is_dir(): |
235 | | - raise IOError(f"path must be a directory: {folder}") |
| 236 | + raise OSError(f"path must be a directory: {folder}") |
236 | 237 |
|
237 | 238 | def _strip_suffix(name: str) -> str: |
238 | 239 | for suffix in suffixes: |
|
0 commit comments