<commit_before>#!/usr/bin/env python

import os
import click
import sys
import shutil

app_package = 'org.storymaker.app'
def build_patch(pack, old_zip, new_zip, patch_name):
    input_dir = 'assets'
    patch_dir = 'patch/%s' % pack
    #os.system('java -jar zipdiff.jar -file1 zips/%s.main.%s.obb -file2 assets/%s.main.%s.obb -outputfile diffs.html' % 
    #    (pack, old_version, pack, new_version))
    try:
        os.remove('diffs.html')
    except: 
        pass
    os.system('java -jar zipdiff.jar -file1 zips/%s -file2 zips/%s -outputfile diffs.html' % (old_zip, new_zip))

    try:
        shutil.rmtree(patch_dir)
    except:
        pass
    os.makedirs(patch_dir)

    from BeautifulSoup import BeautifulSoup
    with open('diffs.html') as f:
        soup = BeautifulSoup(f)
        
        tags = soup.findAll('td')
        
        i = iter(tags)
        for tag in i:
            #print tag
            if 'Removed (' in tag.text:
                pass # TODO we don't yet support removing files in our patches
            if 'Added (' in tag.text or 'Changed (' in tag.text:
                tag = next(i)
                tag = next(i)
                uls = tag.findAll('li')
                print uls
                for ul in uls:
                    dr = "%s/%s" % (patch_dir, os.path.dirname(ul.text))
                    print dr
                    
                    try: os.makedirs(dr) 
                    except Exception as e: print "e: %s" % e
                    shutil.copy("%s/%s" % (input_dir, ul.text), 
                                    "%s/%s" % (patch_dir, ul.text))
    os.system("rm patch/%s ; cd %s ; zip -n .mp4 -r %s %s ; mv %s .." 
        % (patch_name, patch_dir, patch_name, app_package, patch_name))

build_patch('burundi', 'burundi.main.2.obb', 'burundi.main.3.obb', 'burundi.patch.3.obb')
build_patch('learning_guide', 'learning_guide.main.1.obb', 'learning_guide.main.2.obb', 'learning_guide.patch.2.obb')
build_patch('default', 'main.1031.org.storymaker.app.obb', 'main.1044.org.storymaker.app.obb', 'patch.1044.org.storymaker.app.obb')
#build_patch('main', 2, 3)


#build_patch('persian')
#build_patch('assets', 'patch/mena')<commit_msg>update burundi v num<commit_after>#!/usr/bin/env python

import os
import click
import sys
import shutil

app_package = 'org.storymaker.app'
def build_patch(pack, old_zip, new_zip, patch_name):
    input_dir = 'assets'
    patch_dir = 'patch/%s' % pack
    try:
        os.remove('diffs.html')
    except: 
        pass
    os.system('java -jar zipdiff.jar -file1 zips/%s -file2 zips/%s -outputfile diffs.html' % (old_zip, new_zip))

    try:
        shutil.rmtree(patch_dir)
    except:
        pass
    os.makedirs(patch_dir)

    from BeautifulSoup import BeautifulSoup
    with open('diffs.html') as f:
        soup = BeautifulSoup(f)
        
        tags = soup.findAll('td')
        
        i = iter(tags)
        for tag in i:
            #print tag
            if 'Removed (' in tag.text:
                pass # TODO we don't yet support removing files in our patches
            if 'Added (' in tag.text or 'Changed (' in tag.text:
                tag = next(i)
                tag = next(i)
                uls = tag.findAll('li')
                print uls
                for ul in uls:
                    dr = "%s/%s" % (patch_dir, os.path.dirname(ul.text))
                    print dr
                    
                    try: os.makedirs(dr) 
                    except Exception as e: print "e: %s" % e
                    shutil.copy("%s/%s" % (input_dir, ul.text), 
                                    "%s/%s" % (patch_dir, ul.text))
    os.system("rm patch/%s ; cd %s ; zip -n .mp4 -r %s %s ; mv %s .." 
        % (patch_name, patch_dir, patch_name, app_package, patch_name))

build_patch('burundi', 'burundi.main.2.obb', 'burundi.main.4.obb', 'burundi.patch.4.obb')
build_patch('learning_guide', 'learning_guide.main.1.obb', 'learning_guide.main.2.obb', 'learning_guide.patch.2.obb')
build_patch('default', 'main.1031.org.storymaker.app.obb', 'main.1044.org.storymaker.app.obb', 'patch.1044.org.storymaker.app.obb')
{'fraction_non_alphanumeric': 0.13778100072516317, 'fraction_numerical': 0.011119168479574571, 'mean_word_length': 1.9285208775654636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '689794', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1380, 'n_words': 317}