Skip to content

Commit cf485d2

Browse files
author
César Román
authored
feat(ia): add TypeUtilities under ignition.common (#72)
add and update supporting classes and packages Closes: #66
1 parent 79532df commit cf485d2

File tree

10 files changed

+811
-54
lines changed

10 files changed

+811
-54
lines changed

.pylintrc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ max-locals=25
456456
max-parents=7
457457

458458
# Maximum number of public methods for a class (see R0904).
459-
max-public-methods=50
459+
max-public-methods=60
460460

461461
# Maximum number of return / yield for function / method body.
462462
max-returns=6
@@ -498,12 +498,7 @@ attr-naming-style=any
498498
#attr-rgx=
499499

500500
# Bad variable names which should always be refused, separated by a comma.
501-
bad-names=foo,
502-
bar,
503-
baz,
504-
toto,
505-
tutu,
506-
tata
501+
bad-names=
507502

508503
# Bad variable names regexes, separated by a comma. If names match any regex,
509504
# they will always be refused

src/com/inductiveautomation/ignition/common/__init__.py

Lines changed: 325 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,32 @@
44
"AbstractDataset",
55
"BasicDataset",
66
"Dataset",
7+
"JsonElement",
78
"JsonPath",
89
"Path",
910
"QualifiedPath",
11+
"TypeUtilities",
1012
]
1113

12-
from typing import Any, List, Optional, Union
14+
from typing import Any, List, Optional, TypeVar, Union
1315

14-
from com.inductiveautomation.ignition.common.model.values import QualityCode
15-
from com.inductiveautomation.ignition.common.sqltags.model.types import DataQuality
16-
from java.lang import Class, Object, String
16+
from com.inductiveautomation.ignition.common.document import DocumentElement
17+
from com.inductiveautomation.ignition.common.gson import Gson, JsonElement
18+
from com.inductiveautomation.ignition.common.model.values import (
19+
QualifiedValue,
20+
QualityCode,
21+
)
22+
from com.inductiveautomation.ignition.common.sqltags.model.types import (
23+
DataQuality,
24+
DataType,
25+
)
26+
from java.awt import Color
27+
from java.lang import Class, Number, Object, String
28+
from java.util import UUID, Comparator, Date, Locale
29+
from org.json import JSONObject
30+
from org.python.core import PyObject
31+
32+
T = TypeVar("T")
1733

1834

1935
class Dataset(object):
@@ -441,3 +457,308 @@ def getFirstPathComponent(self):
441457

