From da885e07471e38f4e4b5da8b3e3ba67a6be4e4b1 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 23 May 2011 01:28:58 +0900 Subject: [PATCH] fix for python2 --- blender25-meshio/pymeshio/pmd.py | 29 +++++++++++++++++++++-------- test/mqo_test.pyc | Bin 489 -> 489 bytes 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/blender25-meshio/pymeshio/pmd.py b/blender25-meshio/pymeshio/pmd.py index d7a4a27..f9afcbd 100644 --- a/blender25-meshio/pymeshio/pmd.py +++ b/blender25-meshio/pymeshio/pmd.py @@ -1,19 +1,32 @@ # coding: utf-8 import os +import sys import struct from .mmd import * ############################################################################### # PMD ############################################################################### -def encode_string(src): - t=type(src) - if t==str: - return src.encode('cp932') - elif t==bytes: - return src - else: - raise "INVALID str: %s" % t +if sys.version_info[0]<3: + def encode_string(src): + t=type(src) + if t==unicode: + return src.encode('cp932') + elif t==str: + return src + else: + raise "INVALID str: %s" % t + + +else: + def encode_string(src): + t=type(src) + if t==str: + return src.encode('cp932') + elif t==bytes: + return src + else: + raise "INVALID str: %s" % t class Vertex(object): diff --git a/test/mqo_test.pyc b/test/mqo_test.pyc index ce866e49ba58f87345b215567367bb6a7330eb3d..447c5a9156f498bca657e31d86dfa014e5f94b14 100755 GIT binary patch delta 16 YcmaFK{F0fS`7