~thestr4ng3r/mymcplus

72dd691180defb4dbaf3688d9fc4a1b745f4e1b1 — Florian Märkl 3 years ago c7795b4
Remove Compatibility Code
7 files changed, 24 insertions(+), 61 deletions(-)

M mymc/gui.py
M mymc/lzari.py
M mymc/mymc.py
M mymc/ps2mc.py
M mymc/ps2mc_ecc.py
M mymc/ps2save.py
M mymc/round.py
M mymc/gui.py => mymc/gui.py +0 -6
@@ 6,13 6,7 @@
#

"""Graphical user-interface for mymc."""
from __future__ import print_function
from __future__ import division

from future import standard_library
standard_library.install_aliases()
from builtins import range
from past.utils import old_div
_SCCS_ID = "@(#) mymc gui.py 1.4 12/10/04 18:51:51\n"

import os

M mymc/lzari.py => mymc/lzari.py +5 -13
@@ 10,12 10,7 @@ in Python.  Largely based on LZARI.C, one key difference is the use of
a two level dicitionary look up during compression rather than
LZARI.C's binary search tree.
"""
from __future__ import print_function
from __future__ import division

from builtins import range
from builtins import object
from past.utils import old_div
_SCCS_ID = "@(#) mysc lzari.py 1.6 12/10/04 19:07:53\n"

import sys


@@ 149,14 144,14 @@ class lzari_codec(object):
        self.position_cum = [0] * (HIST_LEN + 1)
        a = 0
        for i in range(HIST_LEN, 0, -1):
            a =  a + old_div(10000, (200 + i))
            a =  a + 10000 // (200 + i)
            self.position_cum[i - 1] = a
        
    def search(self, table, x):
        c = 1
        s = len(table) - 1
        while True:
            a = old_div((s + c), 2)
            a = (s + c) // 2
            if table[a] <= x:
                s = a
            else:


@@ 230,7 225,7 @@ class lzari_codec(object):
        
        _range = high - low
        max_cum_freq = sym_cum[MAX_CHAR]
        n = old_div(((code - low + 1) * max_cum_freq - 1), _range)
        n = ((code - low + 1) * max_cum_freq - 1) // _range
        i = bisect_right(sym_cum, n, 1)
        high = low + sym_cum[i] * _range // max_cum_freq
        low += sym_cum[i - 1] * _range // max_cum_freq


@@ 263,11 258,8 @@ class lzari_codec(object):
    def decode_position(self):
        _range = self.high - self.low
        max_cum = self.position_cum[0]
        pos = self.search(self.position_cum,
                  old_div(((self.code - self.low + 1)
                   * max_cum - 1), _range)) - 1
        self.high = (self.low +
                 self.position_cum[pos] * _range // max_cum)
        pos = self.search(self.position_cum, ((self.code - self.low + 1) * max_cum - 1) // _range) - 1
        self.high = (self.low + self.position_cum[pos] * _range // max_cum)
        self.low += self.position_cum[pos + 1] * _range // max_cum
        while True:
            if self.low < QUADRANT2:

M mymc/mymc.py => mymc/mymc.py +5 -13
@@ 6,14 6,7 @@
#

"""A utility for manipulating PS2 memory card images."""
from __future__ import print_function
from __future__ import division

from builtins import map
from builtins import str
from builtins import range
from past.utils import old_div
from builtins import object

_SCCS_ID = "@(#) mysc mymc.py 1.12 12/10/04 19:09:16\n"[:-1]

import sys


@@ 398,19 391,18 @@ def do_dir(cmd, mc, opts, args, opterr):
                
            print("%-32s %s" % (ent[8].decode("ascii"), title[0]))
            print ("%4dKB %-25s %s"
                   % (old_div(length, 1024), protection, title[1]))
                   % (length // 1024, protection, title[1]))
            print()
    finally:
        if f != None:
            f.close()
        dir.close()
        
    free = old_div(mc.get_free_space(), 1024)
    free = mc.get_free_space() // 1024
    if free > 999999:
        free = "%d,%03d,%03d" % (old_div(free, 1000000), free / 1000 % 1000,
                     free % 1000)
        free = "%d,%03d,%03d" % (free // 1000000, free // 1000 % 1000, free % 1000)
    elif free > 999:
        free = "%d,%03d" % (old_div(free, 1000), free % 1000)
        free = "%d,%03d" % (free // 1000, free % 1000)
    else:
        free = "%d" % free


M mymc/ps2mc.py => mymc/ps2mc.py +14 -21
@@ 6,14 6,7 @@
#

"""Manipulate PS2 memory card images."""
from __future__ import print_function
from __future__ import division

from builtins import str
from builtins import map
from builtins import range
from past.utils import old_div
from builtins import object

_SCCS_ID = "@(#) mysc ps2mc.py 1.10 12/10/04 19:10:35\n"

import sys


@@ 377,7 370,7 @@ class ps2mc_file(object):
        while size > 0:
            off = pos % cluster_size
            l = min(cluster_size - off, size)
            buf = self.read_file_cluster(old_div(pos, cluster_size))
            buf = self.read_file_cluster(pos // cluster_size)
            if buf == None:
                break
            if eol != None:


@@ 407,7 400,7 @@ class ps2mc_file(object):
        # print "@@@ write", pos, size
        i = 0
        while size > 0:
            cluster = old_div(pos, cluster_size)
            cluster = pos // cluster_size
            off = pos % cluster_size
            l = min(cluster_size - off, size)
            s = out[i : i + l]


@@ 524,10 517,10 @@ class ps2mc_directory(object):
        self.f.seek(offset * PS2MC_DIRENT_LENGTH, whence)

    def tell(self):
        return old_div(self.f.tell(), PS2MC_DIRENT_LENGTH)
        return self.f.tell() // PS2MC_DIRENT_LENGTH

    def __len__(self):
        return old_div(self.f.length, PS2MC_DIRENT_LENGTH)
        return self.f.length // PS2MC_DIRENT_LENGTH
    
    def __getitem__(self, index):
        # print "@@@ getitem", index, self.f.name


@@ 705,11 698,11 @@ class ps2mc(object):
        pages_per_card = round_down(param_pages_per_card,
                        pages_per_erase_block)
        cluster_size = PS2MC_CLUSTER_SIZE
        pages_per_cluster = old_div(cluster_size, page_size)
        clusters_per_erase_block = (old_div(pages_per_erase_block, pages_per_cluster))
        erase_blocks_per_card = old_div(pages_per_card, pages_per_erase_block)
        clusters_per_card = old_div(pages_per_card, pages_per_cluster)
        epc = old_div(cluster_size, 4)
        pages_per_cluster = cluster_size // page_size
        clusters_per_erase_block = pages_per_erase_block // pages_per_cluster
        erase_blocks_per_card = pages_per_card // pages_per_erase_block
        clusters_per_card = pages_per_card // pages_per_cluster
        epc = cluster_size // 4

        if (page_size < PS2MC_DIRENT_LENGTH
            or pages_per_cluster < 1


@@ 937,7 930,7 @@ class ps2mc(object):

    def read_fat_cluster(self, n):
        indirect_offset = n % self.entries_per_cluster
        dbl_offset = old_div(n, self.entries_per_cluster)
        dbl_offset = n // self.entries_per_cluster
        indirect_cluster = self.indirect_fat_cluster_list[dbl_offset]
        indirect_fat = self._read_fat_cluster(indirect_cluster)
        cluster = indirect_fat[indirect_offset]


@@ 949,7 942,7 @@ class ps2mc(object):
                     "FAT cluster index out of range"
                     " (%d)" % n)
        offset = n % self.entries_per_cluster
        fat_cluster = old_div(n, self.entries_per_cluster)
        fat_cluster = n // self.entries_per_cluster
        (fat, cluster) = self.read_fat_cluster(fat_cluster)
        return (fat, offset, cluster)



@@ 1246,8 1239,8 @@ class ps2mc(object):
        self.update_dirent_all(dirloc, None, ent)
        
        while cluster != PS2MC_FAT_CHAIN_END:
            if old_div(cluster, epc) < self.fat_cursor:
                self.fat_cursor = old_div(cluster, epc)
            if cluster // epc < self.fat_cursor:
                self.fat_cursor = cluster // epc
            next_cluster = self.lookup_fat(cluster)
            if next_cluster & PS2MC_FAT_ALLOCATED_BIT == 0:
                # corrupted

M mymc/ps2mc_ecc.py => mymc/ps2mc_ecc.py +0 -4
@@ 9,11 9,7 @@
Routines for calculating the Hamming codes, a simple form of error
correcting codes (ECC), as used on PS2 memory cards.  
"""
from __future__ import print_function

from builtins import chr
from builtins import map
from builtins import range
_SCCS_ID = "@(#) mysc ps2mc_ecc.py 1.4 07/12/17 02:34:04\n"

import array

M mymc/ps2save.py => mymc/ps2save.py +0 -3
@@ 7,9 7,6 @@
# A simple interface for working with various PS2 save file formats.
#

from builtins import map
from builtins import range
from builtins import object
_SCCS_ID = "@(#) mysc ps2save.py 1.7 12/10/04 19:17:16\n"

import sys

M mymc/round.py => mymc/round.py +0 -1
@@ 1,4 1,3 @@
from __future__ import division
#
# round.py
#