|
@@ -0,0 +1,93 @@
|
|
1
|
+#!/usr/bin/python
|
|
2
|
+
|
|
3
|
+import os
|
|
4
|
+import sys
|
|
5
|
+
|
|
6
|
+# Go to parent folder
|
|
7
|
+
|
|
8
|
+def usage():
|
|
9
|
+ print('')
|
|
10
|
+ print('USAGE: '+__file__+' <virtualenv_folder_path>')
|
|
11
|
+ print('')
|
|
12
|
+ print('')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+def show_help_and_exit():
|
|
16
|
+ usage()
|
|
17
|
+ exit()
|
|
18
|
+
|
|
19
|
+def on_result_and_exit(error_code):
|
|
20
|
+ if error_code==0:
|
|
21
|
+ print('')
|
|
22
|
+ print('')
|
|
23
|
+ exit(0)
|
|
24
|
+
|
|
25
|
+ print('ERRROR')
|
|
26
|
+ print('')
|
|
27
|
+ print('')
|
|
28
|
+ exit(error_code)
|
|
29
|
+
|
|
30
|
+#######
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+if len(sys.argv)<=1:
|
|
34
|
+ show_help_and_exit()
|
|
35
|
+
|
|
36
|
+########################################
|
|
37
|
+#
|
|
38
|
+# BELOW ARE STANDARD ACTIONS
|
|
39
|
+#
|
|
40
|
+########################################
|
|
41
|
+
|
|
42
|
+tg2env_path = sys.argv[1]
|
|
43
|
+
|
|
44
|
+print('PATCHING PYTHON CODE')
|
|
45
|
+print('--------------------')
|
|
46
|
+print('tg2env path: %s'%(tg2env_path))
|
|
47
|
+print('')
|
|
48
|
+
|
|
49
|
+patchable_paths = [
|
|
50
|
+ tg2env_path+'/lib/python3*/site-packages/tgext/pluggable',
|
|
51
|
+ tg2env_path+'/lib/python3*/site-packages/resetpassword',
|
|
52
|
+ tg2env_path+'/lib/python3*/site-packages/babel'
|
|
53
|
+]
|
|
54
|
+
|
|
55
|
+for patchable_path in patchable_paths:
|
|
56
|
+ print('2to3 conversion for %s...' % (patchable_path))
|
|
57
|
+ os.system('2to3 -w %s'%(patchable_path))
|
|
58
|
+ print('-> done')
|
|
59
|
+
|
|
60
|
+babel_source_code_patch_content = """--- tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-11-07 15:35:14.039913184 +0100
|
|
61
|
++++ tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-10-30 17:37:36.295091573 +0100
|
|
62
|
+@@ -384,8 +384,13 @@
|
|
63
|
+
|
|
64
|
+ def _write(text):
|
|
65
|
+ if isinstance(text, text_type):
|
|
66
|
+- text = text.encode(catalog.charset, 'backslashreplace')
|
|
67
|
+- fileobj.write(text)
|
|
68
|
++ pass
|
|
69
|
++ # text = text.encode(catalog.charset, 'backslashreplace')
|
|
70
|
++ try:
|
|
71
|
++ fileobj.write(text.encode('UTF-8'))
|
|
72
|
++ except Exception as e:
|
|
73
|
++ fileobj.write(text)
|
|
74
|
++
|
|
75
|
+
|
|
76
|
+ def _write_comment(comment, prefix=''):
|
|
77
|
+ # xgettext always wraps comments even if --no-wrap is passed;
|
|
78
|
+"""
|
|
79
|
+
|
|
80
|
+babel_patchable_file_path = tg2env_path+'/lib/python*/site-packages/babel/messages/pofile.py'
|
|
81
|
+print('Patching code in file %s...'%(babel_patchable_file_path))
|
|
82
|
+os.system('echo "%s"|patch -p1 %s'%(babel_source_code_patch_content, babel_patchable_file_path))
|
|
83
|
+print('-> done')
|
|
84
|
+
|
|
85
|
+resetpassword_patchable_file_path = tg2env_path+'/lib/python*/site-packages/resetpassword/lib/__init__.py'
|
|
86
|
+print('Patching code in file %s...'%(resetpassword_patchable_file_path))
|
|
87
|
+os.system("sed -i 's/body\.encode/body/g' %s" % (resetpassword_patchable_file_path))
|
|
88
|
+print('-> done')
|
|
89
|
+
|
|
90
|
+print('')
|
|
91
|
+print('')
|
|
92
|
+
|
|
93
|
+
|