mirror of
https://github.com/KanjiVG/kanjivg.git
synced 2026-04-19 20:10:42 +02:00
Release files now named after date of creation
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@
|
||||
kanjivg.xml
|
||||
*.pyc
|
||||
currentdata
|
||||
Main.MissingKanji
|
||||
Main.StrokeCountMismatch
|
||||
kanjivg-????????.xml.gz
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, codecs, xml.sax, datetime
|
||||
import os, codecs, xml.sax, datetime, sys
|
||||
from kanjivg import *
|
||||
|
||||
def createSVG(out, kanji):
|
||||
@@ -43,7 +43,7 @@ kanjivg:type CDATA #IMPLIED >
|
||||
|
||||
if __name__ == "__main__":
|
||||
handler = KanjisHandler()
|
||||
xml.sax.parse("kanjivg.xml", handler)
|
||||
xml.sax.parse(sys.argv[1], handler)
|
||||
kanjis = handler.kanjis.values()
|
||||
|
||||
for kanji in kanjis:
|
||||
|
||||
@@ -327,6 +327,7 @@ class KanjisHandler(BasicHandler):
|
||||
self.kanjis = {}
|
||||
self.currentKanji = None
|
||||
self.groups = []
|
||||
self.metComponents = set()
|
||||
|
||||
def handle_start_kanji(self, attrs):
|
||||
id = str(attrs["id"])
|
||||
@@ -366,6 +367,9 @@ class KanjisHandler(BasicHandler):
|
||||
|
||||
self.groups.append(group)
|
||||
|
||||
if group.element: self.metComponents.add(group.element)
|
||||
if group.original: self.metComponents.add(group.original)
|
||||
|
||||
if group.number:
|
||||
if not group.part: print "%s: Number specified, but part missing" % (self.currentKanji.id)
|
||||
# The group must exist already
|
||||
|
||||
26
mergexml.py
26
mergexml.py
@@ -41,6 +41,7 @@ if __name__ == "__main__":
|
||||
kanjis = []
|
||||
mismatch = []
|
||||
handled = set()
|
||||
metComponents = set()
|
||||
for f in files:
|
||||
# Let's skip the variations out of the process for now...
|
||||
if len(f) > 10: continue
|
||||
@@ -48,7 +49,7 @@ if __name__ == "__main__":
|
||||
if not f.endswith(".xml"): continue
|
||||
descHandler = KanjisHandler()
|
||||
xml.sax.parse(os.path.join("XML", f), descHandler)
|
||||
handled.add(f[:-4])
|
||||
handled.add(realchr(int(f[:-4], 16)))
|
||||
|
||||
parser = xml.sax.make_parser()
|
||||
svgHandler = KanjiStrokeHandler()
|
||||
@@ -59,6 +60,8 @@ if __name__ == "__main__":
|
||||
if os.path.exists(svgFile):
|
||||
parser.parse(svgFile)
|
||||
|
||||
metComponents = metComponents.union(descHandler.metComponents)
|
||||
|
||||
kanji = descHandler.kanjis.values()[0]
|
||||
desc = kanji.getStrokes()
|
||||
svg = svgHandler.strokes
|
||||
@@ -80,7 +83,7 @@ if __name__ == "__main__":
|
||||
if len(f) > 10: continue
|
||||
|
||||
if not f.endswith(".svg"): continue
|
||||
if f[:-4] in handled: continue
|
||||
if realchr(int(f[:-4], 16)) in handled: continue
|
||||
parser = xml.sax.make_parser()
|
||||
svgHandler = KanjiStrokeHandler()
|
||||
parser.setContentHandler(svgHandler)
|
||||
@@ -97,20 +100,31 @@ if __name__ == "__main__":
|
||||
kanji.root.childs.append(stroke)
|
||||
kanjis.append(kanji)
|
||||
|
||||
# Stroke count mismatch kanji
|
||||
mismatch.sort()
|
||||
misout = codecs.open("Main.StrokeCountMismatch", "w", "utf-8")
|
||||
misout.write('version=pmwiki-2.1.0 urlencoded=1\ntext=')
|
||||
misout.write("'''This page is generated - please do not edit it!'''%0a%0aThe following kanjis have a stroke order mismatch between their XML and SVG descriptions:%0a")
|
||||
misout.write("'''This page is generated - please do not edit it!'''%0a%0aThe following kanji have a stroke order mismatch between their XML and SVG descriptions:%0a")
|
||||
for i in range(len(mismatch)):
|
||||
misout.write("* %s: XML %d, SVG %d" % (mismatch[i][0], mismatch[i][1], mismatch[i][2]))
|
||||
misout.write("%0a")
|
||||
kanjis.sort(lambda x,y: cmp(x.id, y.id))
|
||||
|
||||
out = codecs.open("kanjivg.xml", "w", "utf-8")
|
||||
# Missing components
|
||||
misout = codecs.open("Main.MissingKanji", "w", "utf-8")
|
||||
misout.write('version=pmwiki-2.1.0 urlencoded=1\ntext=')
|
||||
misout.write("'''This page is generated - please do not edit it!'''%0a%0aThe following kanji are referenced as components but no data is available for them:%0a")
|
||||
for k in metComponents.difference(handled):
|
||||
misout.write("* %s" % (k,))
|
||||
misout.write("%0a")
|
||||
|
||||
# Finally write the output file
|
||||
curDate = str(datetime.date.today())
|
||||
kanjis.sort(lambda x,y: cmp(x.id, y.id))
|
||||
out = codecs.open("kanjivg-%s.xml" % (curDate.replace("-", ""),), "w", "utf-8")
|
||||
out.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
out.write("<!-- ")
|
||||
out.write(licenseString)
|
||||
out.write("\nThis file has been generated on %s, using the latest KanjiVG data to this date." % (datetime.date.today()))
|
||||
out.write("\nThis file has been generated on %s, using the latest KanjiVG data to this date." % (curDate))
|
||||
out.write("\n-->\n\n")
|
||||
out.write("<kanjis>\n");
|
||||
for kanji in kanjis:
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#!/bin/sh
|
||||
rm -Rf kanjivg.xml.gz generated
|
||||
./mergexml.py
|
||||
outFile="kanjivg-`date +\"%Y%m%d\"`.xml"
|
||||
mkdir -p currentdata/SVG
|
||||
./createsvgfiles.py
|
||||
./createsvgfiles.py $outFile
|
||||
tar czf currentdata.tar.gz currentdata
|
||||
gzip kanjivg.xml
|
||||
scp kanjivg.xml.gz gnurou@gnurou.org:/srv/http/kanjivg/upload/Main/kanjivg-latest.xml.gz
|
||||
gzip $outFile
|
||||
scp $outFile.gz gnurou@gnurou.org:/srv/http/kanjivg/upload/Main/
|
||||
scp currentdata.tar.gz gnurou@gnurou.org:/home/gnurou
|
||||
scp Main.StrokeCountMismatch gnurou@gnurou.org:/srv/http/kanjivg/wiki.d
|
||||
ssh gnurou@gnurou.org "cd /srv/http/kanjivg ; rm -Rf currentdata ; tar xfz /home/gnurou/currentdata.tar.gz ; rm /home/gnurou/currentdata.tar.gz"
|
||||
scp Main.StrokeCountMismatch Main.MissingKanji gnurou@gnurou.org:/srv/http/kanjivg/wiki.d
|
||||
ssh gnurou@gnurou.org "cd /srv/http/kanjivg ; rm -Rf currentdata ; tar xfz /home/gnurou/currentdata.tar.gz ; rm /home/gnurou/currentdata.tar.gz ; cd upload/Main ; ln -sf $outFile.gz kanjivg-latest.xml-gz"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user