getVersion()Class: PackageAPI
Returns the version of SmartPackager whose package code the SDK contains (for example "1.4.0"). For the SDK's own version, use getSdkVersion().
getVersion()
api = package_api.PackageAPI()
version = api.getVersion()
getSdkVersion()Class: PackageAPI
Returns the version of the PackageAPI SDK, the same as the .whl or .nupkg package version (for example "1.0.0").
getSdkVersion()
api = package_api.PackageAPI()
sdkVersion = api.getSdkVersion()
validate(packageFile, validationLevel, vendorKeyFile, authKeyFile)Class: PackageAPI
Marks the package as validated by Yaskawa at the given level and rewrites the .yip file. validationLevel must be "endorsed" or "registered". It doesn't check the package's contents.
It needs a Yaskawa authorization key in authKeyFile; without one it returns False. The package keeps its own vendor key: vendorKeyFile is only used as the authorization key when authKeyFile is "". Returns True if the package was validated, otherwise False (see getLastError()).
validate(packageFile, validationLevel, vendorKeyFile, authKeyFile)
api = package_api.PackageAPI()
isValid = api.validate(packageFile, validationLevel, vendorKeyFile, authKeyFile)
getPackageInfo(packageFile)Class: PackageAPI
Returns the information for a package file, with the key fields below. displayName is in the language set by a packager.ini in the current directory, if any (default English). Returns an empty dictionary if the file isn't a valid .yip package (see getLastError()).
The key fields:
getPackageInfo(packageFile)
api = package_api.PackageAPI()
packagesInfo = api.getPackageInfo(packageFile)
listPackages(folder)Class: PackageAPI
Returns the information for every valid .yip package directly in the given folder (not in sub-folders), in file-name order, with the same key fields as getPackageInfo(). Invalid .yip files are skipped and reported by getWarnings(). Returns an empty list if the folder doesn't exist.
The key fields:
listPackages(folder)
api = package_api.PackageAPI()
packagesList = api.listPackages(folder)
generateVendorKey(vendorKeyFile)Class: PackageAPI
Generates a private vendor key and saves it to the given file, readable only by you. Keep it safe and backed up: it is needed to change packages protected with it, or read their contents. Returns True if successful, otherwise False.
generateVendorKey(vendorKeyFile)
api = package_api.PackageAPI()
wasSuccessful = api.generateVendorKey(vendorKeyFile)
exportPublicKey(vendorKeyFile)Class: PackageAPI
Returns the public key that pairs with the private vendor key in vendorKeyFile, as a hexadecimal string. Returns "" if the file is missing or isn't a valid key.
exportPublicKey(vendorKeyFile)
api = package_api.PackageAPI()
publicKeyStr = api.exportPublicKey(vendorKeyFile)
exportPublicKeyHash(vendorKeyFile)Class: PackageAPI
Returns the SHA-512 hash of the public key that pairs with the private vendor key in vendorKeyFile, as a hexadecimal string. Returns "" if the file is missing or isn't a valid key.
exportPublicKeyHash(vendorKeyFile)
api = package_api.PackageAPI()
publicKeyHashStr = api.exportPublicKeyHash(vendorKeyFile)
isValidVendorKey(vendorKeyFile)Class: PackageAPI
Returns True if vendorKeyFile holds a valid private vendor key, otherwise False.
isValidVendorKey(vendorKeyFile)
api = package_api.PackageAPI()
isValid = api.isValidVendorKey(vendorKeyFile)
createUnprotectedPackage(packageFile, packageTemplateFile, archiveFolder, packageVariables)Class: PackageAPI
Creates an unprotected package in packageFile from the package template packageTemplateFile (.json or .jsonnet). archiveFolder is a folder whose files are included in the package; it must exist. Use "" for no archive. packageVariables sets template variables - see Package variables. Use "" for none. Returns True if the package was created, otherwise False.
IMPORTANT: Anyone can change an unprotected package.
For the package template format, see Install Package Format.
createUnprotectedPackage(packageFile, packageTemplateFile, archiveFolder, packageVariables)
api = package_api.PackageAPI()
wasSuccessful = api.createUnprotectedPackage(packageFile, packageTemplateFile, archiveFolder, packageVariables)
createProtectedPackage(packageFile, packageTemplateFile, archiveFolder, vendorPrivateKeyFile, packageVariables)Class: PackageAPI
Creates a protected package in packageFile from the package template packageTemplateFile (.json or .jsonnet), protected by the vendor key in vendorPrivateKeyFile. Only the holder of that key (or Yaskawa) can change the package or read its JSON (see Package protection and keys). archiveFolder is a folder whose files are included; it must exist. Use "" for no archive. packageVariables sets template variables - see Package variables. Use "" for none. Returns True if the package was created, otherwise False (including when vendorPrivateKeyFile is "").
For the package template format, see Install Package Format.
createProtectedPackage(packageFile, packageTemplateFile, archiveFolder, vendorPrivateKeyFile, packageVariables)
api = package_api.PackageAPI()
wasSuccessful = api.createProtectedPackage(packageFile, packageTemplateFile, archiveFolder, vendorPrivateKeyFile, packageVariables)
addComponent(packageFile, compFile, vendorPrivateKeyFile)Class: PackageAPI
Adds the component defined in compFile (.json or .jsonnet) to packageFile. If the package already has a component with the same canonical name, it is replaced. If the package is protected, vendorPrivateKeyFile must hold its key (or a Yaskawa key); for an unprotected package use "". The package keeps its own key. Returns True if the component was added or replaced, otherwise False.
For the component format, see Components in the Install Package Format.
addComponent(packageFile, compFile, vendorPrivateKeyFile)
api = package_api.PackageAPI()
wasAdded = api.addComponent(packageFile, compFile, vendorPrivateKeyFile)
removeComponent(packageFile, compCanonicalName, vendorKeyFile)Class: PackageAPI
Removes the component with canonical name compCanonicalName from packageFile. If the package is protected, vendorKeyFile must hold its key (or a Yaskawa key); for an unprotected package use "". The package keeps its own key. Returns True if the component was removed, otherwise False - including when the package has no such component.
removeComponent(packageFile, compCanonicalName, vendorKeyFile)
api = package_api.PackageAPI()
wasRemoved = api.removeComponent(packageFile, compCanonicalName, vendorKeyFile)
getJson(packageFile, compCanonicalName, vendorKeyFile)Class: PackageAPI
Returns the JSON for a whole .yip package (compCanonicalName "") or for one of its components (compCanonicalName set to that component's canonical name). For a protected package, vendorKeyFile must be the package's vendor private key, or a Yaskawa key. For an unprotected package, use "". Returns "" if the package is invalid, the key doesn't match, or the package has no such component (see getLastError()).
getJson(packageFile, compCanonicalName, vendorKeyFile)
api = package_api.PackageAPI()
jsonStr = api.getJson(packageFile, compCanonicalName, vendorKeyFile)
changeVendorKey(packageFile, vendorKeyFile, newVendorKeyFile)Class: PackageAPI
Changes the key protecting packageFile. vendorKeyFile is the package's current key ("" if it is unprotected) or a Yaskawa key. newVendorKeyFile is the new key, or "" to make the package unprotected. Use it to protect an unprotected package, move a package to another vendor key, or remove its protection. Returns True if the key was changed, otherwise False.
changeVendorKey(packageFile, vendorKeyFile, newVendorKeyFile)
api = package_api.PackageAPI()
wasChanged = api.changeVendorKey(packageFile, vendorKeyFile, newVendorKeyFile)
getLastError()Class: PackageAPI
Returns why the last call failed, including any detail from the package code, or "" if it succeeded.
getLastError()
getWarnings()Class: PackageAPI
Returns the problems noted during the last call that didn't stop it, such as an invalid package skipped by listPackages() or an icon that isn't a .png or .jpg file and so wasn't included. A list of strings. Empty if there were none.
getWarnings()
api = package_api.PackageAPI()
if not api.addComponent(packageFile, compFile, vendorKeyFile):
print("Failed: " + api.getLastError())
for warning in api.getWarnings():
print("Warning: " + warning)
packageVariables is a comma-separated list of name=value pairs, for example "title=My Package,level=2". Spaces around names and values are ignored, and a name on its own is set to "true". Values can't contain commas or equals signs. Use them in the template with std.extVar('name'), for example displayNames: { en: std.extVar('title') }.