Esempio n. 1
0
 def test_display_time(self):
     self.assertEquals(tools.display_time(1),
                       "1.00 sec")
     self.assertEquals(tools.display_time(61.2),
                       "1 min 1.20 sec")
     self.assertEquals(tools.display_time(60),
                       "1 min 0.00 sec")
     self.assertEquals(tools.display_time(3600),
                       "1 hour 0.00 sec")
     self.assertEquals(tools.display_time(3661),
                       "1 hour 1 min 1.00 sec")
Esempio n. 2
0
def unpack(dicts, dest_dir, verbose):
    # dict_ext = os.path.splitext(dict_file)[1].upper()
    # if dict_ext != '.LSD':
    #     raise LsdError("Need Lingvo lsd dictionary.")

    count = len(dicts)
    if count == 1:
        print("Unpacking dict: %s" % dicts[0])
    for i in range(count):
        dict_file = dicts[i]
        start = timer()
        try:
            if count > 1:
                print("Unpacking dict (%d from %d): %s" % (i + 1, count, dict_file))
            m = LsdFile(dict_file, verbose)
            m.parse()
            m.dump()
            m.write(dest_dir)
        except ValueError as e:
            print("Error: %s" % e)
            return 1
        end = timer()
        print("Unpack OK (%s)" % tools.display_time(end - start))

    return 0
Esempio n. 3
0
def main():
    args = get_arg_parser().parse_args()
    dicts = []
    if args.all:
        # all lsd in directory
        print("Decode all lsd in current directory..")
        dicts = get_dicts()
        print(dicts)
    else:
        dicts.append(args.input)

    if args.header:
        header(dicts)
    else:
        if args.outdir != "":
            # check path
            if not os.path.exists(args.outdir):
                os.mkdir(args.outdir)

        start = timer()
        unpack(dicts, args.outdir, args.verbose)
        end = timer()
        if len(dicts) > 1:
            # print("Files count: %i" % c)
            print("Elapsed: %s" % tools.display_time(end - start))

    return 0
Esempio n. 4
0
 def test_display_time(self):
     self.assertEquals(tools.display_time(1), "1.00 sec")
     self.assertEquals(tools.display_time(61.2), "1 min 1.20 sec")
     self.assertEquals(tools.display_time(60), "1 min 0.00 sec")
     self.assertEquals(tools.display_time(3600), "1 hour 0.00 sec")
     self.assertEquals(tools.display_time(3661), "1 hour 1 min 1.00 sec")