How to use the ufonormalizer.subpathWriteFile 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_subpathWriteFile(self):
        expected_text = 'foo bar™⁜'
        subpathWriteFile(expected_text, self.directory, self.filename)
        with open(self.filepath, 'r', encoding='utf-8') as f:
            text = f.read()
        self.assertEqual(text, expected_text)
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def _test_normalizeGlyphNames(self, oldGlyphMapping, expectedGlyphMapping):
        import tempfile
        directory = tempfile.mkdtemp()
        layerDirectory = "glyphs"
        fullLayerDirectory = subpathJoin(directory, layerDirectory)
        os.mkdir(fullLayerDirectory)
        for fileName in oldGlyphMapping.values():
            subpathWriteFile("", directory, layerDirectory, fileName)
        self.assertEqual(sorted(os.listdir(fullLayerDirectory)),
                         sorted(oldGlyphMapping.values()))
        subpathWritePlist(oldGlyphMapping, directory, layerDirectory,
                          "contents.plist")
        newGlyphMapping = normalizeGlyphNames(directory, layerDirectory)
        listing = os.listdir(fullLayerDirectory)
        listing.remove("contents.plist")
        self.assertEqual(sorted(listing), sorted(newGlyphMapping.values()))
        self.assertEqual(
            subpathReadPlist(directory, layerDirectory, "contents.plist"),
            newGlyphMapping)
        shutil.rmtree(directory)
        return newGlyphMapping == expectedGlyphMapping
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_subpathWriteFile(self):
        expected_text = 'foo bar™⁜'
        subpathWriteFile(expected_text, self.directory, self.filename)
        with open(self.filepath, 'r', encoding='utf-8') as f:
            text = f.read()
        self.assertEqual(text, expected_text)
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def test_subpathWriteFile_newline(self):
        mixed_eol_text = 'foo\r\nbar\nbaz\rquz'
        expected_text = 'foo\nbar\nbaz\nquz'
        subpathWriteFile(mixed_eol_text, self.directory, self.filename)
        with open(self.filepath, 'r', encoding='utf-8') as f:
            text = f.read()
        self.assertEqual(text, expected_text)
github unified-font-object / ufoNormalizer / tests / test_ufonormalizer.py View on Github external
def _test_normalizeGlyphNames(self, oldGlyphMapping, expectedGlyphMapping):
        import tempfile
        directory = tempfile.mkdtemp()
        layerDirectory = "glyphs"
        fullLayerDirectory = subpathJoin(directory, layerDirectory)
        os.mkdir(fullLayerDirectory)
        for fileName in oldGlyphMapping.values():
            subpathWriteFile("", directory, layerDirectory, fileName)
        self.assertEqual(sorted(os.listdir(fullLayerDirectory)),
                         sorted(oldGlyphMapping.values()))
        subpathWritePlist(oldGlyphMapping, directory, layerDirectory,
                          "contents.plist")
        newGlyphMapping = normalizeGlyphNames(directory, layerDirectory)
        listing = os.listdir(fullLayerDirectory)
        listing.remove("contents.plist")
        self.assertEqual(sorted(listing), sorted(newGlyphMapping.values()))
        self.assertEqual(
            subpathReadPlist(directory, layerDirectory, "contents.plist"),
            newGlyphMapping)
        shutil.rmtree(directory)
        return newGlyphMapping == expectedGlyphMapping
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_float_precision_argument(self):
        metainfo = METAINFO_PLIST % 3
        libdata = """
        
        
            
                test_float
                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()
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