graspfile.torfile¶
A class to hold a parsed GRASP Tor File in a collection of objects
Classes
GraspTorComment([tor_comment]) |
A container for comments from a GraspTorFile |
GraspTorFile([file_like]) |
A container for objects read from a tor file. |
GraspTorMember([tor_member]) |
A container for the member parameter of an GraspTorObject |
GraspTorObject([tor_obj]) |
A container for a GraspTorObject, that has a name, a type and a number of members. |
GraspTorRef([tor_ref]) |
A container for a value that is a reference to another GraspTorObject |
GraspTorSequence([tor_seq]) |
A container for a value that is a sequence of GraspTorValues. |
GraspTorStruct([tor_struct]) |
A container for a GraspTorStruct, that has a number of members. |
GraspTorValue([tor_value]) |
A container for values from GraspTorMember objects |
-
class
graspfile.torfile.GraspTorComment(tor_comment=None)[source]¶ Bases:
objectA container for comments from a GraspTorFile
-
_type= None¶ The type of the object
Type: str
-
location= None¶ Line number that the comment appears in.
Type: int
-
name= None¶ Name of comment object
Type: str
-
text= None¶ Test of the comment object
Type: str
-
type¶ Return the type of the comment object as “commment”.
-
-
class
graspfile.torfile.GraspTorFile(file_like=None)[source]¶ Bases:
collections.OrderedDictA container for objects read from a tor file. Subclasses OrderedDict to provide a dict of torObjects keyed by name, and sorted by insertion order
Create a TorFile object, and if fileLike is specified, read the file
-
clear() → None. Remove all items from od.¶
-
copy() → a shallow copy of od¶
-
fromkeys()¶ Create a new ordered dictionary with keys from iterable and values set to value.
-
get()¶ Return the value for key if key is in the dictionary, else default.
-
items() → a set-like object providing a view on D's items¶
-
keys() → a set-like object providing a view on D's keys¶
-
move_to_end()¶ Move an existing element to the end (or beginning if last is false).
Raise KeyError if the element does not exist.
-
pop(k[, d]) → v, remove specified key and return the corresponding¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem()¶ Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
-
read(file_like)[source]¶ Read a list of torObjects and torComments from a fileLike object. We use pyparsing.ParserElement’s parseFile method, which can take either a file-like object or a filename to open. If you wish to parse an existing string object, used StringIO to supply a file-like object containing the string.
-
setdefault()¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
update([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
values() → an object providing a view on D's values¶
-
-
class
graspfile.torfile.GraspTorMember(tor_member=None)[source]¶ Bases:
objectA container for the member parameter of an GraspTorObject
-
type¶ Return the type of the GraspTorMember
-
unit¶ Short circuit through tor_value to supply tV.unit if appropriate, else return None
-
value¶ Short circuit through tor_value to supply tV.value if it is a simple value
-
-
class
graspfile.torfile.GraspTorObject(tor_obj=None)[source]¶ Bases:
collections.OrderedDictA container for a GraspTorObject, that has a name, a type and a number of members. Members are stored as an OrderedDict.
-
clear() → None. Remove all items from od.¶
-
copy() → a shallow copy of od¶
-
fromkeys()¶ Create a new ordered dictionary with keys from iterable and values set to value.
-
get()¶ Return the value for key if key is in the dictionary, else default.
-
items() → a set-like object providing a view on D's items¶
-
keys() → a set-like object providing a view on D's keys¶
-
move_to_end()¶ Move an existing element to the end (or beginning if last is false).
Raise KeyError if the element does not exist.
-
name¶ Return the name of the GraspTorObject
-
pop(k[, d]) → v, remove specified key and return the corresponding¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem()¶ Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
-
read_str(tor_str)[source]¶ Read the contents of the string into a tor_object and then process the results
-
setdefault()¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
type¶ Return the type of the GraspTorObject
-
update([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
values() → an object providing a view on D's values¶
-
-
class
graspfile.torfile.GraspTorRef(tor_ref=None)[source]¶ Bases:
objectA container for a value that is a reference to another GraspTorObject
-
ref= None¶ Reference to another GraspTorObject
Type: str
-
-
class
graspfile.torfile.GraspTorSequence(tor_seq=None)[source]¶ Bases:
listA container for a value that is a sequence of GraspTorValues.
-
append()¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count()¶ Return number of occurrences of value.
-
extend()¶ Extend list by appending elements from the iterable.
-
index()¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert()¶ Insert object before index.
-
pop()¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove()¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort()¶ Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
-
-
class
graspfile.torfile.GraspTorStruct(tor_struct=None)[source]¶ Bases:
collections.OrderedDictA container for a GraspTorStruct, that has a number of members. Members are stored as an OrderedDict.
-
clear() → None. Remove all items from od.¶
-
copy() → a shallow copy of od¶
-
fromkeys()¶ Create a new ordered dictionary with keys from iterable and values set to value.
-
get()¶ Return the value for key if key is in the dictionary, else default.
-
items() → a set-like object providing a view on D's items¶
-
keys() → a set-like object providing a view on D's keys¶
-
move_to_end()¶ Move an existing element to the end (or beginning if last is false).
Raise KeyError if the element does not exist.
-
pop(k[, d]) → v, remove specified key and return the corresponding¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem()¶ Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
-
setdefault()¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
update([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
values() → an object providing a view on D's values¶
-
-
class
graspfile.torfile.GraspTorValue(tor_value='_None')[source]¶ Bases:
objectA container for values from GraspTorMember objects
Container for values within GraspTorMember, GraspTorStruct, and GraspTorSequence objects.
Parameters: tor_value – a pyparsing.ParseResults object from a tor_value tokentcOK. -
fill(tor_value)[source]¶ Fills the GraspTorValue object from output by the parser.
Parameters: tor_value – a pyparsing.ParseResults class output by the torparser module.
-
unit= None¶ The unit of the value as a string
Type: str
-
value= None¶ The value as a string
Type: str
-