__init__.py revision 1500
591N/A# The contents of this file are subject to the terms of the 591N/A# Common Development and Distribution License (the "License"). 591N/A# You may not use this file except in compliance with the License. 591N/A# See the License for the specific language governing permissions 591N/A# and limitations under the License. 591N/A# When distributing Covered Code, include this CDDL HEADER in each 591N/A# If applicable, add the following below this CDDL HEADER, with the 591N/A# fields enclosed by brackets "[]" replaced with your own identifying 591N/A# information: Portions Copyright [yyyy] [name of copyright owner] 591N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 591N/A# Use is subject to license terms. 591N/Apackage containing packaging action (file type) modules 1659N/AThis package contains modules describing packaging actions, or file types. The 2639N/Aactions are dynamically discovered, so that new modules can be placed in this 2639N/Apackage directory and they'll just be picked up. The current package contents 2639N/Acan be seen in the section "PACKAGE CONTENTS", below. 2639N/AThis package has one data member: "types". This is a dictionary which maps the 2639N/Aaction names to the classes that represent them. 2639N/AThis package also has one function: "fromstr", which creates an action instance 2639N/Abased on a str() representation of an action. 591N/A# All modules in this package (all python files except __init__.py with their 2639N/A# A dictionary of all the types in this package, mapping to the classes that 591N/A # Pull the class objects out of nvlist, keeping only those that are 591N/A # actually defined in this package. 591N/A# Clean up after ourselves 591N/A """Base exception class for Action errors.""" 1659N/A return _(
"unknown action type '%(type)s' in package " 1659N/A "'%(fmri)s' in action '%(action)s'") % {
1659N/A return _(
"unknown action type '%(type)s' in action " 2639N/A return _(
"Malformed action in package '%(fmri)s' at " 1659N/A "position: %(pos)d:\n %(action)s\n" 2639N/A return _(
"Malformed action at position: %(pos)d:\n " 591N/A """Used to indicate that a file-related error occuring during action 1973N/A """Used to indicate that attributes provided were invalid, or required 1973N/A attributes were missing for an action.""" 1846N/A return _(
"invalid action in package %(fmri)s: " 591N/A return _(
"invalid action, '%(action)s': %(error)s") % {
2639N/A """Create an attribute dict given a string w/ key=value pairs. 2639N/A Raises MalformedActionError if the attributes have syntactic problems. 1890N/A """Create an action instance based on a str() representation of an 2639N/A Raises UnknownActionError if the action type is unknown. 2639N/A Raises MalformedActionError if the action has other syntactic problems. 2639N/A """Create an action instance based on a sequence of "key=value" strings. 2639N/A This function also translates external representations of actions with 2639N/A payloads (like file and license which can use NOHASH or file paths to 2639N/A point to the payload) to an internal representation which sets the 2639N/A data field of the action returned. 2639N/A The "atype" parameter is the type of action to be built. 2639N/A The "args" parameter is the sequence of "key=value" strings. 2639N/A The "ahash" parameter is used to set the hash value for the action. 2639N/A The "basedirs" parameter is the list of directories to look in to find 2639N/A any payload for the action. 2639N/A Raises MalformedActionError if the attribute strings are malformed. 2639N/A # This is by far the common case-- an attribute with 591N/A # We're only here if the for: statement above throws a 2639N/A # MalformedActionError. That can happen if split yields a 591N/A # single element, which is possible if e.g. an attribute lacks 591N/A """Create an action instance based on a sequence of strings. 591N/A This function also translates external representations of actions with 2639N/A payloads (like file and license which can use NOHASH or file paths to 1846N/A point to the payload) to an internal representation which sets the 591N/A data field of the action returned. 1659N/A In general, each string should be in the form of "key=value". The 1973N/A exception is a payload for certain actions which should be the first 1846N/A Raises MalformedActionError if the attribute strings are malformed. 591N/A """Sets the data field of an action using the information in the 591N/A payload and returns the actual path used to set the data. 629N/A The "payload" parameter is the representation of the data to assign to 1973N/A the action's data field. It can either be NOHASH or a path to the file. 1973N/A The "action" parameter is the action to modify. 591N/A The "basedirs" parameter contains the directories to examine to find 2233N/A # look for file in specified dirs