|
@@ -7,7 +7,7 @@ import sys
|
7
|
7
|
|
8
|
8
|
def usage():
|
9
|
9
|
print('')
|
10
|
|
- print('USAGE: '+__file__+' <virtualenv_folder_path>')
|
|
10
|
+ print('USAGE: '+__file__+' <step_1_or2> <site_packages_folder_path> ')
|
11
|
11
|
print('')
|
12
|
12
|
print('')
|
13
|
13
|
|
|
@@ -30,7 +30,7 @@ def on_result_and_exit(error_code):
|
30
|
30
|
#######
|
31
|
31
|
|
32
|
32
|
|
33
|
|
-if len(sys.argv)<=1:
|
|
33
|
+if len(sys.argv)<=2:
|
34
|
34
|
show_help_and_exit()
|
35
|
35
|
|
36
|
36
|
########################################
|
|
@@ -39,53 +39,60 @@ if len(sys.argv)<=1:
|
39
|
39
|
#
|
40
|
40
|
########################################
|
41
|
41
|
|
42
|
|
-tg2env_path = sys.argv[1]
|
|
42
|
+patch_step = sys.argv[1]
|
|
43
|
+sitepackages_path = sys.argv[2]
|
43
|
44
|
|
44
|
45
|
print('PATCHING PYTHON CODE')
|
45
|
46
|
print('--------------------')
|
46
|
|
-print('tg2env path: %s'%(tg2env_path))
|
|
47
|
+print('site packages path: %s'%(sitepackages_path))
|
47
|
48
|
print('')
|
48
|
49
|
|
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
|
|
-]
|
|
50
|
+if patch_step=='1':
|
|
51
|
+
|
|
52
|
+ patchable_paths = [
|
|
53
|
+ sitepackages_path+'/tgext/pluggable',
|
|
54
|
+ sitepackages_path+'/resetpassword',
|
|
55
|
+ sitepackages_path+'/babel'
|
|
56
|
+ ]
|
|
57
|
+
|
|
58
|
+ for patchable_path in patchable_paths:
|
|
59
|
+ print('2to3 conversion for %s...' % (patchable_path))
|
|
60
|
+ os.system('2to3 -w %s'%(patchable_path))
|
|
61
|
+ print('-> done')
|
|
62
|
+
|
|
63
|
+ babel_source_code_patch_content = """--- tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-11-07 15:35:14.039913184 +0100
|
|
64
|
+ +++ tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-10-30 17:37:36.295091573 +0100
|
|
65
|
+ @@ -384,8 +384,13 @@
|
|
66
|
+
|
|
67
|
+ def _write(text):
|
|
68
|
+ if isinstance(text, text_type):
|
|
69
|
+ - text = text.encode(catalog.charset, 'backslashreplace')
|
|
70
|
+ - fileobj.write(text)
|
|
71
|
+ + pass
|
|
72
|
+ + # text = text.encode(catalog.charset, 'backslashreplace')
|
|
73
|
+ + try:
|
|
74
|
+ + fileobj.write(text.encode('UTF-8'))
|
|
75
|
+ + except Exception as e:
|
|
76
|
+ + fileobj.write(text)
|
|
77
|
+ +
|
|
78
|
+
|
|
79
|
+ def _write_comment(comment, prefix=''):
|
|
80
|
+ # xgettext always wraps comments even if --no-wrap is passed;
|
|
81
|
+ """
|
|
82
|
+
|
|
83
|
+ babel_patchable_file_path = sitepackages_path+'/babel/messages/pofile.py'
|
|
84
|
+ print('Patching code in file %s...'%(babel_patchable_file_path))
|
|
85
|
+ os.system('echo "%s"|patch -p1 %s'%(babel_source_code_patch_content, babel_patchable_file_path))
|
|
86
|
+ print('-> done')
|
54
|
87
|
|
55
|
|
-for patchable_path in patchable_paths:
|
56
|
|
- print('2to3 conversion for %s...' % (patchable_path))
|
57
|
|
- os.system('2to3 -w %s'%(patchable_path))
|
|
88
|
+elif patch_step=='2':
|
|
89
|
+ resetpassword_patchable_file_path = sitepackages_path+'/resetpassword/lib/__init__.py'
|
|
90
|
+ print('Patching code in file %s...'%(resetpassword_patchable_file_path))
|
|
91
|
+ os.system("sed -i 's/body\.encode/body/g' %s" % (resetpassword_patchable_file_path))
|
58
|
92
|
print('-> done')
|
59
|
93
|
|
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')
|
|
94
|
+else:
|
|
95
|
+ show_help_and_exit()
|
89
|
96
|
|
90
|
97
|
print('')
|
91
|
98
|
print('')
|