Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup two failing tests after locale update #72

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions processor-tests/humans/label_EditorTranslator1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bibliography

>>===== RESULT =====>>
<div class="csl-bib-body">
<div class="csl-entry">1. Иванов И.И. Пример оформления книги с редактором и переводчиком в одном лице : вид издания : in 5 vols. Vol. 2 / И.И. Иванов, П.П. Петров, С.С. Сидоров; ed &#38; trans. Р.Р. Романов Дополнительно. – Тюмень: Дом, 2013. – No. 10. – 100 p.</div>
<div class="csl-entry">1. Иванов И.И. Пример оформления книги с редактором и переводчиком в одном лице : вид издания : in 5 vols. Vol. 2 / И.И. Иванов, П.П. Петров, С.С. Сидоров; ed &#38; trans. Р.Р. Романов Дополнительно. – Тюмень: Дом, 2013. – No. 10. – 100 p.</div>
</div>
<<===== RESULT =====<<

Expand Down Expand Up @@ -610,4 +610,3 @@ _______________________________________________________________________________
>>===== VERSION =====>>
1.0
<<===== VERSION =====<<

5 changes: 2 additions & 3 deletions processor-tests/humans/label_MissingReturnsEmpty.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ citation
<<==== MODE ====<<

>>==== RESULT ====>>
Aalto, 23
Aalto
<<==== RESULT ====<<

>>==== CITATION-ITEMS ====>>
Expand All @@ -17,7 +17,7 @@ Aalto, 23
<<==== CITATION-ITEMS ====<<

>>==== CSL ====>>
<style
<style
xmlns="http://purl.org/net/xbiblio/csl"
class="note"
version="1.0">
Expand Down Expand Up @@ -63,4 +63,3 @@ Aalto, 23
>>===== VERSION =====>>
1.0
<<===== VERSION =====<<

39 changes: 39 additions & 0 deletions processor-tests/machines/bugreports_SingleQuoteXml.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion processor-tests/machines/label_EditorTranslator1.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}
],
"mode": "bibliography",
"result": "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\">1.\tИванов И.И. Пример оформления книги с редактором и переводчиком в одном лице : вид издания : in 5 vols. Vol. 2 / И.И. Иванов, П.П. Петров, С.С. Сидоров; ed &#38; trans. Р.Р. Романов Дополнительно. – Тюмень: Дом, 2013. – 10. – 100 p.</div>\n</div>",
"result": "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\">1.\tИванов И.И. Пример оформления книги с редактором и переводчиком в одном лице : вид издания : in 5 vols. Vol. 2 / И.И. Иванов, П.П. Петров, С.С. Сидоров; ed &#38; trans. Р.Р. Романов Дополнительно. – Тюмень: Дом, 2013. – No. 10. – 100 p.</div>\n</div>",
"tags": false,
"version": "1.0"
}
5 changes: 2 additions & 3 deletions processor-tests/machines/label_MissingReturnsEmpty.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
]
],
"citations": false,
"csl": "<style \n xmlns=\"http://purl.org/net/xbiblio/csl\"\n class=\"note\"\n version=\"1.0\">\n <info>\n <id />\n <title />\n <updated>2009-08-10T04:49:00+09:00</updated>\n </info>\n <!-- locale>\n <term name=\"number\">nummie</term>\n </locale -->\n <macro name=\"author\">\n <names variable=\"author\">\n <name form=\"short\" />\n </names>\n </macro>\n <citation>\n <layout delimiter=\"; \">\n <text macro=\"author\" />\n <group delimiter=\" \" prefix=\", \">\n <text term=\"number\"/>\n <number variable=\"collection-number\"/>\n </group>\n </layout>\n </citation>\n</style>",
"csl": "<style\n xmlns=\"http://purl.org/net/xbiblio/csl\"\n class=\"note\"\n version=\"1.0\">\n <info>\n <id />\n <title />\n <updated>2009-08-10T04:49:00+09:00</updated>\n </info>\n <!-- locale>\n <term name=\"number\">nummie</term>\n </locale -->\n <macro name=\"author\">\n <names variable=\"author\">\n <name form=\"short\" />\n <label form=\"long\" prefix=\", \"/>\n </names>\n </macro>\n <citation>\n <layout delimiter=\"; \">\n <text macro=\"author\" />\n </layout>\n </citation>\n</style>",
"input": [
{
"author": [
Expand All @@ -19,13 +19,12 @@
"given": "Alan"
}
],
"collection-number": 23,
"id": "ITEM-1",
"type": "book"
}
],
"mode": "citation",
"result": "Aalto, 23",
"result": "Aalto",
"tags": false,
"version": "1.0"
}
24 changes: 12 additions & 12 deletions processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def fixEndings(s):
class ApplyLicense:

def __init__(self):
self.rex = "(?sm)^^(/\*.*?^\s*\*/\n*)(.*)"
self.rex = r"(?sm)^^(/\*.*?^\s*\*/\n*)(.*)"
m = re.match(self.rex, fixEndings(open( os.path.join("src","load.js")).read()) )
if m:
self.license = "%s\n" % m.group(1).strip()
Expand Down Expand Up @@ -227,7 +227,7 @@ def __init__(self,opt,cp,hpath,testname,pos=0):
self.CREATORS = ["author","editor","translator","recipient","interviewer"]
self.CREATORS += ["composer","original-author","container-author","collection-editor"]
self.RE_ELEMENT = '(?sm)^(.*>>=[^\n]*%s[^\n]+)(.*)(\n<<=.*%s.*)'
self.RE_FILENAME = '^[a-z]+_[a-zA-Z0-9]+\.txt$'
self.RE_FILENAME = r"^[a-z]+_[a-zA-Z0-9]+\.txt$"
self.script = os.path.split(sys.argv[0])[1]
self.pickle = ".".join((os.path.splitext( self.script )[0], "pkl"))
self.data = {}
Expand Down Expand Up @@ -330,7 +330,7 @@ def validate(self):
tfd,tfilename = tempfile.mkstemp(dir=".")
os.write(tfd,self.data["csl"].encode('utf8'))
os.close(tfd)

jfh = os.popen("%s %s -c %s %s" % (self.cp.get("jing", "command"), self.cp.get("jing", "path"),rnc_path,tfilename))
success = True
plural = ""
Expand All @@ -344,13 +344,13 @@ def validate(self):
sys.exit()
m = re.match(".*:([0-9]+):([0-9]+): *error:(.*)",line)
if m:
if success:
print("\n##")
print("#### Error%s in CSL for test: %s" % (plural,self.hp))
print("##\n")
success = False
print(" %s @ line %s" %(m.group(3).upper(),m.group(1)))
plural = "s"
if success:
print("\n##")
print("#### Error%s in CSL for test: %s" % (plural,self.hp))
print("##\n")
success = False
print(" %s @ line %s" %(m.group(3).upper(),m.group(1)))
plural = "s"
jfh.close()
os.unlink(tfilename)
if not success:
Expand All @@ -370,8 +370,8 @@ def validate(self):

pickler.dump( (opt, self.pos) )
sys.exit()


if __name__ == "__main__":

from optparse import OptionParser
Expand Down