-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsendExtension.py
More file actions
45 lines (35 loc) · 1.24 KB
/
sendExtension.py
File metadata and controls
45 lines (35 loc) · 1.24 KB
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
from distutils.dir_util import copy_tree
import os
import sys
import string
import shutil
if os.path.exists('../extension'):
shutil.rmtree('../extension')
os.remove('../extension.zip')
print('Cleaning old stuff')
os.makedirs('../extension')
copy_tree('../YourAutoLiker', '../extension')
print('Copying the extension folder')
shutil.rmtree('../extension/docs')
os.remove('../extension/sendExtension.py')
print('Removing website folder')
def inplace_change(filename, old_string, new_string):
# Safely read the input filename using 'with'
with open(filename) as f:
s = f.read()
if old_string not in s:
print('No ocurrences on {filename}.'.format(**locals()))
return
# Safely write the changed content, if found in the file
with open(filename, 'w') as f:
print(
'Replaced in {filename}'.format(**locals()))
s = s.replace(old_string, new_string)
f.write(s)
for root, dirs, files in os.walk("../extension"):
for file in files:
if file.endswith(".js"):
inplace_change(os.path.join(root, file),
'console.log', '//console.log')
shutil.make_archive('../extension', 'zip', '../extension')
print('creating zip file')