mirror of
https://codeberg.org/fediverse/fep.git
synced 2026-08-05 03:35:52 +00:00
450c402de3
This pull request adds `implementations` key to the JSON index. Implementations are counted only for proposals that have `implementation` type. Resolves https://codeberg.org/fediverse/fep/issues/194 and https://codeberg.org/fediverse/fep/pulls/214 Discussion on SocialHub: https://socialhub.activitypub.rocks/t/implemented-fep-type/5048 Results: | Title | Status | Count | | ----- | ------ | ----- | | [Object Integrity Proofs](https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md) | DRAFT | 6 | | [Identity Proofs](https://codeberg.org/fediverse/fep/src/branch/main/fep/c390/fep-c390.md) | DRAFT | 3 | | [Representing actor's public keys](https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md) | FINAL | 5 | | [Client-side activity signing](https://codeberg.org/fediverse/fep/src/branch/main/fep/ae97/fep-ae97.md) | DRAFT | 2 | | [Portable Objects](https://codeberg.org/fediverse/fep/src/branch/main/fep/ef61/fep-ef61.md) | DRAFT | 4 | | [Server-Level Actor Discovery Using WebFinger](https://codeberg.org/fediverse/fep/src/branch/main/fep/d556/fep-d556.md) | FINAL | 4 | | [The OpenWebAuth Protocol](https://codeberg.org/fediverse/fep/src/branch/main/fep/61cf/fep-61cf.md) | DRAFT | 5 | | [Emoji reactions](https://codeberg.org/fediverse/fep/src/branch/main/fep/c0e0/fep-c0e0.md) | DRAFT | 4 | | [Conversation Containers](https://codeberg.org/fediverse/fep/src/branch/main/fep/171b/fep-171b.md) | DRAFT | 3 | | [Backfilling conversations](https://codeberg.org/fediverse/fep/src/branch/main/fep/f228/fep-f228.md) | DRAFT | 8 | | [Representing context with a Collection](https://codeberg.org/fediverse/fep/src/branch/main/fep/2931/fep-2931.md) | DRAFT | 4 | | [Capability discovery](https://codeberg.org/fediverse/fep/src/branch/main/fep/844e/fep-844e.md) | DRAFT | 4 | Reviewed-on: https://codeberg.org/fediverse/fep/pulls/634 Reviewed-by: helge <helge@noreply.codeberg.org> Co-authored-by: silverpill <silverpill@firemail.cc> Co-committed-by: silverpill <silverpill@firemail.cc>
93 lines
2.5 KiB
Python
93 lines
2.5 KiB
Python
def unquote(value):
|
|
if value.startswith('"') and value.endswith('"'):
|
|
return value[1:-1]
|
|
else:
|
|
return value
|
|
|
|
|
|
class FepFile:
|
|
def __init__(self, fep):
|
|
self.fep = fep
|
|
with open(self.filename) as f:
|
|
self.frontmatter, self.content = FepFile.parsefile(f)
|
|
|
|
@property
|
|
def filename(self):
|
|
return f"fep/{self.fep}/fep-{self.fep}.md"
|
|
|
|
@property
|
|
def summary(self):
|
|
result = []
|
|
is_summary = False
|
|
for x in self.content:
|
|
if is_summary:
|
|
if x.startswith("##"):
|
|
return "\n".join(result)
|
|
result.append(x)
|
|
elif x == "## Summary":
|
|
is_summary = True
|
|
|
|
def write(self):
|
|
with open(self.filename, "w") as f:
|
|
f.write("---\n")
|
|
for x in self.frontmatter:
|
|
f.write(x + "\n")
|
|
f.write("---\n")
|
|
for x in self.content:
|
|
f.write(x + "\n")
|
|
|
|
@property
|
|
def parsed_frontmatter(self):
|
|
split = [x.split(":", 1) for x in self.frontmatter]
|
|
return {a: unquote(b.strip()) for a, b in split}
|
|
|
|
@property
|
|
def title(self):
|
|
titles = [x for x in self.content if x.startswith("# ")]
|
|
assert len(titles) > 0
|
|
|
|
title = titles[0]
|
|
|
|
begin_title = f"# FEP-{self.fep}: "
|
|
|
|
assert title.startswith(begin_title)
|
|
true_title = title.removeprefix(begin_title)
|
|
|
|
return true_title
|
|
|
|
@property
|
|
def implementations(self):
|
|
if self.parsed_frontmatter.get("type") != "implementation":
|
|
return 0
|
|
implementations = []
|
|
in_section = False
|
|
for line in self.content:
|
|
if line.startswith('#') and "Implementations" in line:
|
|
in_section = True
|
|
elif in_section is True and line.startswith('#'):
|
|
in_section = False
|
|
elif (
|
|
in_section is True
|
|
and (line.startswith("-") or line.startswith("*"))
|
|
):
|
|
implementations.append(line)
|
|
return len(implementations)
|
|
|
|
@staticmethod
|
|
def parsefile(f):
|
|
lines = f.readlines()
|
|
|
|
status = 0
|
|
frontmatter = []
|
|
content = []
|
|
|
|
for line in lines:
|
|
if line == "---\n" and status <= 2:
|
|
status += 1
|
|
elif status == 1:
|
|
frontmatter.append(line.removesuffix("\n"))
|
|
elif status >= 2:
|
|
content.append(line.removesuffix("\n"))
|
|
|
|
return frontmatter, content
|