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
|
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
|
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)))
|