forked from easyw/kicadStepUpMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utf8test.py
100 lines (91 loc) · 2.48 KB
/
utf8test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/python
# -*- coding: utf-8 -*-
import FreeCAD
import sys, os, re
def check_type(input):
if (sys.version_info > (3, 0)): #py3
if isinstance(input, str):
print('string')
return
else:
print('not string')
return
else: #py2
if type(input) != unicode:
print('string py2')
return
else:
print('not string py2')
return
def make_string(input):
if (sys.version_info > (3, 0)): #py3
if isinstance(input, str):
return input
else:
input = input.encode('utf-8')
return input
else: #py2
if type(input) == unicode:
input = input.encode('utf-8')
return input
else:
return input
def make_unicode(input):
if (sys.version_info > (3, 0)): #py3
if isinstance(input, str):
return input
else:
input = input.decode('utf-8')
return input
else: #py2
if type(input) != unicode:
input = input.decode('utf-8')
return input
else:
return input
##
prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/kicadStepUpGui")
models3D_prefix = prefs.GetString('prefix3d_1')
print (models3D_prefix)
check_type(models3D_prefix)
pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/kicadStepUp")
last_pcb_path = pg.GetString("last_pcb_path")
print(last_pcb_path)
pg.SetString("last_pcb_path",make_string(models3D_prefix))
print ('writing done')
check_type(last_pcb_path)
model1 = '10rx.wrl'
model_u=u'Würfel1.stp'
fullpath = os.path.join(make_unicode(last_pcb_path), make_unicode(model_u))
#fullpath3 = os.path.join(last_pcb_path, model_u)
print (fullpath)
check_type(fullpath)
newfullpath2 = make_unicode(fullpath)
print (newfullpath2)
check_type(newfullpath2)
if os.path.exists(newfullpath2):
print('file found MAKE UNICODE')
else:
print ('ERROR')
#fullpath = re.sub("\\", "/", fullpath)
fullpath = fullpath.replace('\\','/')
print (fullpath)
check_type(fullpath)
if os.path.exists(fullpath):
print('file found')
else:
print ('ERROR')
newfullpath = make_string(fullpath)
print (newfullpath)
check_type(newfullpath)
if os.path.exists(newfullpath):
print('file found')
else:
print ('ERROR')
fullpath = fullpath.replace('/','\\')
print (fullpath)
check_type(fullpath)
if os.path.exists(fullpath):
print('file found')
else:
print ('ERROR')