InputStream does not need support mark/reset
Use lookahead variable to avoid using mark()/reset() on the java.io.InputStream
This allows me to use Jython this way:
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.7.0_80
Type "help", "copyright", "credits" or "license" for more information.
>>> from org.bitlet.wetorrent import *
>>> mf = Metafile(file('/path/to/some.torrent'))
>>> mf.length
99893498L
Thanks, will take a look today.
For context, is this needed because is.markSupported is false in Jython?
This is just for clarity, that a lookahead is being used. I introduced readHead to make sure I replace only those calls to is.read that read one character "in advance". In the end, we ended up not having any other is.read() calls.
Similar for parseInteger, parseList and parseDictionary - they use (head, tail) split just to clarify the algorithm; technically those methods could be as well embedded in parse, as they are only called from there.