Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def main():
if args.command == "schema":
create_schema(conn)
elif args.command == "jixia":
project = LeanProject(args.project_root)
# jixia runs each module with cwd=project_root, so the module file
# path must be absolute — a relative root would be resolved twice.
project = LeanProject(os.path.abspath(args.project_root))
prefixes = [parse_name(p) for p in args.prefixes.split(",")]
load_data(project, prefixes, conn)
elif args.command == "informal":
Expand Down
10 changes: 9 additions & 1 deletion database/jixia_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ def _get_range(declaration: Declaration):

def load_data(project: LeanProject, prefixes: list[LeanName], conn: Connection):
def load_module(data: Iterable[LeanName], base_dir: Path):
values = ((Jsonb(m), project.path_of_module(m, base_dir).read_bytes(), project.load_module_info(m).docstring) for m in data)
values = []
for m in data:
try:
content = project.path_of_module(m, base_dir).read_bytes()
docstring = project.load_module_info(m).docstring
except FileNotFoundError:
logger.warning("skipping module %s: jixia output not found", m)
continue
values.append((Jsonb(m), content, docstring))
Comment on lines +41 to +49
cursor.executemany(
"""
INSERT INTO module (name, content, docstring) VALUES (%s, %s, %s) ON CONFLICT DO NOTHING
Expand Down
Loading