Ejemplo n.º 1
0
def GenTestImage(coadef, svgfn, imgfn):
    curblazon = blazon.Blazon(coadef)
    shield = curblazon.GetShield()
    f = open(svgfn, "w")
    f.writelines(repr(shield))
    f.close()
    os.system("rsvg -w 100 " + svgfn + " " + imgfn)
Ejemplo n.º 2
0
 def testPunctuation(self):
     """Check that punctuation isn't stuck to tokens in a way that
     could confuse the parser."""
     import re
     test = blazon.Blazon("This, is, also, a test.")
     # Whatever the text normalizer done, it should not allow
     # punctuation to attach to a word.
     self.assertTrue(re.match("[a-z][\,\.]", test.GetBlazon()) is None)
Ejemplo n.º 3
0
 def testSVG(self):
     """Draw all good blazons from the test set, and check if they generate valid SVG."""
     testblazons = open("tests/blazons-good.txt", "r")
     for line in testblazons:
         line = line.strip()
         curblazon = blazon.Blazon(line)
         shield = curblazon.GetShield()
         if shield is not None:
             # If the shield *is* empty, it should be caught by other tests.
             try:
                 SVGisValid = self.ValidateXML(repr(shield))
             except SystemExit:
                 SVGisValid = False
             self.assertTrue(SVGisValid, "Invalid SVG for blazon: " + line)
Ejemplo n.º 4
0
 def testBlazon(self):
     line = "Purpure, a lozenge argent."
     curblazon = blazon.Blazon(line)            
     shield = curblazon.GetShield()
Ejemplo n.º 5
0
 def testCaps(self):
     """Check that blazons are properly de-capitalised after being input."""
     test = blazon.Blazon("This is a test")
     self.assertEqual(test.blazon, "this is a test")
Ejemplo n.º 6
0
def ParsesOK(line):
    """Since blazonry parsing is a moving target, this function should try to test if the blazon it gets will parse in whichever way is currently fashionable."""
    curblazon = blazon.Blazon(line)            
    shield = curblazon.GetShield()
    # YAPPS gives us None when it fails.
    return shield is not None
Ejemplo n.º 7
0
#!/usr/bin/python
"""Use this file for invocation from the command line.

Example:

python gen.py Azure a bend or.
"""

import blazon
import sys
import getopt

if __name__ == '__main__':
    (options, argv) = getopt.getopt(sys.argv[1:], "b:", ["base="])
    base = None
    for k, v in options:
        if k in ("-b", "--base"):
            base = v
    cmdlineinput = " ".join(argv)
    curblazon = blazon.Blazon(cmdlineinput, base=base)
    print curblazon.GetShield()
Ejemplo n.º 8
0
Archivo: gen.py Proyecto: clsn/pyblazon
#!/usr/bin/env python3
"""Use this file for invocation from the command line.

Example:

python gen.py Azure a bend or.
"""

import blazon
import sys
import getopt

if __name__ == '__main__':
    (options, argv) = getopt.getopt(sys.argv[1:], "nb:",
                                    ["no-outline", "base="])
    base = None
    outline = True
    for k, v in options:
        if k in ("-b", "--base"):
            base = v
        if k in ("-n", "--no-outline"):
            outline = False
    cmdlineinput = " ".join(argv)
    curblazon = blazon.Blazon(cmdlineinput, base=base, outline=outline)
    print(curblazon.GetShield())