1
0

fix css_compress + include .idea/

This commit is contained in:
2018-01-19 22:49:46 +01:00
parent bfa6b89860
commit 40ca6e8d96
21 changed files with 227 additions and 9 deletions

View File

@@ -24,39 +24,64 @@ def countnl(str, start, end):
if (str[i] == '\n'): cnt = cnt+1;
return cnt;
finput = str.replace(sys.argv[1], '\\', '/')
foutput = str.replace(sys.argv[2], '\\', '/')
fsource = str.replace(sys.argv[1], '\\', '/') # scss
finput = str.replace(sys.argv[2], '\\', '/') # css
foutput = str.replace(sys.argv[3], '\\', '/') # min.css
ftemp = '__temp_compresss_py_yui.tmp.css';
print('======== INPUT ========');
print();
print(fsource);
print(finput);
print(foutput);
print();
print();
print('======== CALL SCSS ========');
out = subprocess.run(['C:/TOOLS/Ruby/bin/scss.bat', '--no-cache', '--update', fsource + ':' + finput], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print('> C:/TOOLS/Ruby/bin/scss.bat --no-cache --update ' + fsource + ':' + finput)
print('STDOUT:')
print(out.stdout.decode('utf-8'))
print('STDERR:')
print(out.stderr.decode('utf-8'))
print('======== CALL ========');
#os.system("java -jar yuicompressor.jar \""+finput+"\" -o \""+ftemp+"\"")
print('')
print('')
print('======== CALL YUI ========');
out = subprocess.run(['java', '-jar', 'yuicompressor.jar', finput, '-o', ftemp], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print('> java -jar yuicompressor.jar "'+finput+'" -o "'+ftemp+'"')
print('STDOUT:');
print(out.stdout.decode('utf-8'))
print('STDERR:');
print(out.stderr.decode('utf-8'))
print('')
print('')
print('======== READ ========');
with open(ftemp, 'r') as tf:
data = tf.read()
print('')
print('')
print('======== REM ========');
try:
os.remove(ftemp);
except e:
print(e)
print('')
print('')
print('======== REGEX ========');
data = re.sub(r'(\}*\})', '\g<1>\n', data);
print('')
print('')
print('======== MEDIA ========');
ins = []
for i in range(len(data)):
@@ -78,6 +103,13 @@ for i in range(len(data)):
for (l, c) in reversed(ins):
data = data[:l] + c + data[l:]
print('')
print('')
print('======== WRITE ========');
with open(foutput, "w") as tf:
tf.write(data)
tf.write(data)
print('')
print('')
print('Sinished.')