Use marshal pre 1.2.0

This commit is contained in:
Ganesh Viswanathan 2020-06-18 14:52:27 -05:00
commit 9b2aa7d4b1
2 changed files with 31 additions and 11 deletions

View file

@ -1,4 +1,9 @@
import json, os, strformat, strutils, tables import os, strformat, strutils, tables
when (NimMajor, NimMinor, NimPatch) < (1, 2, 0):
import marshal
else:
import json
type type
ConanPackage* = ref object ConanPackage* = ref object
@ -272,6 +277,9 @@ proc loadConanInfo*(outdir: string): ConanPackage =
file = outdir / conanInfo file = outdir / conanInfo
if fileExists(file): if fileExists(file):
when (NimMajor, NimMinor, NimPatch) < (1, 2, 0):
result = to[ConanPackage](readFile(file))
else:
try: try:
result = to(readFile(file).parseJson(), ConanPackage) result = to(readFile(file).parseJson(), ConanPackage)
except: except:
@ -283,6 +291,9 @@ proc saveConanInfo*(pkg: ConanPackage, outdir: string) =
let let
file = outdir / conanInfo file = outdir / conanInfo
when (NimMajor, NimMinor, NimPatch) < (1, 2, 0):
writeFile(file, $$pkg)
else:
writeFile(file, $(%pkg)) writeFile(file, $(%pkg))
proc parseConanManifest(pkg: ConanPackage, outdir: string) = proc parseConanManifest(pkg: ConanPackage, outdir: string) =

View file

@ -1,5 +1,8 @@
import json, os, strutils import json, os, strutils
when (NimMajor, NimMinor, NimPatch) < (1, 2, 0):
import marshal
type type
JBBPackage* = ref object JBBPackage* = ref object
## JBBPackage type that stores package information ## JBBPackage type that stores package information
@ -143,6 +146,9 @@ proc loadJBBInfo*(outdir: string): JBBPackage =
file = outdir / jbbInfo file = outdir / jbbInfo
if fileExists(file): if fileExists(file):
when (NimMajor, NimMinor, NimPatch) < (1, 2, 0):
result = to[JBBPackage](readFile(file))
else:
try: try:
result = to(readFile(file).parseJson(), JBBPackage) result = to(readFile(file).parseJson(), JBBPackage)
except: except:
@ -154,6 +160,9 @@ proc saveJBBInfo*(pkg: JBBPackage, outdir: string) =
let let
file = outdir / jbbInfo file = outdir / jbbInfo
when (NimMajor, NimMinor, NimPatch) < (1, 2, 0):
writeFile(file, $$pkg)
else:
writeFile(file, $(%pkg)) writeFile(file, $(%pkg))
proc dlJBBRequires*(pkg: JBBPackage, outdir: string) proc dlJBBRequires*(pkg: JBBPackage, outdir: string)