[utils.miner] Improved output with colouring in python scripts
This commit is contained in:
parent
676cd2bf65
commit
d89bd44f8b
|
@ -7,12 +7,12 @@ import os
|
|||
import sys
|
||||
|
||||
# Tool libs
|
||||
from utils import run, sanitize
|
||||
import utils
|
||||
import conf
|
||||
from objects import GameBlock
|
||||
|
||||
|
||||
print("=> Phase: blocks")
|
||||
utils.title('BLOCKS')
|
||||
if conf.SAVE:
|
||||
sys.path.append('../../minecraftcodex')
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'local_settings'
|
||||
|
@ -26,10 +26,10 @@ BLOCKS = []
|
|||
###
|
||||
# LOOK FOR CORRECT JAVA FILES
|
||||
###
|
||||
print(" => Looking for java files...")
|
||||
print(" Keywords: %s" % ', '.join(conf.BLOCKS_JAVA_KEYWORDS))
|
||||
utils.sub("Looking for java files...")
|
||||
#utils.sub("Keywords: %s" % ', '.join(conf.BLOCKS_JAVA_KEYWORDS), end='\n')
|
||||
for keyword in conf.BLOCKS_JAVA_KEYWORDS:
|
||||
command = run('grep \'%s\' ./classes/*' % keyword)
|
||||
command = utils.run('grep \'%s\' ./classes/*' % keyword)
|
||||
lines = []
|
||||
[lines.append(x) for x in command]
|
||||
lines = ''.join(lines).split('\n')
|
||||
|
@ -37,13 +37,15 @@ for keyword in conf.BLOCKS_JAVA_KEYWORDS:
|
|||
if result and result is not '':
|
||||
java_file = os.path.basename(result.strip().split()[0][:-1])
|
||||
if java_file not in conf.BLOCKS_FILES:
|
||||
print(" Found: %s" % java_file)
|
||||
utils.echo("%s " % java_file, end='')
|
||||
conf.BLOCKS_FILES.append(java_file)
|
||||
|
||||
utils.echo('\r')
|
||||
|
||||
###
|
||||
# GET ITEMS INFO FROM CLASSFILE
|
||||
###
|
||||
print(" => Mining blocks...")
|
||||
utils.sub('Looking for dataz', end='\n')
|
||||
|
||||
# Old items for final count
|
||||
try:
|
||||
|
@ -67,7 +69,7 @@ for java_file in conf.BLOCKS_FILES:
|
|||
if conf.DEBUG:
|
||||
print("Line: " + item['code'])
|
||||
|
||||
item['code'] = sanitize(item['code'])
|
||||
item['code'] = utils.sanitize(item['code'])
|
||||
|
||||
if conf.DEBUG:
|
||||
print("Sanitize: " + item['code'])
|
||||
|
@ -110,21 +112,20 @@ if conf.SAVE:
|
|||
obj.save()
|
||||
|
||||
# Print the miner summary and compile the new old data
|
||||
print(' => Summary')
|
||||
new_old_data = {}
|
||||
new_old_data['list'] = []
|
||||
[new_old_data['list'].append(x.name) for x in BLOCKS]
|
||||
new_blocks = len(new_old_data['list'])-len(OLD_BLOCKS['list'])
|
||||
print(' Fetched %d blocks (%d new)' % (len(new_old_data['list']), new_blocks))
|
||||
if new_blocks > 0:
|
||||
print(' Modifications:')
|
||||
utils.info('Fetched %d blocks (%d new)' % (len(new_old_data['list']), new_blocks))
|
||||
if new_blocks != 0:
|
||||
utils.sub('Modifications:', end='\n')
|
||||
for item in BLOCKS:
|
||||
if item.name not in OLD_BLOCKS['list']:
|
||||
print(' + %s' % item.name)
|
||||
utils.sub(' + %s' % item.name, end='\n', color=utils.colors.GREEN)
|
||||
|
||||
for item in OLD_BLOCKS['list']:
|
||||
if item not in new_old_data['list']:
|
||||
print(' - %s' % item)
|
||||
utils.sub(' - %s' % item, end='\n', color=utils.colors.RED)
|
||||
|
||||
oldblocks = open('blocks.json', 'w')
|
||||
oldblocks.write(json.dumps(new_old_data))
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
JARFILE=$1
|
||||
|
||||
if [ "$JARFILE" != "" ]; then
|
||||
echo "=> Phase: JAR file"
|
||||
echo "[] Preparing files from JAR: $JARFILE []"
|
||||
# Remove old
|
||||
rm -rf ./jarfile ./classes
|
||||
|
||||
|
@ -13,18 +13,18 @@ if [ "$JARFILE" != "" ]; then
|
|||
mkdir classes
|
||||
|
||||
# Decompress the jarfile into the jarfile folder
|
||||
echo " => Unpackaging jar file"
|
||||
echo " Unpackaging jar file"
|
||||
unzip -qq $JARFILE -d ./jarfile
|
||||
|
||||
# Find all the classes and pass then through JAD
|
||||
#find . -type d -name *.class -exec rm -rf {} \;
|
||||
echo " => Decompiling classes"
|
||||
echo " Decompiling classes"
|
||||
ls ./jarfile/*.class | xargs -n1 ./tools/jad/jad -sjava -dclasses &> /dev/null
|
||||
|
||||
# Remove classfiles and left only other files
|
||||
echo " => Cleaning"
|
||||
echo " Cleaning"
|
||||
rm ./jarfile/*.class
|
||||
else
|
||||
echo "No jarfile specified."
|
||||
exit
|
||||
echo "[!] No jarfile specified!"
|
||||
exit -1
|
||||
fi
|
||||
|
|
|
@ -7,12 +7,12 @@ import os
|
|||
import sys
|
||||
|
||||
# Tool libs
|
||||
from utils import run, sanitize
|
||||
import utils
|
||||
import conf
|
||||
from objects import GameItem
|
||||
|
||||
|
||||
print("=> Phase: items")
|
||||
utils.title("ITEMS")
|
||||
|
||||
if conf.SAVE:
|
||||
sys.path.append('../../minecraftcodex')
|
||||
|
@ -27,21 +27,23 @@ ITEMS = []
|
|||
###
|
||||
# LOOK FOR CORRECT JAVA FILES
|
||||
###
|
||||
print(" => Looking for java files...")
|
||||
print(" Keywords: %s" % ', '.join(conf.ITEMS_JAVA_KEYWORDS))
|
||||
utils.sub("Looking for java files: ")
|
||||
#utils.sub("Keywords: %s" % ', '.join(conf.ITEMS_JAVA_KEYWORDS), end='\n')
|
||||
for keyword in conf.ITEMS_JAVA_KEYWORDS:
|
||||
cmd = run('grep \'%s\' ./classes/*' % keyword)
|
||||
cmd = utils.run('grep \'%s\' ./classes/*' % keyword)
|
||||
for result in cmd:
|
||||
if result and result is not '':
|
||||
java_file = os.path.basename(result.strip().split()[0][:-1])
|
||||
if java_file not in conf.ITEMS_FILES:
|
||||
print(" Found: %s" % java_file)
|
||||
utils.echo("%s " % java_file, end='')
|
||||
conf.ITEMS_FILES.append(java_file)
|
||||
|
||||
utils.echo('\r')
|
||||
|
||||
###
|
||||
# GET ITEMS INFO FROM CLASSFILE
|
||||
###
|
||||
print(" => Mining items...")
|
||||
utils.sub('Looking for dataz', end='\n')
|
||||
|
||||
# Old items for final count
|
||||
try:
|
||||
|
@ -65,7 +67,7 @@ for java_file in conf.ITEMS_FILES:
|
|||
if conf.DEBUG:
|
||||
print("Line: " + item['code'])
|
||||
|
||||
item['code'] = sanitize(item['code'])
|
||||
item['code'] = utils.sanitize(item['code'])
|
||||
|
||||
if conf.DEBUG:
|
||||
print("Sanitize: " + item['code'])
|
||||
|
@ -109,21 +111,20 @@ if conf.SAVE:
|
|||
|
||||
|
||||
# Print the miner summary and compile the new old data
|
||||
print(' => Summary')
|
||||
new_old_data = {}
|
||||
new_old_data['list'] = []
|
||||
[new_old_data['list'].append(x.name) for x in ITEMS]
|
||||
new_items = len(new_old_data['list'])-len(OLD_ITEMS['list'])
|
||||
print(' Fetched %d items (%d new)' % (len(ITEMS), new_items))
|
||||
if new_items > 0:
|
||||
print(' Modifications:')
|
||||
utils.info('Fetched %d items (%d new)' % (len(ITEMS), new_items))
|
||||
if new_items != 0:
|
||||
utils.sub('Modifications', end='\n')
|
||||
for item in ITEMS:
|
||||
if item.name not in OLD_ITEMS['list']:
|
||||
print(' + %s' % item.name)
|
||||
utils.sub(' + %s' % item.name, end='\n', color=utils.colors.GREEN)
|
||||
|
||||
for item in OLD_ITEMS['list']:
|
||||
if item not in new_old_data['list']:
|
||||
print(' - %s' % item)
|
||||
utils.sub(' - %s' % item, end='\n', color=utils.colors.RED)
|
||||
|
||||
olditems = open('items.json', 'w')
|
||||
olditems.write(json.dumps(new_old_data))
|
||||
|
|
|
@ -7,12 +7,12 @@ import os
|
|||
import sys
|
||||
|
||||
# Tool libs
|
||||
from utils import run, sanitize
|
||||
import utils
|
||||
import conf
|
||||
from objects import GameLanguage
|
||||
|
||||
|
||||
print("=> Phase: languages")
|
||||
utils.title('LANGUAGES')
|
||||
if conf.SAVE:
|
||||
sys.path.append('../../minecraftcodex')
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'local_settings'
|
||||
|
@ -28,9 +28,9 @@ LANGUAGES_STR = []
|
|||
###
|
||||
# LOOK FOR CORRECT JAVA FILES
|
||||
###
|
||||
print(" => Looking for languages files...")
|
||||
utils.sub("Looking for languages files:")
|
||||
directory_list = os.listdir(conf.LANGUAGES_PATH)
|
||||
print(" Found %d file(s)." % len(directory_list))
|
||||
utils.echo("found %d file(s)" % len(directory_list), end='\n')
|
||||
|
||||
###
|
||||
# GET LANGUAGES
|
||||
|
@ -44,7 +44,7 @@ try:
|
|||
except:
|
||||
OLD_LANGUAGES = []
|
||||
|
||||
print(" => Mining languages...")
|
||||
utils.sub('Looking for dataz', end='\n')
|
||||
for item in directory_list:
|
||||
if '.lang' in item:
|
||||
if conf.DEBUG:
|
||||
|
@ -103,23 +103,20 @@ if conf.SAVE:
|
|||
string_obj.save()
|
||||
|
||||
|
||||
|
||||
print(" => Summary")
|
||||
|
||||
# LANGUAGES
|
||||
[LANGUAGES_STR.append(x.name) for x in LANGUAGES]
|
||||
new_languages = len(LANGUAGES_STR) - len(OLD_LANGUAGES)
|
||||
print(" Found %d languages (%d new)." % (len(LANGUAGES_STR), new_languages))
|
||||
utils.info("Found %d languages (%d new)." % (len(LANGUAGES_STR), new_languages))
|
||||
if len(LANGUAGES_STR) != len(OLD_LANGUAGES):
|
||||
print(" Comparision:")
|
||||
utils.sub('Modifications:', end='\n')
|
||||
|
||||
for string in LANGUAGES_STR:
|
||||
if string not in OLD_LANGUAGES:
|
||||
print(" + %s" % string)
|
||||
for lang in LANGUAGES_STR:
|
||||
if lang not in OLD_LANGUAGES:
|
||||
utils.sub(' + %s' % lang, end='\n', color=utils.colors.GREEN)
|
||||
|
||||
for string in OLD_LANGUAGES:
|
||||
if string not in LANGUAGES_STR:
|
||||
print(" - %s" % string)
|
||||
for lang in OLD_LANGUAGES:
|
||||
if lang not in LANGUAGES_STR:
|
||||
utils.sub(' - %s' % lang, end='\n', color=utils.colors.RED)
|
||||
|
||||
olditems = open('languages.json', 'w')
|
||||
olditems.write(json.dumps(LANGUAGES_STR))
|
||||
|
@ -127,17 +124,17 @@ olditems.close()
|
|||
|
||||
# STRINGS
|
||||
new_strings = len(STRINGS) - len(OLD_STRINGS)
|
||||
print(" Found %d strings (%d new) -based on en_US-." % (len(STRINGS), new_strings))
|
||||
utils.info("Found %d strings (%d new) -based on en_US-." % (len(STRINGS), new_strings))
|
||||
if len(STRINGS) != len(OLD_STRINGS):
|
||||
print(" Comparision:")
|
||||
utils.sub('Modifications:', end='\n')
|
||||
|
||||
for string in STRINGS:
|
||||
if string not in OLD_STRINGS:
|
||||
print(" + %s" % string)
|
||||
utils.sub(' + %s' % string, end='\n', color=utils.colors.GREEN)
|
||||
|
||||
for string in OLD_STRINGS:
|
||||
if string not in STRINGS:
|
||||
print(" - %s" % string)
|
||||
utils.sub(' - %s' % string, end='\n', color=utils.colors.RED)
|
||||
|
||||
olditems = open('strings.json', 'w')
|
||||
olditems.write(json.dumps(STRINGS))
|
||||
|
|
|
@ -8,10 +8,11 @@ import json
|
|||
from PIL import Image
|
||||
|
||||
# Tool libs
|
||||
import utils
|
||||
import conf
|
||||
from objects import GameTexture
|
||||
|
||||
print("=> Phase: textures")
|
||||
utils.title("TEXTURES")
|
||||
|
||||
if conf.SAVE:
|
||||
path.append('../../minecraftcodex')
|
||||
|
@ -73,21 +74,22 @@ if conf.SAVE:
|
|||
)
|
||||
item.save()
|
||||
|
||||
print(' => Summary')
|
||||
|
||||
# SUMMARY
|
||||
new_old_data = {}
|
||||
new_old_data['list'] = []
|
||||
[new_old_data['list'].append(x.name) for x in TEXTURES]
|
||||
new_items = len(new_old_data['list'])-len(OLD_TEXTURES['list'])
|
||||
print(' Fetched %d textures (%d new)' % (len(TEXTURES), new_items))
|
||||
if new_items > 0:
|
||||
print(' Modifications:')
|
||||
utils.info('Fetched %d textures (%d new)' % (len(TEXTURES), new_items))
|
||||
if new_items != 0:
|
||||
utils.sub('Modifications', end='\n')
|
||||
for item in TEXTURES:
|
||||
if item.name not in OLD_TEXTURES['list']:
|
||||
print(' + %s' % item.name)
|
||||
utils.sub(' + %s' % item.name, end='\n', color=utils.colors.GREEN)
|
||||
|
||||
for item in OLD_TEXTURES['list']:
|
||||
if item not in new_old_data['list']:
|
||||
print(' - %s' % item)
|
||||
utils.sub(' - %s' % item, end='\n', color=utils.colors.RED)
|
||||
|
||||
olditems = open('textures.json', 'w')
|
||||
olditems.write(json.dumps(new_old_data))
|
||||
|
|
Loading…
Reference in New Issue