Exemplo n.º 1
0
import hotchpotch.struct
from hotchpotch.importer import importObjectByPath
import json


with open("registry.json") as file:
	registry = json.load(file)

importObjectByPath(
	"sys/registry",
	"org.hotchpotch.registry",
	[
		("HPSD", hotchpotch.struct.dumps(registry)),
		("META", hotchpotch.struct.dumps({
			"org.hotchpotch.annotation" : {
				"title"   : "UTI registry",
				"comment" : "Import by boot.py"
			}
		}))
	],
	True)

# set default sync rules
importObjectByPath(
	"sys/syncrules",
	"public.data",
	[
		("HPSD", hotchpotch.struct.dumps([])),
		("META", hotchpotch.struct.dumps({
			"org.hotchpotch.annotation" : {
Exemplo n.º 2
0
       <hp-obj-spec>    = [FOUR:<content>]+
       <content> = local file | json data
"""
    sys.exit(1)


# === main

if len(sys.argv) < 4:
    usage()

# parse command line
objPath = sys.argv[1]
objUti = sys.argv[2]
objSpec = []
for spec in sys.argv[3:]:
    if spec[4] != ':':
        usage()
    fourCC = spec[:4]
    content = spec[5:]
    if os.path.isfile(content):
        with open(content, "rb") as file:
            part = file.read()
    else:
        part = struct.dumps(struct.loadJSON(content))
    objSpec.append((fourCC, part))

# let's do it
if not importObjectByPath(objPath, objUti, objSpec):
    print "Import failed"
Exemplo n.º 3
0
       <content> = local file | json data
"""
	sys.exit(1)


# === main

if len(sys.argv) < 4:
	usage()

# parse command line
objPath = sys.argv[1]
objUti  = sys.argv[2]
objSpec = []
for spec in sys.argv[3:]:
	if spec[4] != ':':
		usage()
	fourCC = spec[:4]
	content = spec[5:]
	if os.path.isfile(content):
		with open(content, "rb") as file:
			part = file.read()
	else:
		part = struct.dumps(struct.loadJSON(content))
	objSpec.append((fourCC, part))

# let's do it
if not importObjectByPath(objPath, objUti, objSpec):
	print "Import failed"