pyds.Label¶
- class pyds.Label(*statements)¶
Bases: pyds.Statements
Represents a PDS label.
Methods
- Label.insert(index, statement)¶
Insert the statement statement at index index.
- Parameters
index (int)
The index at which to insert the statement.
index can be any integer (positive or negative). If negative, it’s taken to mean the index from the end. For example, s.insert(-10, stmt) is the same as s.insert(len(s)-10, stmt).
If index is out of range and positive, then statement is appended to the end. If it’s out of range and negative, then statement is prepended to the begining.
statement (Attribute, Group or Object)
The statement to insert. It must be an instance of either Attribute, Group or Object.
Also, statement‘s identifier must not be the same as any other statement previously inserted.
- Raises
- Label.append(statement)¶
Append the statement statement.
Note
Calling s.append(stmt) is the same as calling s.insert(len(s), stmt). See insert() for further documentation.
- Label.get(index)¶
Return the statement at index index.
- Parameters
index (int)
The index from where to return the statement.
index can be any integer (positive or negative). If negative, it’s taken to mean the index from the end. For example, s.get(-10) is the same as s.get(len(s)-10).
- Raises
-
If index is out of range.
-
- Label.pop(index)¶
Remove and return the statement at index index.
- Parameters
index (int)
The index from where to remove and return the statement.
index can be any integer (positive or negative). If negative, it’s taken to mean the index from the end. For example, s.pop(-10) is the same as s.pop(len(s)-10).
- Raises
-
If index is out of range.
-
Special Methods
- Label.__setitem__(key, value)¶
Create and insert a new statement using key and value.
- Parameters
key (str)
The identifier of the new statement.
If value is an instance of Value, then key must be a valid identifier such that a new Attribute can be instantiated as, Attribute(key, value).
If value is an instance of GroupStatements, then key must be a valid identifier such that a new Group can be instantiated as, Group(key, value).
If value is an instance of ObjectStatements, then key must be a valid identifier such that a new Object can be instantiated as, Object(key, value).
value (Value, GroupStatements or ObjectStatements)
value determines the type of the new statement.
If value is an instance of Value, then an Attribute statement is created.
If value is an instance of GroupStatements, then a Group statement is created.
If value is an instance of ObjectStatements, then an Object statement is created.
- Raises
-
If value is not an instance of Value, GroupStatements or ObjectStatements.
-
If key is not a valid identifier.
-
- Label.__getitem__(key)¶
Return the value of the statement whose identifier is key.
- Label.__delitem__(key)¶
Remove the statement whose identifier is key.
- Label.__contains__(key)¶
Test if a statement exists whose identifier is key. Return True if it exists, and False otherwise.
- Parameters
key (str)
The identifier of the statement. key is case-insensitive.
- Label.__reversed__()¶
Return an iterator that iterates over the statements in reverse order.
Called by reversed().