@illuminis/comprism 0.1.8 → 2.4.0
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.
- package/out/{graph → build/machine/codemap}/read-python.js +2 -2
- package/out/{executor → build/machine/executor}/diagnostics.js +1 -1
- package/out/{executor → build/machine/executor}/hooks.js +1 -1
- package/out/{executor → build/machine/executor}/sandbox.js +1 -1
- package/out/build/machine/line/index.js +339 -0
- package/out/{commands/privacy.js → build/machine/runtime/home.js} +10 -19
- package/out/build/machine/runtime/needs.js +89 -0
- package/out/{lib → build/machine/runtime}/self.js +25 -3
- package/out/build/machine/terminal/jobs.js +67 -0
- package/out/build/machine/terminal/sign-in.js +212 -0
- package/out/build/machine/terminal/steps.js +460 -0
- package/out/build/machine/terminal/voice.js +136 -0
- package/out/build/machine/voice/record.js +286 -0
- package/out/cli-start.js +128 -0
- package/out/machine/line/index.js +339 -0
- package/out/machine/runtime/self.js +22 -0
- package/out/machine/terminal/clipboard.js +182 -0
- package/out/machine/terminal/jobs.js +67 -0
- package/out/machine/terminal/sign-in.js +212 -0
- package/out/machine/terminal/steps.js +460 -0
- package/out/machine/terminal/voice.js +136 -0
- package/out/machine/voice/record.js +79 -1
- package/out/native/dictate +0 -0
- package/out/server.generated.js +6 -0
- package/package.json +8 -40
- package/README.md +0 -343
- package/out/agent/command.d.ts +0 -157
- package/out/agent/command.js +0 -454
- package/out/agent/render.d.ts +0 -169
- package/out/agent/render.js +0 -689
- package/out/agent/session.d.ts +0 -334
- package/out/agent/session.js +0 -1232
- package/out/commands/agents.d.ts +0 -2
- package/out/commands/agents.js +0 -79
- package/out/commands/ask.d.ts +0 -1
- package/out/commands/ask.js +0 -222
- package/out/commands/codemap.d.ts +0 -2
- package/out/commands/codemap.js +0 -151
- package/out/commands/commands-thin.d.ts +0 -39
- package/out/commands/commands-thin.js +0 -244
- package/out/commands/config.d.ts +0 -1
- package/out/commands/config.js +0 -138
- package/out/commands/cost.d.ts +0 -1
- package/out/commands/cost.js +0 -167
- package/out/commands/decisionEngine.d.ts +0 -1
- package/out/commands/decisionEngine.js +0 -66
- package/out/commands/hooks.d.ts +0 -1
- package/out/commands/hooks.js +0 -83
- package/out/commands/install.d.ts +0 -206
- package/out/commands/install.js +0 -738
- package/out/commands/instructions.d.ts +0 -1
- package/out/commands/instructions.js +0 -113
- package/out/commands/integrations.d.ts +0 -3
- package/out/commands/integrations.js +0 -215
- package/out/commands/jobs.d.ts +0 -5
- package/out/commands/jobs.js +0 -157
- package/out/commands/keys.d.ts +0 -55
- package/out/commands/keys.js +0 -344
- package/out/commands/login.d.ts +0 -9
- package/out/commands/login.js +0 -606
- package/out/commands/memory.d.ts +0 -3
- package/out/commands/memory.js +0 -113
- package/out/commands/permissions.d.ts +0 -1
- package/out/commands/permissions.js +0 -94
- package/out/commands/plugins.d.ts +0 -4
- package/out/commands/plugins.js +0 -192
- package/out/commands/privacy.d.ts +0 -1
- package/out/commands/providerKey.d.ts +0 -32
- package/out/commands/providerKey.js +0 -108
- package/out/commands/repl.d.ts +0 -12
- package/out/commands/repl.js +0 -2303
- package/out/commands/report.d.ts +0 -39
- package/out/commands/report.js +0 -115
- package/out/commands/review.d.ts +0 -5
- package/out/commands/review.js +0 -223
- package/out/commands/sessions.d.ts +0 -23
- package/out/commands/sessions.js +0 -115
- package/out/commands/settings.d.ts +0 -23
- package/out/commands/settings.js +0 -153
- package/out/commands/skills.d.ts +0 -21
- package/out/commands/skills.js +0 -207
- package/out/commands/unattended.d.ts +0 -7
- package/out/commands/unattended.js +0 -351
- package/out/commands/update.d.ts +0 -1
- package/out/commands/update.js +0 -123
- package/out/commands/welcome.d.ts +0 -25
- package/out/commands/welcome.js +0 -223
- package/out/commands/worktrees.d.ts +0 -5
- package/out/commands/worktrees.js +0 -186
- package/out/executor/browser.d.ts +0 -14
- package/out/executor/diagnostics.d.ts +0 -2
- package/out/executor/documents.d.ts +0 -40
- package/out/executor/files.d.ts +0 -2
- package/out/executor/git.d.ts +0 -48
- package/out/executor/hooks.d.ts +0 -51
- package/out/executor/index.d.ts +0 -45
- package/out/executor/notebook.d.ts +0 -2
- package/out/executor/paths.d.ts +0 -20
- package/out/executor/sandbox.d.ts +0 -40
- package/out/executor/shell.d.ts +0 -86
- package/out/executor/toolservers.d.ts +0 -20
- package/out/executor/worktree.d.ts +0 -9
- package/out/graph/build.d.ts +0 -45
- package/out/graph/facts.d.ts +0 -47
- package/out/graph/files.d.ts +0 -45
- package/out/graph/read-locales.d.ts +0 -29
- package/out/graph/read-python.d.ts +0 -11
- package/out/graph/read-typescript.d.ts +0 -16
- package/out/graph/sync.d.ts +0 -66
- package/out/graph/sync.js +0 -242
- package/out/lib/attach.d.ts +0 -106
- package/out/lib/attach.js +0 -396
- package/out/lib/clipboard.d.ts +0 -23
- package/out/lib/commandlist.d.ts +0 -20
- package/out/lib/commandlist.js +0 -58
- package/out/lib/config.d.ts +0 -94
- package/out/lib/config.js +0 -197
- package/out/lib/connection.d.ts +0 -73
- package/out/lib/connection.js +0 -188
- package/out/lib/decision.d.ts +0 -22
- package/out/lib/decision.js +0 -50
- package/out/lib/fingerprint.d.ts +0 -25
- package/out/lib/fingerprint.js +0 -58
- package/out/lib/gateway.d.ts +0 -427
- package/out/lib/gateway.js +0 -226
- package/out/lib/history.d.ts +0 -24
- package/out/lib/history.js +0 -137
- package/out/lib/ide.d.ts +0 -19
- package/out/lib/ide.js +0 -131
- package/out/lib/keyboard.d.ts +0 -98
- package/out/lib/keyboard.js +0 -390
- package/out/lib/lastlogin.d.ts +0 -14
- package/out/lib/lastlogin.js +0 -105
- package/out/lib/machine.d.ts +0 -21
- package/out/lib/machine.js +0 -91
- package/out/lib/notify.d.ts +0 -4
- package/out/lib/notify.js +0 -52
- package/out/lib/output.d.ts +0 -48
- package/out/lib/output.js +0 -108
- package/out/lib/picker.d.ts +0 -1
- package/out/lib/picker.js +0 -158
- package/out/lib/project-ops.d.ts +0 -19
- package/out/lib/project-ops.js +0 -146
- package/out/lib/project.d.ts +0 -28
- package/out/lib/prompt.d.ts +0 -37
- package/out/lib/prompt.js +0 -142
- package/out/lib/queue.d.ts +0 -13
- package/out/lib/queue.js +0 -116
- package/out/lib/readiness.d.ts +0 -22
- package/out/lib/readiness.js +0 -207
- package/out/lib/self.d.ts +0 -23
- package/out/lib/servicecommand.d.ts +0 -14
- package/out/lib/servicecommand.js +0 -74
- package/out/lib/sessions.d.ts +0 -19
- package/out/lib/sessions.js +0 -221
- package/out/lib/startcache.d.ts +0 -13
- package/out/lib/startcache.js +0 -78
- package/out/lib/stdin.d.ts +0 -32
- package/out/lib/stdin.js +0 -117
- package/out/lib/store.d.ts +0 -40
- package/out/lib/store.js +0 -138
- package/out/lib/sync.d.ts +0 -18
- package/out/lib/sync.js +0 -81
- package/out/lib/types.d.ts +0 -417
- package/out/lib/types.js +0 -21
- package/out/lib/ui.d.ts +0 -123
- package/out/lib/ui.js +0 -299
- package/out/lib/version.d.ts +0 -23
- package/out/lib/version.js +0 -46
- package/out/lib/voice.d.ts +0 -49
- package/out/lib/voice.js +0 -236
- package/out/lib/words.d.ts +0 -20
- package/out/lib/words.js +0 -27
- package/out/machine/codemap/build.d.ts +0 -45
- package/out/machine/codemap/facts.d.ts +0 -47
- package/out/machine/codemap/files.d.ts +0 -45
- package/out/machine/codemap/read-locales.d.ts +0 -29
- package/out/machine/codemap/read-python.d.ts +0 -11
- package/out/machine/codemap/read-typescript.d.ts +0 -16
- package/out/machine/executor/browser.d.ts +0 -14
- package/out/machine/executor/diagnostics.d.ts +0 -2
- package/out/machine/executor/documents.d.ts +0 -40
- package/out/machine/executor/files.d.ts +0 -2
- package/out/machine/executor/git.d.ts +0 -48
- package/out/machine/executor/hooks.d.ts +0 -51
- package/out/machine/executor/index.d.ts +0 -45
- package/out/machine/executor/notebook.d.ts +0 -2
- package/out/machine/executor/paths.d.ts +0 -20
- package/out/machine/executor/sandbox.d.ts +0 -40
- package/out/machine/executor/shell.d.ts +0 -86
- package/out/machine/executor/toolservers.d.ts +0 -20
- package/out/machine/executor/worktree.d.ts +0 -9
- package/out/machine/folder/project.d.ts +0 -28
- package/out/machine/runtime/home.d.ts +0 -2
- package/out/machine/runtime/needs.d.ts +0 -30
- package/out/machine/runtime/self.d.ts +0 -23
- package/out/machine/voice/record.d.ts +0 -38
- package/out/postinstall.d.ts +0 -2
- package/out/postinstall.js +0 -120
- package/out/providers/anthropic.d.ts +0 -22
- package/out/providers/anthropic.js +0 -80
- package/out/providers/index.d.ts +0 -8
- package/out/providers/index.js +0 -84
- package/out/providers/openai.d.ts +0 -11
- package/out/providers/openai.js +0 -57
- package/out/thin.d.ts +0 -2
- package/out/thin.js +0 -855
- package/scripts/read_python.py +0 -270
- /package/out/{graph → build/machine/codemap}/build.js +0 -0
- /package/out/{graph → build/machine/codemap}/facts.js +0 -0
- /package/out/{graph → build/machine/codemap}/files.js +0 -0
- /package/out/{graph → build/machine/codemap}/read-locales.js +0 -0
- /package/out/{graph → build/machine/codemap}/read-typescript.js +0 -0
- /package/out/{executor → build/machine/executor}/browser.js +0 -0
- /package/out/{executor → build/machine/executor}/documents.js +0 -0
- /package/out/{executor → build/machine/executor}/files.js +0 -0
- /package/out/{executor → build/machine/executor}/git.js +0 -0
- /package/out/{executor → build/machine/executor}/index.js +0 -0
- /package/out/{executor → build/machine/executor}/notebook.js +0 -0
- /package/out/{executor → build/machine/executor}/paths.js +0 -0
- /package/out/{executor → build/machine/executor}/shell.js +0 -0
- /package/out/{executor → build/machine/executor}/toolservers.js +0 -0
- /package/out/{executor → build/machine/executor}/worktree.js +0 -0
- /package/out/{lib → build/machine/folder}/project.js +0 -0
- /package/out/{lib → build/machine/terminal}/clipboard.js +0 -0
package/scripts/read_python.py
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Read Python files into code map facts, using Python's own parser.
|
|
3
|
-
|
|
4
|
-
This is a parser, not a model. Nothing here guesses: every object and every
|
|
5
|
-
link comes from the syntax tree, so the same file always produces the same
|
|
6
|
-
facts and two machines reading one project agree.
|
|
7
|
-
|
|
8
|
-
It runs on the person's own machine and prints facts, never source. What
|
|
9
|
-
leaves is "a function called price_of exists at line 40 of this file, and
|
|
10
|
-
these things call it". What it says is never read by anything but the parser.
|
|
11
|
-
|
|
12
|
-
Usage: read_python.py <project-root> <relative-path-list-file>
|
|
13
|
-
Writes one JSON object to stdout.
|
|
14
|
-
"""
|
|
15
|
-
import ast
|
|
16
|
-
import json
|
|
17
|
-
import os
|
|
18
|
-
import sys
|
|
19
|
-
|
|
20
|
-
ROUTE_METHODS = {"get", "post", "put", "patch", "delete", "head", "options"}
|
|
21
|
-
MODEL_BASE_HINTS = {"Base", "BaseDataMixin", "DeclarativeBase", "Model",
|
|
22
|
-
"SQLModel", "models.Model"}
|
|
23
|
-
COLUMN_FACTORIES = {"Column", "mapped_column", "relationship"}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def dotted(node):
|
|
27
|
-
"""Render a Name / Attribute chain back to its source text."""
|
|
28
|
-
if isinstance(node, ast.Name):
|
|
29
|
-
return node.id
|
|
30
|
-
if isinstance(node, ast.Attribute):
|
|
31
|
-
base = dotted(node.value)
|
|
32
|
-
return "%s.%s" % (base, node.attr) if base else node.attr
|
|
33
|
-
if isinstance(node, ast.Call):
|
|
34
|
-
return dotted(node.func)
|
|
35
|
-
if isinstance(node, ast.Subscript):
|
|
36
|
-
return dotted(node.value)
|
|
37
|
-
return ""
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def literal_str(node):
|
|
41
|
-
if isinstance(node, ast.Constant) and isinstance(node.value, str):
|
|
42
|
-
return node.value
|
|
43
|
-
return None
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class ModuleReader(ast.NodeVisitor):
|
|
47
|
-
def __init__(self, file_id, module_path):
|
|
48
|
-
self.file_id = file_id
|
|
49
|
-
self.module_path = module_path
|
|
50
|
-
self.objects = []
|
|
51
|
-
self.links = []
|
|
52
|
-
self.scope = []
|
|
53
|
-
self.owner = [file_id]
|
|
54
|
-
self.router_prefixes = {}
|
|
55
|
-
self.mounts = []
|
|
56
|
-
|
|
57
|
-
def qual(self, name):
|
|
58
|
-
return ".".join(self.scope + [name])
|
|
59
|
-
|
|
60
|
-
def add_object(self, object_id, kind, name, line, **extra):
|
|
61
|
-
entry = {"id": object_id, "kind": kind, "name": name,
|
|
62
|
-
"file": self.file_id, "line": line}
|
|
63
|
-
entry.update({k: v for k, v in extra.items() if v not in (None, [], "")})
|
|
64
|
-
self.objects.append(entry)
|
|
65
|
-
|
|
66
|
-
def add_link(self, src, kind, dst=None, to_name=None, **extra):
|
|
67
|
-
link = {"from": src, "kind": kind}
|
|
68
|
-
if dst:
|
|
69
|
-
link["to"] = dst
|
|
70
|
-
if to_name:
|
|
71
|
-
link["to_name"] = to_name
|
|
72
|
-
link.update(extra)
|
|
73
|
-
self.links.append(link)
|
|
74
|
-
|
|
75
|
-
# ---- imports ---------------------------------------------------------
|
|
76
|
-
def visit_Import(self, node):
|
|
77
|
-
for alias in node.names:
|
|
78
|
-
self.add_link(self.file_id, "imports", to_name=alias.name, line=node.lineno)
|
|
79
|
-
self.generic_visit(node)
|
|
80
|
-
|
|
81
|
-
def visit_ImportFrom(self, node):
|
|
82
|
-
module = node.module or ""
|
|
83
|
-
if node.level:
|
|
84
|
-
base = self.module_path.rsplit(".", node.level)[0]
|
|
85
|
-
module = "%s.%s" % (base, module) if module else base
|
|
86
|
-
for alias in node.names:
|
|
87
|
-
self.add_link(
|
|
88
|
-
self.file_id, "imports",
|
|
89
|
-
to_name=("%s.%s" % (module, alias.name)) if module else alias.name,
|
|
90
|
-
line=node.lineno)
|
|
91
|
-
self.generic_visit(node)
|
|
92
|
-
|
|
93
|
-
# ---- routers ---------------------------------------------------------
|
|
94
|
-
def visit_Assign(self, node):
|
|
95
|
-
"""`router = APIRouter(prefix="/billing")` fixes every path below it."""
|
|
96
|
-
if not self.scope and isinstance(node.value, ast.Call):
|
|
97
|
-
leaf = dotted(node.value.func).split(".")[-1]
|
|
98
|
-
if leaf in ("APIRouter", "Blueprint", "Router"):
|
|
99
|
-
prefix = ""
|
|
100
|
-
for kw in node.value.keywords:
|
|
101
|
-
if kw.arg in ("prefix", "url_prefix"):
|
|
102
|
-
prefix = literal_str(kw.value) or ""
|
|
103
|
-
for target in node.targets:
|
|
104
|
-
if isinstance(target, ast.Name):
|
|
105
|
-
self.router_prefixes[target.id] = prefix
|
|
106
|
-
self.generic_visit(node)
|
|
107
|
-
|
|
108
|
-
def _include_router(self, node):
|
|
109
|
-
"""`include_router(billing.router, prefix="/api")` mounts a whole file."""
|
|
110
|
-
prefix = ""
|
|
111
|
-
for kw in node.keywords:
|
|
112
|
-
if kw.arg in ("prefix", "url_prefix"):
|
|
113
|
-
prefix = literal_str(kw.value) or ""
|
|
114
|
-
if not node.args:
|
|
115
|
-
return
|
|
116
|
-
target = dotted(node.args[0])
|
|
117
|
-
if target:
|
|
118
|
-
self.mounts.append({"target": target, "prefix": prefix, "line": node.lineno})
|
|
119
|
-
|
|
120
|
-
# ---- classes ---------------------------------------------------------
|
|
121
|
-
def visit_ClassDef(self, node):
|
|
122
|
-
qual = self.qual(node.name)
|
|
123
|
-
object_id = "%s::%s" % (self.file_id, qual)
|
|
124
|
-
bases = [dotted(b) for b in node.bases]
|
|
125
|
-
tablename = None
|
|
126
|
-
columns = []
|
|
127
|
-
for stmt in node.body:
|
|
128
|
-
if isinstance(stmt, ast.Assign):
|
|
129
|
-
for target in stmt.targets:
|
|
130
|
-
if isinstance(target, ast.Name):
|
|
131
|
-
if target.id == "__tablename__":
|
|
132
|
-
tablename = literal_str(stmt.value)
|
|
133
|
-
elif isinstance(stmt.value, ast.Call) and \
|
|
134
|
-
dotted(stmt.value.func).split(".")[-1] in COLUMN_FACTORIES:
|
|
135
|
-
columns.append(target.id)
|
|
136
|
-
elif isinstance(stmt, ast.AnnAssign) and isinstance(stmt.target, ast.Name):
|
|
137
|
-
if isinstance(stmt.value, ast.Call) and \
|
|
138
|
-
dotted(stmt.value.func).split(".")[-1] in COLUMN_FACTORIES:
|
|
139
|
-
columns.append(stmt.target.id)
|
|
140
|
-
|
|
141
|
-
is_model = bool(tablename) or any(
|
|
142
|
-
b.split(".")[-1] in MODEL_BASE_HINTS for b in bases)
|
|
143
|
-
self.add_object(object_id, "model" if is_model else "class", qual,
|
|
144
|
-
node.lineno, bases=bases, table=tablename, columns=columns)
|
|
145
|
-
self.add_link(self.file_id, "defines", object_id)
|
|
146
|
-
for base in bases:
|
|
147
|
-
self.add_link(object_id, "inherits", to_name=base)
|
|
148
|
-
if tablename:
|
|
149
|
-
table_id = "table:%s" % tablename
|
|
150
|
-
self.add_object(table_id, "table", tablename, node.lineno)
|
|
151
|
-
self.add_link(object_id, "maps_to", table_id)
|
|
152
|
-
|
|
153
|
-
self.scope.append(node.name)
|
|
154
|
-
self.owner.append(object_id)
|
|
155
|
-
self.generic_visit(node)
|
|
156
|
-
self.owner.pop()
|
|
157
|
-
self.scope.pop()
|
|
158
|
-
|
|
159
|
-
# ---- functions -------------------------------------------------------
|
|
160
|
-
def _function(self, node, is_async):
|
|
161
|
-
qual = self.qual(node.name)
|
|
162
|
-
object_id = "%s::%s" % (self.file_id, qual)
|
|
163
|
-
decorators = [dotted(d) for d in node.decorator_list]
|
|
164
|
-
self.add_object(object_id, "method" if self.scope else "function", qual,
|
|
165
|
-
node.lineno, decorators=decorators,
|
|
166
|
-
is_async=is_async or None,
|
|
167
|
-
args=[a.arg for a in node.args.args])
|
|
168
|
-
self.add_link(self.file_id, "defines", object_id)
|
|
169
|
-
|
|
170
|
-
# An endpoint: @router.get("/things"). The path here is RELATIVE to its
|
|
171
|
-
# own router; the service puts the two halves back together.
|
|
172
|
-
for dec in node.decorator_list:
|
|
173
|
-
if not isinstance(dec, ast.Call):
|
|
174
|
-
continue
|
|
175
|
-
target = dotted(dec.func)
|
|
176
|
-
verb = target.split(".")[-1].lower()
|
|
177
|
-
if verb not in ROUTE_METHODS:
|
|
178
|
-
continue
|
|
179
|
-
path = literal_str(dec.args[0]) if dec.args else None
|
|
180
|
-
if path is None:
|
|
181
|
-
continue
|
|
182
|
-
router_var = target.rsplit(".", 1)[0] if "." in target else ""
|
|
183
|
-
route_id = "route:%s %s@%s" % (verb.upper(), path, self.file_id)
|
|
184
|
-
self.add_object(route_id, "route", "%s %s" % (verb.upper(), path),
|
|
185
|
-
node.lineno, method=verb.upper(), path=path,
|
|
186
|
-
router_var=router_var)
|
|
187
|
-
self.add_link(route_id, "handled_by", object_id)
|
|
188
|
-
self.add_link(self.file_id, "declares", route_id)
|
|
189
|
-
|
|
190
|
-
self.scope.append(node.name)
|
|
191
|
-
self.owner.append(object_id)
|
|
192
|
-
self.generic_visit(node)
|
|
193
|
-
self.owner.pop()
|
|
194
|
-
self.scope.pop()
|
|
195
|
-
|
|
196
|
-
def visit_FunctionDef(self, node):
|
|
197
|
-
self._function(node, False)
|
|
198
|
-
|
|
199
|
-
def visit_AsyncFunctionDef(self, node):
|
|
200
|
-
self._function(node, True)
|
|
201
|
-
|
|
202
|
-
def visit_Name(self, node):
|
|
203
|
-
"""A capitalized name used in an expression is nearly always a class or
|
|
204
|
-
a model being referenced, which is how database usage shows up."""
|
|
205
|
-
if isinstance(node.ctx, ast.Load) and node.id[:1].isupper():
|
|
206
|
-
self.add_link(self.owner[-1], "references", to_name=node.id, line=node.lineno)
|
|
207
|
-
self.generic_visit(node)
|
|
208
|
-
|
|
209
|
-
def visit_Call(self, node):
|
|
210
|
-
target = dotted(node.func)
|
|
211
|
-
if target.split(".")[-1] in ("include_router", "register_blueprint"):
|
|
212
|
-
self._include_router(node)
|
|
213
|
-
if target:
|
|
214
|
-
leaf = target.split(".")[-1]
|
|
215
|
-
if leaf and not leaf.startswith("_"):
|
|
216
|
-
self.add_link(self.owner[-1], "calls", to_name=leaf,
|
|
217
|
-
full_name=target, line=node.lineno)
|
|
218
|
-
self.generic_visit(node)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
def module_path_for(rel_path):
|
|
222
|
-
trimmed = rel_path[:-3]
|
|
223
|
-
if trimmed.endswith("/__init__"):
|
|
224
|
-
trimmed = trimmed[: -len("/__init__")]
|
|
225
|
-
return trimmed.replace("/", ".")
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
def main():
|
|
229
|
-
if len(sys.argv) < 3:
|
|
230
|
-
sys.stderr.write("usage: read_python.py <project-root> <path-list-file>\n")
|
|
231
|
-
return 2
|
|
232
|
-
root = os.path.abspath(sys.argv[1])
|
|
233
|
-
with open(sys.argv[2], "r", encoding="utf8") as handle:
|
|
234
|
-
rels = [line.strip() for line in handle if line.strip()]
|
|
235
|
-
|
|
236
|
-
facts = {}
|
|
237
|
-
failures = []
|
|
238
|
-
for rel_path in rels:
|
|
239
|
-
full = os.path.join(root, rel_path)
|
|
240
|
-
try:
|
|
241
|
-
with open(full, "r", encoding="utf-8") as handle:
|
|
242
|
-
source = handle.read()
|
|
243
|
-
tree = ast.parse(source, filename=rel_path)
|
|
244
|
-
except (SyntaxError, UnicodeDecodeError, OSError, ValueError) as exc:
|
|
245
|
-
failures.append({"file": rel_path, "reason": type(exc).__name__})
|
|
246
|
-
continue
|
|
247
|
-
|
|
248
|
-
reader = ModuleReader(rel_path, module_path_for(rel_path))
|
|
249
|
-
reader.visit(tree)
|
|
250
|
-
entry = {
|
|
251
|
-
"objects": [{
|
|
252
|
-
"id": rel_path, "kind": "file",
|
|
253
|
-
"name": os.path.basename(rel_path), "file": rel_path, "line": 1,
|
|
254
|
-
"lang": "python", "lines": source.count("\n") + 1,
|
|
255
|
-
"module": module_path_for(rel_path),
|
|
256
|
-
}] + reader.objects,
|
|
257
|
-
"links": reader.links,
|
|
258
|
-
}
|
|
259
|
-
if reader.router_prefixes or reader.mounts:
|
|
260
|
-
entry["routers"] = {"prefixes": reader.router_prefixes,
|
|
261
|
-
"mounts": reader.mounts}
|
|
262
|
-
facts[rel_path] = entry
|
|
263
|
-
|
|
264
|
-
json.dump({"facts": facts, "failures": failures}, sys.stdout,
|
|
265
|
-
separators=(",", ":"))
|
|
266
|
-
return 0
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if __name__ == "__main__":
|
|
270
|
-
sys.exit(main())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|