Class PyUtilities
java.lang.Object
com.inductiveautomation.ignition.common.PyUtilities
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanisIterable(org.python.core.PyObject pyObject) Predicate that returns true if the provided object is iterable - which is a superset of sequences, as an iterable doesn't have to be sized.static booleanisSequence(org.python.core.PyObject pyObject) Predicate that returns true if the provided object is a sequence, per Java convention - meaning, strings are not considered sequences.static booleanisString(org.python.core.PyObject pyObject) Simple predicate that returns true if the provided object is a Python string (ie, inherits fromPyBaseString.static Stream<org.python.core.PyObject>stream(org.python.core.PyObject pyObject) Stream items frompyObject.static Stream<org.apache.commons.lang3.tuple.Pair<org.python.core.PyObject,org.python.core.PyObject>> streamEntries(org.python.core.PyObject pyObject) Stream entries frompyObject, in a key: valuePair.toPyDictionary(Function<T, ?> keyExtractor, Function<T, ?> valueExtractor) Collect a stream ofTinto a new PyDictionary.toPyList()Collect a stream into a new PyList.
- 
Method Details- 
isStringpublic static boolean isString(org.python.core.PyObject pyObject) Simple predicate that returns true if the provided object is a Python string (ie, inherits fromPyBaseString.
- 
isSequencepublic static boolean isSequence(org.python.core.PyObject pyObject) Predicate that returns true if the provided object is a sequence, per Java convention - meaning, strings are not considered sequences.
- 
isIterablepublic static boolean isIterable(org.python.core.PyObject pyObject) Predicate that returns true if the provided object is iterable - which is a superset of sequences, as an iterable doesn't have to be sized. Returns true for strings as well.
- 
streamStream items frompyObject. Per Python behavior, will stream characters one-by-one in a string.- Throws:
- org.python.core.PyException- TypeError if provided PyObject is not iterable.
 
- 
streamEntriespublic static Stream<org.apache.commons.lang3.tuple.Pair<org.python.core.PyObject,org.python.core.PyObject>> streamEntries(org.python.core.PyObject pyObject) Stream entries frompyObject, in a key: valuePair.- Throws:
- org.python.core.PyException- TypeError if provided PyObject is not iterable.
- IllegalArgumentException- if provided PyObject is not a mapping type.
 
- 
toPyListCollect a stream into a new PyList.
- 
toPyDictionarypublic static <T> Collector<T,Object, toPyDictionaryorg.python.core.PyDictionary> (Function<T, ?> keyExtractor, Function<T, ?> valueExtractor) Collect a stream ofTinto a new PyDictionary.- Type Parameters:
- T- The incoming type, eg- Map.Entryor- Pair.
- Parameters:
- keyExtractor- The key extractor, eg- Map.Entry.getKey(). Should not return a PyObject directly.
- valueExtractor- The value extractor, eg- Map.Entry.getValue(). Should not return a PyObject directly.
- Returns:
- a new PyDictionary.
 
 
-