Hi
I'm currently trying to use this plugin. It doesn't work in Calibre at all, so I decided to go to the console instead and run it in python. I noticed a few things:
- The files do not have the ending ".yves" any more (fixed)
- The "manifest.yves" is now called "_version_" (fixed)
- It does not run on Python 3 (fixed)
- UTF-8 does not work (main issue)
So I started translating the file yvesDecode.py to Python 3 and I fixed the filename issues, but I'm stuck with the conversion: Since I want to work with different languages, I wanted to use UTF-8 but the conversion of the .yves-files does not seem to work. For example, I get "La création" instead of "La création".
How can I get this to run properly?
So far, this is my code (I changed it to only work on Gen 1 for testing, as running the entire bible would take too long):
Code:
import sys, os
#import json # JSON module did not work
import rson
def readFile(paramFile):
file = open(paramFile, 'rb')
arrayOfByte = file.read()
file.close()
return(readString(arrayOfByte))
def readString(arrayOfByte):
i = 0
byteArray = []
while (i < len(arrayOfByte)):
if (len(arrayOfByte) > i + 1):
j = ((int('0xFF',16) & arrayOfByte[(i + 1)]) >> 5 | (int('0xFF',16) & arrayOfByte[(i + 1)]) << 3)
byteArray.append(j)
byteArray.append(((int('0xFF',16) & arrayOfByte[i]) >> 5 | (int('0xFF',16) & arrayOfByte[i]) << 3))
else:
byteArray.append(((int('0xFF',16) & arrayOfByte[i]) >> 5 | (int('0xFF',16) & arrayOfByte[i]) << 3))
i += 2;
return(''.join([ chr(x & 0xFF) for x in byteArray]))
def loadJson(string):
#return json.loads(string)
return rson.loads(string)
def yvesDir2HTML(yvesfile, yves_temp_directory):
file = open('out.txt', 'w', encoding="utf8") #for testing, only output part of the bible
yvesfile = 'GEN.1' #for testing, only output part of the bible
content = readFile(yvesfile)
file.write(content)
file.close()
return("done")
if __name__ == '__main__':
if len(sys.argv[1:]) > 0:
for file in sys.argv[1:]:
print(loadJson(readFile(file)))
else:
print(yvesDir2HTML("_version_","."))
Of course, I'll put everything back together when it works.