diff options
Diffstat (limited to 'lib/thandy')
-rw-r--r-- | lib/thandy/SignerCLI.py | 12 | ||||
-rw-r--r-- | lib/thandy/formats.py | 16 |
2 files changed, 17 insertions, 11 deletions
diff --git a/lib/thandy/SignerCLI.py b/lib/thandy/SignerCLI.py index d3af5fb..d002565 100644 --- a/lib/thandy/SignerCLI.py +++ b/lib/thandy/SignerCLI.py @@ -98,13 +98,9 @@ def makebundle(args): _, r, _ = thandy.formats.checkSignedObj(p) if r != 'package': print pkgFile, "was not a package" - packages[p['signed']['location']] = p + packages[p['signed']['name']] = p['signed'] - def getHash(path): - p = packages[path] - return thandy.formats.getDigest(p['signed']) - - bundleObj = thandy.formats.makeBundleObj(configFile, getHash) + bundleObj = thandy.formats.makeBundleObj(configFile, packages.__getitem__) signable = thandy.formats.makeSignable(bundleObj) ks = getKeyStore() @@ -224,7 +220,7 @@ def addrole(args): r = args[1] if r not in thandy.formats.ALL_ROLES: print "Unrecognized role %r. Known roles are %s"%( - r,", ".join(thandy.format.ALL_ROLES)) + r,", ".join(thandy.formats.ALL_ROLES)) sys.exit(1) p = args[2] k.addRole(r, p) @@ -239,7 +235,7 @@ def delrole(args): r = args[1] if r not in thandy.formats.ALL_ROLES: print "Unrecognized role %r. Known roles are %s"%( - r,", ".join(thandy.format.ALL_ROLES)) + r,", ".join(thandy.formats.ALL_ROLES)) sys.exit(1) p = args[2] diff --git a/lib/thandy/formats.py b/lib/thandy/formats.py index e10f0aa..61c1001 100644 --- a/lib/thandy/formats.py +++ b/lib/thandy/formats.py @@ -628,11 +628,11 @@ def makePackageObj(config_fname, package_fname): return result -def makeBundleObj(config_fname, getPackageHash): +def makeBundleObj(config_fname, getPackage): packages = [] def ShortGloss(lang, val): packages[-1]['gloss'][lang] = val def LongGloss(lang, val): packages[-1]['longgloss'][lang] = val - def Package(name, version, path, order, optional=False): + def Package(name, order, version=None, path=None, optional=False): packages.append({'name' : name, 'version' : version, 'path' : path, @@ -661,7 +661,17 @@ def makeBundleObj(config_fname, getPackageHash): for p in packages: try: - p['hash'] = formatHash(getPackageHash(p['path'])) + pkginfo = getPackage(p['name']) + except KeyError: + raise thandy.FormatException("No such package as %s"%p['name']) + + p['hash'] = formatHash(getDigest(pkginfo)) + if p['path'] == None: + p['path'] = pkginfo['location'] + if p['version'] == None: + p['version'] = pkginfo['version'] + if p[' + except KeyError: raise thandy.FormatException("No such package as %s"%p['path']) |