How to use the ufonormalizer.main function in ufonormalizer

To help you get started, we’ve selected a few ufonormalizer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_invalid_float_precision(self):
        stream = StringIO()
        with TemporaryDirectory(suffix=".ufo") as tmp:
            with self.assertRaisesRegex(SystemExit, '2'):
                with redirect_stderr(stream):
                    main(['--float-precision', '-10', tmp])
        self.assertTrue("float precision must be >= 0" in stream.getvalue())
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_input_not_ufo(self):
        # I use the path to the test module itself
        existing_not_ufo_file = os.path.realpath(__file__)
        stream = StringIO()
        with self.assertRaisesRegex(SystemExit, '2'):
            with redirect_stderr(stream):
                main([existing_not_ufo_file])
        self.assertTrue("Input path is not a UFO" in stream.getvalue())
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_invalid_float_precision(self):
        stream = StringIO()
        with TemporaryDirectory(suffix=".ufo") as tmp:
            with self.assertRaisesRegex(SystemExit, '2'):
                with redirect_stderr(stream):
                    main(['--float-precision', '-10', tmp])
        self.assertTrue("float precision must be >= 0" in stream.getvalue())
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
org.robofab.fontlab.customdata
                <data>
                gAJ9cQFVA2xpYnECY3BsaXN0bGliCl9JbnRlcm5hbERpY3QKcQMpgXEEVSdj
                b20uc2NocmlmdGdlc3RhbHR1bmcuR2x5cGhzLmxhc3RDaGFuZ2VxBVUTMjAx
                Ny8wOS8yNiAwOToxMzoyMXEGc31xB2JzLg==
                </data>
            
        
        """
        with TemporaryDirectory(suffix=".ufo") as indir:
            outdir = os.path.join(indir, 'output.ufo')

            subpathWriteFile(metainfo, indir, "metainfo.plist")
            subpathWriteFile(libdata, indir, "lib.plist")

            main(["-o", outdir, indir])
            data = subpathReadPlist(outdir, "lib.plist")
            self.assertEqual(
                data['org.robofab.fontlab.customdata'],
                base64.b64decode("""\
                gAJ9cQFVA2xpYnECY3BsaXN0bGliCl9JbnRlcm5hbERpY3QKcQMpgXEEVSdj
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
0.3333333333333334
            
        
        """
        with TemporaryDirectory(suffix=".ufo") as indir:
            outdir = os.path.join(indir, 'output.ufo')

            subpathWriteFile(metainfo, indir, "metainfo.plist")
            subpathWriteFile(libdata, indir, "lib.plist")

            # without --float-precision, it uses 10 decimal digits by default
            main(["-o", outdir, indir])
            data = subpathReadPlist(outdir, "lib.plist")
            self.assertEqual(data["test_float"], 0.3333333333)

            main(["-o", outdir, "--float-precision=0", indir])
            data = subpathReadPlist(outdir, "lib.plist")
            self.assertEqual(data["test_float"], 0)

            main(["-o", outdir, "--float-precision=6", indir])
            data = subpathReadPlist(outdir, "lib.plist")
            self.assertEqual(data["test_float"], 0.333333)

            # -1 means no rounding, use repr()
            main(["-o", outdir, "--float-precision=-1", indir])
            data = subpathReadPlist(outdir, "lib.plist")
            self.assertEqual(data["test_float"], 0.3333333333333334)
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_no_path(self):
        stream = StringIO()
        with self.assertRaisesRegex(SystemExit, '2'):
            with redirect_stderr(stream):
                main([])
        self.assertTrue("No input path" in stream.getvalue())
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_metainfo_no_formatVersion(self):
        metainfo = EMPTY_PLIST
        with TemporaryDirectory(suffix=".ufo") as tmp:
            with open(os.path.join(tmp, "metainfo.plist"), 'w') as f:
                f.write(metainfo)
            with self.assertRaisesRegex(
                    UFONormalizerError, 'Required formatVersion value not defined'):
                main([tmp])
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
org.robofab.fontlab.customdata
                <data>
                gAJ9cQFVA2xpYnECY3BsaXN0bGliCl9JbnRlcm5hbERpY3QKcQMpgXEEVSdj
                b20uc2NocmlmdGdlc3RhbHR1bmcuR2x5cGhzLmxhc3RDaGFuZ2VxBVUTMjAx
                Ny8wOS8yNiAwOToxMzoyMXEGc31xB2JzLg==
                </data>
            
        
        """
        with TemporaryDirectory(suffix=".ufo") as indir:
            outdir = os.path.join(indir, 'output.ufo')

            subpathWriteFile(metainfo, indir, "metainfo.plist")
            subpathWriteFile(libdata, indir, "lib.plist")

            main(["-o", outdir, indir])
            data = subpathReadPlist(outdir, "lib.plist")
            self.assertEqual(
                data['org.robofab.fontlab.customdata'],
                base64.b64decode("""\
                gAJ9cQFVA2xpYnECY3BsaXN0bGliCl9JbnRlcm5hbERpY3QKcQMpgXEEVSdj
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_input_does_not_exist(self):
        stream = StringIO()
        with self.assertRaisesRegex(SystemExit, '2'):
            with redirect_stderr(stream):
                main(['foobarbazquz'])
        self.assertTrue("Input path does not exist" in stream.getvalue())
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_main_no_path(self):
        stream = StringIO()
        with self.assertRaisesRegex(SystemExit, '2'):
            with redirect_stderr(stream):
                main([])
        self.assertTrue("No input path" in stream.getvalue())