home » dokk/manpages.git
Author zPlus <zplus@peers.community> 2023-11-25 08:02:26
Committer zPlus <zplus@peers.community> 2023-11-25 08:02:26
Commit a0539d8 (patch)
Tree a91a996
Parent(s)

Add [ and ] to the list of %-encoded characters.


commits diff: 7485d93..a0539d8
1 file changed, 7 insertions, 5 deletionsdownload


Diffstat
-rwxr-xr-x scripts/rdf.py 12

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+7/-5 M   scripts/rdf.py
index 8c774e2..a8d0795
old size: 4K - new size: 4K
@@ -25,11 +25,13 @@ def percent_encode(string):
25 25 path. Since we use node URIs like <dokk:manpages:distro/package/name>, we need
26 26 to percent-encode these otherwise the URLs are invalid.
27 27 The reason for using a custom method instead of urllib.parse.quote() is that quote()
28 - will percent-encode *any* non ASCII character such as non-latin characters.
28 + will percent-encode *any* non-ASCII character.
29 29 """
30 30
31 31 return string.replace(' ', '_') \
32 - .replace('#', '%23')
32 + .replace('#', '%23') \
33 + .replace('[', '%5B') \
34 + .replace(']', '%5D')
33 35
34 36 for absolute_file_path in pathlib.Path(DEBIMAN_SERVING_DIR).glob('**/*.roff'):
35 37 if not absolute_file_path.is_file():
@@ -75,7 +77,7 @@ for absolute_file_path in pathlib.Path(DEBIMAN_SERVING_DIR).glob('**/*.roff'):
75 77 # because I haven't got enough RAM for storing thousands of pages.
76 78 g_page = Graph()
77 79
78 - page_ref = URIRef('dokk:manpages:debian/' + percent_encode(f'{distro_number}/{distro_package}/{filename}'))
80 + page_ref = URIRef(percent_encode(f'dokk:manpages:debian/{distro_number}/{distro_package}/{filename}'))
79 81 g_page.add((page_ref, RDF.type, URIRef(MANPAGE.Page)))
80 82 g_page.add((page_ref, URIRef(MANPAGE.filename), Literal(filename)))
81 83 g_page.add((page_ref, URIRef(MANPAGE.name), Literal(name)))
@@ -93,14 +95,14 @@ for absolute_file_path in pathlib.Path(DEBIMAN_SERVING_DIR).glob('**/*.roff'):
93 95
94 96 # Create a graph node for this package
95 97 # Link to the page node
96 - package_ref = URIRef('dokk:manpages:debian/' + percent_encode(f'{distro_number}/{distro_package}'))
98 + package_ref = URIRef(percent_encode(f'dokk:manpages:debian/{distro_number}/{distro_package}'))
97 99 g.add((package_ref, RDF.type, URIRef(MANPAGE.Package)))
98 100 g.add((package_ref, MANPAGE.name, Literal(distro_package)))
99 101 g.add((package_ref, MANPAGE.page, page_ref))
100 102
101 103 # Create a graph node for this distro
102 104 # Link to the package node
103 - distro_ref = URIRef('dokk:manpages:debian/' + percent_encode(f'{distro_number}'))
105 + distro_ref = URIRef(percent_encode(f'dokk:manpages:debian/{distro_number}'))
104 106 g.add((distro_ref, RDF.type, URIRef(MANPAGE.Distribution)))
105 107 g.add((distro_ref, MANPAGE.name, Literal('debian')))
106 108 g.add((distro_ref, MANPAGE.codename, Literal(distro_codename)))