MCPcopy Index your code
hub / github.com/idank/explainshell / list_sections

Method list_sections

explainshell/store.py:634–648  ·  view source on GitHub ↗

Return distinct section directories for a distro/release. Extracts the third path component from source keys matching ``distro/release/...`` using a range scan on the primary key.

(self, distro: str, release: str)

Source from the content-addressed store, hash-verified

632 return SubcommandMappingResult(mappings_to_add, parents)
633
634 def list_sections(self, distro: str, release: str) -> list[str]:
635 """Return distinct section directories for a distro/release.
636
637 Extracts the third path component from source keys matching
638 ``distro/release/...`` using a range scan on the primary key.
639 """
640 prefix = f"{distro}/{release}/"
641 offset = len(prefix)
642 rows = self._conn.execute(
643 "SELECT DISTINCT SUBSTR(source, ?, INSTR(SUBSTR(source, ?), '/') - 1) AS section "
644 "FROM manpages WHERE source >= ? AND source < ? "
645 "ORDER BY section",
646 (offset + 1, offset + 1, prefix, prefix[:-1] + chr(ord(prefix[-1]) + 1)),
647 ).fetchall()
648 return [row["section"] for row in rows]
649
650 def list_manpages(self, prefix: str) -> list[str]:
651 """List source paths that start with *prefix*.

Callers 5

show_sectionsFunction · 0.95
manpage_sectionsFunction · 0.80
test_no_duplicatesMethod · 0.80

Calls

no outgoing calls

Tested by 3

test_no_duplicatesMethod · 0.64