ThreeDimensionModeller 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ # Package public surface — requirement-python-packaging / requirement-python-coding-style
2
+ # Do not re-export undefined symbols from .cli.
3
+
4
+ __version__ = "1.0.0"
5
+
6
+ from .cli import main
7
+
8
+ __all__ = ["__version__", "main"]
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())
@@ -0,0 +1,200 @@
1
+ # =============================================================================
2
+ # About page composer.
3
+ # requirement-python-oop — class AboutPage.
4
+ # requirement-python-about — identity lines, host check, and the star box.
5
+ # requirement-domain-threedimensionmodeller — the domain sentence on the identity block.
6
+ # =============================================================================
7
+ from __future__ import print_function, unicode_literals
8
+
9
+ import os
10
+
11
+ from .check_system import CheckSystem
12
+
13
+
14
+ class AboutPage:
15
+ """Identity lines, install sentence, and the star box. One class, one module.
16
+
17
+ The host check is CheckSystem. Cli writes CheckSystem(...) and passes it here.
18
+ """
19
+
20
+ def __init__(
21
+ self,
22
+ check,
23
+ app_name,
24
+ version,
25
+ author,
26
+ updated,
27
+ homepage,
28
+ download_url,
29
+ usage,
30
+ console_name,
31
+ logger=None,
32
+ ):
33
+ self.logger = logger
34
+ if logger is not None:
35
+ logger.log_message("instantiated", component="AboutPage")
36
+ if not isinstance(check, CheckSystem):
37
+ raise TypeError("about host check is CheckSystem")
38
+ self.check = check
39
+ self.app_name = app_name
40
+ self.version = version
41
+ self.author = author
42
+ self.updated = updated
43
+ self.homepage = homepage
44
+ self.download_url = download_url
45
+ self.usage = usage
46
+ self.console_name = console_name
47
+
48
+ def _is_source_checkout(self, path):
49
+ """True when path is this package inside a source tree that has pyproject.toml."""
50
+ marker = "{}src{}ThreeDimensionModeller{}".format(os.sep, os.sep, os.sep)
51
+ if marker not in path:
52
+ return False
53
+ cursor = os.path.dirname(path)
54
+ for _ in range(8):
55
+ if os.path.isfile(os.path.join(cursor, "pyproject.toml")):
56
+ return True
57
+ parent = os.path.dirname(cursor)
58
+ if parent == cursor:
59
+ return False
60
+ cursor = parent
61
+ return False
62
+
63
+ def install_kind(self, path):
64
+ """
65
+ General Purpose: global, local, or uninstalled for an about location.
66
+ A source checkout is uninstalled. A copy under the home directory is local.
67
+ """
68
+ path = os.path.realpath(path)
69
+ parts = path.split(os.sep)
70
+ packaged = "site-packages" in parts or "dist-packages" in parts
71
+ if not packaged and self._is_source_checkout(path):
72
+ return "uninstalled"
73
+ home = os.path.realpath(os.path.expanduser("~"))
74
+ in_home = path == home or path.startswith(home + os.sep)
75
+ base = os.path.basename(path)
76
+ if in_home and (packaged or base in (self.console_name, self.app_name)):
77
+ return "local"
78
+ if path.startswith("/usr/") or path.startswith("/opt/") or path.startswith("/bin/"):
79
+ return "global"
80
+ if packaged and not in_home:
81
+ return "global"
82
+ return "uninstalled"
83
+
84
+ def install_sentence(self, kind):
85
+ """General Purpose: The location sentence inside the about box."""
86
+ if kind == "global":
87
+ return "You are using the GLOBAL INSTALLED version, location:"
88
+ if kind == "local":
89
+ return "You are using the LOCAL INSTALLED version, location:"
90
+ return "You are using an UNINSTALLED version, location:"
91
+
92
+ def about_box_lines(
93
+ self,
94
+ usage=None,
95
+ location=None,
96
+ kind=None,
97
+ homepage=None,
98
+ download_url=None,
99
+ author=None,
100
+ updated=None,
101
+ ):
102
+ """
103
+ General Purpose: Star-bordered about box.
104
+ An empty download URL omits the install line.
105
+ The title uses the package version string. It is not a second integer triple.
106
+ """
107
+ if usage is None:
108
+ usage = self.usage
109
+ if location is None:
110
+ location = self.check.self_location()
111
+ if kind is None:
112
+ kind = self.install_kind(location)
113
+ if homepage is None:
114
+ homepage = self.homepage
115
+ if download_url is None:
116
+ download_url = self.download_url
117
+ if author is None:
118
+ author = self.author
119
+ if updated is None:
120
+ updated = self.updated
121
+ app = self.install_sentence(kind)
122
+ python_exe = self.check.python_executable_name() or "python3"
123
+ msg1 = "{} ({}) by {} on {}".format(
124
+ self.app_name, self.version, author, updated
125
+ )
126
+ if download_url == "":
127
+ msg = [
128
+ msg1,
129
+ "",
130
+ app,
131
+ " {}".format(location),
132
+ "",
133
+ "Basic Usage:",
134
+ " {}".format(usage),
135
+ "",
136
+ "Please visit our homepage: ",
137
+ ' "{}"'.format(homepage),
138
+ "",
139
+ "",
140
+ "",
141
+ "",
142
+ ]
143
+ else:
144
+ msg = [
145
+ msg1,
146
+ "",
147
+ app,
148
+ " {}".format(location),
149
+ "",
150
+ "Basic Usage:",
151
+ " {}".format(usage),
152
+ "",
153
+ "Please visit our homepage: ",
154
+ ' "{}"'.format(homepage),
155
+ "",
156
+ "Installation command:",
157
+ " curl -fsSL {} | {}".format(download_url, python_exe),
158
+ "",
159
+ ]
160
+ if download_url == "":
161
+ if homepage == "":
162
+ max_line = len(msg) - 3
163
+ else:
164
+ max_line = len(msg) - 2
165
+ else:
166
+ max_line = len(msg) - 1
167
+ if max_line < 1:
168
+ max_line = len(msg)
169
+ max_len = 0
170
+ for index in range(0, max_line):
171
+ if len(msg[index]) > max_len:
172
+ max_len = len(msg[index])
173
+ boxed = []
174
+ for index in range(0, max_line):
175
+ boxed.append(msg[index] + (" " * (max_len - len(msg[index]))))
176
+ star = "*" * (max_len + 4)
177
+ blank = " " * max_len
178
+ lines = [star, "* {} *".format(blank)]
179
+ for row in boxed:
180
+ lines.append("* {} *".format(row))
181
+ lines.append("* {} *".format(blank))
182
+ lines.append(star)
183
+ return lines
184
+
185
+ def framework_about(self):
186
+ """
187
+ General Purpose: About text for the menu result page.
188
+ requirement-python-about: identity, host check, and the install box.
189
+ """
190
+ lines = [
191
+ "{} {}".format(self.app_name, self.version),
192
+ "Domain: Build a glTF model and an HTML viewer from outline images in a folder",
193
+ "Runtime tools: none",
194
+ "Entry points: {}, python -m {}".format(self.console_name, self.app_name),
195
+ "",
196
+ ]
197
+ lines.extend(self.check.check_system_lines())
198
+ lines.append("")
199
+ lines.extend(self.about_box_lines())
200
+ return "\n".join(lines)