Integrate dictionary metainfo line name and home page url into dictd build.
--- a/Makefile Sun Mar 27 23:59:21 2016 +0300
+++ b/Makefile Mon Mar 28 00:31:52 2016 +0300
@@ -315,14 +315,16 @@
dict: $(DICTDZ_FILES) $(INDEX_FILES)
# --case-sensitive
-# -u "`sed -n '\|http://[[:print:]]\+/|{s=^.*\(http://\)=\1=;p;q;}' $<`"
-# -s "`sed -n '/^ABOUT: /{s=ABOUT: ==;p;q;}' $<`"
-dist/dictd/%.dict dist/dictd/%.index: dist/dictd/%.c5
- (cd dist/dictd; dictfmt -c5 --headword-separator '; ' --break-headwords --utf8 --allchars $*) < $<
+dist/dictd/%.dict dist/dictd/%.index: dist/dictd/%.c5 dist/dictd/%.c5.name dist/dictd/%.c5.url $(MAKEFILE_LIST)
+ (cd dist/dictd; dictfmt -c5 --headword-separator '; ' --break-headwords --utf8 --allchars -s "`cat $*.c5.name`" -u "`cat $*.c5.url`" $*) < $<
dist/dictd/%.dict.dz: dist/dictd/%.dict
dictzip -c $< >$@
+
+dist/dictd/%.c5.name dist/dictd/%.c5.url: dist/dictd/%.c5
+ :
+
# -B suppress __pycache__ dir
dist/dictd/%.c5: %.gadict py/gadict.py py/gadict_c5.py | dist/dictd
python3 -B py/gadict_c5.py $< $@
--- a/py/gadict_c5.py Sun Mar 27 23:59:21 2016 +0300
+++ b/py/gadict_c5.py Mon Mar 28 00:31:52 2016 +0300
@@ -12,11 +12,6 @@
foname = sys.argv[2]
fin = io.open(finame, mode='r', buffering=1, encoding="utf-8")
-if foname is None:
- fout = sys.stdout
-else:
- fout = open(foname, "w")
-
parser = gadict.Parser()
try:
@@ -30,17 +25,25 @@
finally:
fin.close()
+
prelude = dom[0]
-if prelude.name is not None:
- fout.write("_____\n\n00-database-short\n")
- fout.write(prelude.name)
- fout.write("\n")
-if len(prelude.urls) > 0:
- fout.write("_____\n\n00-database-url\n")
- for url in prelude.urls:
- fout.write(url)
- fout.write("\n")
-fout.write("_____\n\n00-database-info\n")
+
+with open(foname+".name", "w") as f: # for dictfmt -s
+ if prelude.name is not None:
+ f.write(prelude.name)
+ f.write("\n")
+
+with open(foname+".url", "w") as f: # for dictfmt -u
+ if len(prelude.urls) > 0:
+ f.write(prelude.urls[0])
+ f.write("\n")
+
+
+if foname is None:
+ fout = sys.stdout
+else:
+ fout = open(foname, "w")
+
if prelude.name is not None:
fout.write("Dictionary name: ")
fout.write(prelude.name)
@@ -50,6 +53,8 @@
fout.write("\n\n")
fout.write("Project licenses: ")
fout.write(", ".join(prelude.licences))
+fout.write("\n\n")
+fout.write(prelude.about)
fout.write("\n")
for idx in range(1, len(dom)):