Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from reinerh/master
Browse files Browse the repository at this point in the history
Use OrderedDict instead of sorting to keep reproducibility and preserve order
  • Loading branch information
Storyyeller committed Nov 19, 2015
2 parents bd05f5c + 11b65d5 commit a06efe5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions enjarify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import zipfile, traceback, argparse
import zipfile, traceback, argparse, collections

from . import parsedex
from .jvm import writeclass
Expand Down Expand Up @@ -46,7 +46,7 @@ def translate(data, opts, classes=None, errors=None):

def writeToJar(fname, classes):
with zipfile.ZipFile(fname, 'w') as out:
for unicode_name, data in sorted(classes.items()):
for unicode_name, data in classes.items():
# Don't bother compressing small files
compress_type = zipfile.ZIP_DEFLATED if len(data) > 10000 else zipfile.ZIP_STORED
out.writestr(zipfile.ZipInfo(unicode_name), data, compress_type=compress_type)
Expand Down Expand Up @@ -87,7 +87,8 @@ def main():
return

opts = options.NONE if args.fast else options.PRETTY
classes, errors = {}, {}
classes = collections.OrderedDict()
errors = {}
for data in dexs:
translate(data, opts=opts, classes=classes, errors=errors)
writeToJar(outfile, classes)
Expand Down

0 comments on commit a06efe5

Please sign in to comment.