Пример #1
0
 def get_font(self):
     use_most_recent_export = bpy.context.window_manager.converter_props.use_most_recent_export
     otf_file_path = bpy.context.window_manager.converter_props.otf_file_path
     most_recent_otf_export_path = bpy.context.window_manager.converter_props.most_recent_otf_export_path
     otf_path = ensure_ext(
         abspath(most_recent_otf_export_path
                 if use_most_recent_export else otf_file_path), ".otf")
     try:
         f = open(otf_path, 'rb')
     except OSError:
         return self.send_error(HTTPStatus.NOT_FOUND, "File not found")
     try:
         fs = fstat(f.fileno())
         self.send_response_only(HTTPStatus.OK)
         self.send_header("Content-type", "font/otf")
         self.send_header("Cache-Control", "no-store")
         self.send_header("Content-Length", str(fs[6]))
         self.end_headers()
     except:
         f.close()
         raise
     try:
         self.send_file(f, self.wfile)
     finally:
         f.close()
     return
Пример #2
0
    def execute(self, context):
        from . import operators

        filepath = self.filepath
        filepath = path.ensure_ext(filepath, self.filename_ext)

        return operators.export_to_splash(self, context, filepath)
Пример #3
0
    def test_ensure_ext(self):
        from bpy.path import ensure_ext

        # Should work with both strings and bytes.
        self.assertEqual(ensure_ext('demo', '.blend'), 'demo.blend')
        self.assertEqual(ensure_ext(b'demo', b'.blend'), b'demo.blend')

        # Test different cases.
        self.assertEqual(ensure_ext('demo.blend', '.blend'), 'demo.blend')
        self.assertEqual(ensure_ext('demo.BLEND', '.blend'), 'demo.BLEND')
        self.assertEqual(ensure_ext('demo.blend', '.BLEND'), 'demo.blend')

        # Test empty extensions, compound extensions etc.
        self.assertEqual(ensure_ext('demo', 'blend'), 'demoblend')
        self.assertEqual(ensure_ext('demo', ''), 'demo')
        self.assertEqual(ensure_ext('demo', '.json.gz'), 'demo.json.gz')
        self.assertEqual(ensure_ext('demo.json.gz', '.json.gz'),
                         'demo.json.gz')
        self.assertEqual(ensure_ext('demo.json', '.json.gz'),
                         'demo.json.json.gz')
        self.assertEqual(ensure_ext('', ''), '')
        self.assertEqual(ensure_ext('', '.blend'), '.blend')

        # Test case-sensitive behavior.
        self.assertEqual(ensure_ext('demo', '.blend', case_sensitive=True),
                         'demo.blend')
        self.assertEqual(
            ensure_ext('demo.BLEND', '.blend', case_sensitive=True),
            'demo.BLEND.blend')
        self.assertEqual(ensure_ext('demo', 'Blend', case_sensitive=True),
                         'demoBlend')
        self.assertEqual(ensure_ext('demoBlend', 'blend', case_sensitive=True),
                         'demoBlendblend')
        self.assertEqual(ensure_ext('demo', '', case_sensitive=True), 'demo')
Пример #4
0
    def test_ensure_ext(self):
        from bpy.path import ensure_ext

        # Should work with both strings and bytes.
        self.assertEqual(ensure_ext('demo', '.blend'), 'demo.blend')
        self.assertEqual(ensure_ext(b'demo', b'.blend'), b'demo.blend')

        # Test different cases.
        self.assertEqual(ensure_ext('demo.blend', '.blend'), 'demo.blend')
        self.assertEqual(ensure_ext('demo.BLEND', '.blend'), 'demo.BLEND')
        self.assertEqual(ensure_ext('demo.blend', '.BLEND'), 'demo.blend')

        # Test empty extensions, compound extensions etc.
        self.assertEqual(ensure_ext('demo', 'blend'), 'demoblend')
        self.assertEqual(ensure_ext('demo', ''), 'demo')
        self.assertEqual(ensure_ext('demo', '.json.gz'), 'demo.json.gz')
        self.assertEqual(ensure_ext('demo.json.gz', '.json.gz'), 'demo.json.gz')
        self.assertEqual(ensure_ext('demo.json', '.json.gz'), 'demo.json.json.gz')
        self.assertEqual(ensure_ext('', ''), '')
        self.assertEqual(ensure_ext('', '.blend'), '.blend')

        # Test case-sensitive behaviour.
        self.assertEqual(ensure_ext('demo', '.blend', True), 'demo.blend')
        self.assertEqual(ensure_ext('demo.BLEND', '.blend', True), 'demo.BLEND.blend')
        self.assertEqual(ensure_ext('demo', 'Blend', True), 'demoBlend')
        self.assertEqual(ensure_ext('demoBlend', 'blend', True), 'demoBlendblend')
        self.assertEqual(ensure_ext('demo', '', True), 'demo')