442458
def getFirstPathComponentId(self):
443459
pass
460+
461+
462+
class TypeUtilities(Object):
463+
DATE_FORMAT_STRING = "yyyyMMdd.HHmmssSSSZ" # type: String
464+
NULL_SAFE_CASE_INSENSITIVE_ORDER = None # type: Comparator
465+
466+
@staticmethod
467+
def anyEqual(value, *args):
468+
# type: (T, T) -> bool
469+
pass
470+
471+
@staticmethod
472+
def coerce(value, destType):
473+
# type: (Object, Class) -> Object
474+
pass
475+
476+
@staticmethod
477+
def coerceForLocale(value, target, valueLocale):
478+
# type: (Object, Class, Locale) -> Object
479+
pass
480+
481+
@staticmethod
482+
def coerceGeneric(value, destType):
483+
# type: (Object, Class) -> T
484+
pass
485+
486+
@staticmethod
487+
def coerceLocaleSafe(str, type):
488+
# type: (String, Class) -> Object
489+
pass
490+
491+
@staticmethod
492+
def coerceNullSafe(value, destType):
493+
# type: (Object, Class) -> Object
494+
pass
495+
496+
@staticmethod
497+
def coerceNumberForLocale(value, destType, locale):
498+
# type: (Object, Class, Locale) -> Object
499+
pass
500+
501+
@staticmethod
502+
def coerceNumberNullSafe(value, destType, locale):
503+
# type: (Object, Class, Locale) -> Object
504+
pass
505+
506+
@staticmethod
507+
def colorToHex(c):
508+
# type: (Color) -> String
509+
pass
510+
511+
@staticmethod
512+
def compareInts(foo, bar):
513+
# type: (int, int) -> int
514+
pass
515+
516+
@staticmethod
517+
def compareNullHigh(c1, c2):
518+
# type: (T, T) -> T
519+
pass
520+
521+
@staticmethod
522+
def compareNullLow(c1, c2):
523+
# type: (T, T) -> T
524+
pass
525+
526+
@staticmethod
527+
def datasetFromJSON(json):
528+
# type: (JSONObject) -> Dataset
529+
pass
530+
531+
@staticmethod
532+
def datasetFromJsonString(jsonStr):
533+
# type: (String) -> Dataset
534+
pass
535+
536+
@staticmethod
537+
def datasetToGson(data, gson=None):
538+
# type: (Dataset, Optional[Gson]) -> JsonElement
539+
pass
540+
541+
@staticmethod
542+
def datasetToJSON(data):
543+
# type: (Dataset) -> JSONObject
544+
pass
545+
546+
@staticmethod
547+
def deepEquals(o1, o2, checkArrayTypes):
548+
# type: (Object, Object, bool) -> bool
549+
pass
550+
551+
@staticmethod
552+
def equalsIgnoreCase(o1, o2):
553+
# type: (Object, Object) -> bool
554+
pass
555+
556+
@staticmethod
557+
def fromString(value, dest, locale):
558+
# type: (String, Class, Locale) -> Object
559+
pass
560+
561+
@staticmethod
562+
def getColorFromString(color):
563+
# type: (String) -> Color
564+
pass
565+
566+
@staticmethod
567+
def getFirstOrNull(list_):
568+
# type: (List[T]) -> T
569+
pass
570+
571+
@staticmethod
572+
def getInitValueForClass(c):
573+
# type: (Class) -> Object
574+
pass
575+
576+
@staticmethod
577+
def getLastNameComponent(name):
578+
# type: (String) -> String
579+
pass
580+
581+
@staticmethod
582+
def getPrimitiveType(c):
583+
# type: (Class) -> Object
584+
pass
585+
586+
@staticmethod
587+
def getWrapperType(c):
588+
# type: (Class) -> Class
589+
pass
590+
591+
@staticmethod
592+
def gsonToPy(element):
593+
# type: (JsonElement) -> PyObject
594+
pass
595+
596+
@staticmethod
597+
def hasPrimitiveType(c):
598+
# type: (Class) -> bool
599+
pass
600+
601+
@staticmethod
602+
def hasValueChanged(
603+
currentValue, # type: QualifiedValue
604+
previousValue, # type: QualifiedValue
605+
expectedType, # type: DataType
606+
deadband, # type: float
607+
):
608+
# type: (...) -> bool
609+
pass
610+
611+
@staticmethod
612+
def isAssignable(dest, source):
613+
# type: (Class, Class) -> bool
614+
pass
615+
616+
@staticmethod
617+
def isBoolean(clazz):
618+
# type: (Class) -> bool
619+
pass
620+
621+
@staticmethod
622+
def isDirectlyAssignable(dest, source):
623+
# type: (Class, Class) -> bool
624+
pass
625+
626+
@staticmethod
627+
def isFractional(clazz):
628+
# type: (Class) -> bool
629+
pass
630+
631+
@staticmethod
632+
def isNullOrEmpty(s):
633+
# type: (String) -> bool
634+
return not s
635+
636+
@staticmethod
637+
def isNumber(clazz):
638+
# type: (Class) -> bool
639+
pass
640+
641+
@staticmethod
642+
def isPrimitive(clazz):
643+
# type: (Class) -> bool
644+
pass
645+
646+
@staticmethod
647+
def isProperNumber(clazz):
648+
# type: (Class) -> bool
649+
pass
650+
651+
@staticmethod
652+
def neq(o1, o2):
653+
# type: (Object, Object) -> bool
654+
pass
655+
656+
@staticmethod
657+
def pyToGson(pyObject, customGson=None):
658+
# type: (PyObject, Optional[Gson]) -> JsonElement
659+
pass
660+
661+
@staticmethod
662+
def pyToJava(pyObject):
663+
# type: (PyObject) -> Object
664+
pass
665+
666+
@staticmethod
667+
def setArrayValue(arrayValue, newVal, pos):
668+
# type: (Object, Object, int) -> QualityCode
669+
pass
670+
671+
@staticmethod
672+
def setClassInitializer(init):
673+
# type: (TypeUtilities.ClassInitializer) -> None
674+
pass
675+
676+
@staticmethod
677+
def toBool(value):
678+
# type: (Object) -> bool
679+
pass
680+
681+
@staticmethod
682+
def toByteArray(uuid):
683+
# type: (UUID) -> bytearray
684+
pass
685+
686+
@staticmethod
687+
def toColor(color):
688+
# type: (Object) -> Color
689+
pass
690+
691+
@staticmethod
692+
def toDataset(value):
693+
# type: (Object) -> Dataset
694+
pass
695+
696+
@staticmethod
697+
def toDate(value):
698+
# type: (Object) -> Date
699+
pass
700+
701+
@staticmethod
702+
def toDocument(value):
703+
# type: (Object) -> DocumentElement
704+
pass
705+
706+
@staticmethod
707+
def toDouble(value):
708+
# type: (Object) -> float
709+
pass
710+
711+
@staticmethod
712+
def toEnum(enumType, value):
713+
# type: (Class, String) -> T
714+
pass
715+
716+
@staticmethod
717+
def toFloat(value):
718+
# type: (Object) -> float
719+
pass
720+
721+
@staticmethod
722+
def toInteger(value):
723+
# type: (Object) -> int
724+
pass
725+
726+
@staticmethod
727+
def toLong(value):
728+
# type: (Object) -> long
729+
pass
730+
731+
@staticmethod
732+
def toNumber(value, locale=None):
733+
# type: (Object, Optional[Locale]) -> Number
734+
pass
735+
736+
@staticmethod
737+
def toShort(value):
738+
# type: (Object) -> int
739+
pass
740+
741+
@staticmethod
742+
def toStr(value):
743+
# type: (Object) -> String
744+
pass
745+
746+
@staticmethod
747+
def toStringLocalized(value, locale=None):
748+
# type: (Object, Optional[Locale]) -> String
749+
pass
750+
751+
@staticmethod
752+
def toStringOnlyNumberLocalized(value, locale):
753+
# type: (Object, Locale) -> String
754+
pass
755+
756+
@staticmethod
757+
def toUUID(barr):
758+
# type: (bytearray) -> UUID
759+
pass
760+
761+
class ClassInitializer(object):
762+
def createNew(self, claz):
763+
# type: (Class) -> Object
764+
pass
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Any
2+
3+
from java.lang import Object
4+
5+
6+
class DocumentElement(Object):
7+
def __init__(self, *args):
8+
# type: (Any) -> None
9+
pass
10+
11+
12+
class Document(DocumentElement):
13+
def __init__(self, *args):
14+
# type: (Any) -> None
15+
super(Document, self).__init__(*args)

src/com/inductiveautomation/ignition/common/i18n/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,3 @@ def setKey(self, key):
4343
def setParams(self, params):
4444
# type: (List[Object]) -> None
4545
pass
46-
47-
def toString(self, locale=None):
48-
# type: (Optional[Locale]) -> String
49-
pass

0 commit comments

Comments
 (0)