|
1 | 1 | import os
|
| 2 | +import shutil |
2 | 3 | import sys
|
3 | 4 | import types
|
4 |
| -import shutil |
5 |
| -import sh # type: ignore |
6 |
| -from tap import Tap |
7 |
| -from time import time_ns |
8 | 5 | from contextlib import contextmanager
|
| 6 | +from time import time_ns |
9 | 7 | from typing import Generator, List, Dict, Any, Union, Literal
|
| 8 | + |
| 9 | +import sh # type: ignore |
10 | 10 | from pypage import pypage # type: ignore
|
| 11 | +from tap import Tap |
| 12 | + |
11 | 13 | from .fs import (
|
12 | 14 | FileNode,
|
13 | 15 | DirNode,
|
@@ -42,22 +44,23 @@ def __init__(self, args: Args, fs: Fs) -> None:
|
42 | 44 | self.nameRegistry: NameRegistry = fs.nameRegistry
|
43 | 45 | self.fixSysPath()
|
44 | 46 |
|
45 |
| - self.linkDepth: Union[Literal[2], Literal[4]] = 2 |
| 47 | + self.indentSpaces: Union[Literal[2], Literal[4]] = 2 |
46 | 48 |
|
47 | 49 | def linkObj(self, srcFile: PyPageNode, dstFile: FileNode) -> str:
|
48 | 50 | assert isinstance(dstFile, FileNode)
|
49 | 51 | dstName = dstFile.getLinkName()
|
50 |
| - print(" " * self.linkDepth + f"{Fore.grey_42}Linking to:{Style.reset}", dstName) |
| 52 | + indentSpaces = " " * self.indentSpaces |
| 53 | + print(indentSpaces + f"{Fore.grey_42}Linking to:{Style.reset}", dstName) |
51 | 54 | dstFile.makePublic() # FixMe: Circular links can make pages public.
|
52 | 55 |
|
53 | 56 | dstFileName = dstFile.fileName
|
54 | 57 | if isinstance(dstFile, NonMd):
|
55 | 58 | dstFileName = dstFile.rectifiedFileName
|
56 | 59 | elif isinstance(dstFile, Md):
|
57 | 60 | dstFileName = (
|
58 |
| - dstFile.realName |
59 |
| - # Add a "/" trailing slash if arg requests it |
60 |
| - + ("/" if self.args.trailing_slash else "") |
| 61 | + dstFile.realName |
| 62 | + # Add a "/" trailing slash if arg requests it |
| 63 | + + ("/" if self.args.trailing_slash else "") |
61 | 64 | )
|
62 | 65 |
|
63 | 66 | srcPath = self.splitPath(srcFile.fullPath)[:-1]
|
@@ -132,10 +135,10 @@ def linkObj(dstFile: FileNode) -> str:
|
132 | 135 | f" {Fore.purple_3}Applying template...{Style.reset}"
|
133 | 136 | ) # TODO (see ideas.md)
|
134 | 137 | templateHtml = Content.getTemplateHtml(env)
|
135 |
| - self.linkDepth = 4 |
| 138 | + self.indentSpaces = 4 |
136 | 139 | # Re-process against `templateHtml` with PyPage:
|
137 | 140 | pyPageOutput = pypage(templateHtml, env | {"body": pyPageOutput})
|
138 |
| - self.linkDepth = 2 |
| 141 | + self.indentSpaces = 2 |
139 | 142 |
|
140 | 143 | fileNode.setPyPageOutput(pyPageOutput)
|
141 | 144 |
|
@@ -243,7 +246,7 @@ def run(args: Args) -> None:
|
243 | 246 |
|
244 | 247 | generate(args, content)
|
245 | 248 |
|
246 |
| - elapsedMilliseconds = (time_ns() - startTimeNs) / 10**6 |
| 249 | + elapsedMilliseconds = (time_ns() - startTimeNs) / 10 ** 6 |
247 | 250 | # pylint: disable=consider-using-f-string
|
248 | 251 | print("\nTime elapsed: %.2f ms" % elapsedMilliseconds)
|
249 | 252 |
|
|
0 commit comments