mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-19 22:55:25 +02:00
Make parsing of OPF major version more robust
This commit is contained in:
parent
72115a92b1
commit
5a2c70e91e
1 changed files with 6 additions and 1 deletions
|
|
@ -20,10 +20,15 @@
|
|||
OPFVersion = namedtuple('OPFVersion', 'major minor patch')
|
||||
|
||||
def parse_opf_version(raw):
|
||||
parts = (raw or '').split('.')
|
||||
try:
|
||||
major = int(parts[0])
|
||||
except Exception:
|
||||
return OPFVersion(2, 0, 0)
|
||||
try:
|
||||
v = list(map(int, raw.split('.')))
|
||||
except Exception:
|
||||
v = [2, 0, 0]
|
||||
v = [major, 0, 0]
|
||||
while len(v) < 3:
|
||||
v.append(0)
|
||||
v = v[:3]
|
||||
|
|
|
|||
Loading…
Reference in a new issue