amalgam-lang 6.1.6__py3-none-macosx_12_0_arm64.whl → 7.0.0__py3-none-macosx_12_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of amalgam-lang might be problematic. Click here for more details.

amalgam/api.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from ctypes import (
2
- byref, c_bool, c_char, c_char_p, c_double, c_size_t, c_uint64, c_void_p,
3
- cdll, POINTER
2
+ byref, cast, c_bool, c_char, c_char_p, c_double, c_size_t, c_uint64, c_void_p,
3
+ cdll, POINTER, Structure
4
4
  )
5
5
  from datetime import datetime
6
6
  import gc
@@ -15,12 +15,45 @@ import warnings
15
15
  _logger = logging.getLogger('amalgam')
16
16
 
17
17
 
18
+ class _LoadEntityStatus(Structure):
19
+ """
20
+ A private status returned from Amalgam binary LoadEntity C API.
21
+
22
+ This is implemented with ctypes for accessing binary Amalgam builds.
23
+ """
24
+ _fields_ = [
25
+ ("loaded", c_bool),
26
+ ("message", POINTER(c_char)),
27
+ ("version", POINTER(c_char))
28
+ ]
29
+
30
+
31
+ class LoadEntityStatus:
32
+ """
33
+ Status returned by :func:`~api.Amalgam.load_entity`.
34
+
35
+ This is implemented with python types and is meant to wrap _LoadEntityStatus
36
+ which uses ctypes and directly interacts with the Amalgam binaries.
37
+ """
38
+ def __init__(self, api, c_status: _LoadEntityStatus = None):
39
+ if c_status is None:
40
+ self.loaded = True
41
+ self.message = ""
42
+ self.version = ""
43
+ else:
44
+ self.loaded = bool(c_status.loaded)
45
+ self.message = api.char_p_to_bytes(c_status.message).decode("utf-8")
46
+ self.version = api.char_p_to_bytes(c_status.version).decode("utf-8")
47
+
48
+ def __str__(self):
49
+ return f"{self.loaded},\"{self.message}\",\"{self.version}\""
50
+
51
+
18
52
  class Amalgam:
19
53
  """
20
54
  A general python direct interface to the Amalgam library.
21
55
 
22
- This is implemented with ctypes for accessing binary amalgam builds in
23
- Linux, MacOS and Windows.
56
+ This is implemented with ctypes for accessing binary Amalgam builds.
24
57
 
25
58
  Parameters
26
59
  ----------
@@ -496,7 +529,9 @@ class Amalgam:
496
529
  size: Optional[int] = None
497
530
  ) -> c_char:
498
531
  """
499
- Convert a string to a c++ char pointer.
532
+ Convert a string to a C char pointer.
533
+
534
+ User must call `del` on returned buffer
500
535
 
501
536
  Parameters
502
537
  ----------
@@ -509,7 +544,7 @@ class Amalgam:
509
544
  Returns
510
545
  -------
511
546
  c_char
512
- A c++ char point for the string.
547
+ A C char pointer for the string.
513
548
  """
514
549
  if isinstance(value, str):
515
550
  value = value.encode('utf-8')
@@ -518,6 +553,28 @@ class Amalgam:
518
553
  buf.value = value
519
554
  return buf
520
555
 
556
+ def char_p_to_bytes(self, p: POINTER(c_char)) -> bytes:
557
+ """
558
+ Copies a native C char pointer to bytes, cleaning up native memory correctly.
559
+
560
+ Parameters
561
+ ----------
562
+ p : LP_char_p
563
+ C pointer to string to convert
564
+
565
+ Returns
566
+ -------
567
+ bytes
568
+ The byte-encoded string from C pointer
569
+ """
570
+ bytes = cast(p, c_char_p).value
571
+
572
+ self.amlg.DeleteString.argtypes = c_char_p,
573
+ self.amlg.DeleteString.restype = None
574
+ self.amlg.DeleteString(p)
575
+
576
+ return bytes
577
+
521
578
  def get_json_from_label(self, handle: str, label: str) -> bytes:
522
579
  """
523
580
  Get a label from amalgam and returns it in json format.
@@ -534,15 +591,19 @@ class Amalgam:
534
591
  bytes
535
592
  The byte-encoded json representation of the amalgam label.
536
593
  """
537
- self.amlg.GetJSONPtrFromLabel.restype = c_char_p
594
+ self.amlg.GetJSONPtrFromLabel.restype = POINTER(c_char)
538
595
  self.amlg.GetJSONPtrFromLabel.argtype = [c_char_p, c_char_p]
539
596
  handle_buf = self.str_to_char_p(handle)
540
597
  label_buf = self.str_to_char_p(label)
541
- result = self.amlg.GetJSONPtrFromLabel(handle_buf, label_buf)
542
- self._log_execution(f"GET_JSON_FROM_LABEL {handle} {label}")
598
+
599
+ self._log_execution(f"GET_JSON_FROM_LABEL \"{handle}\" \"{label}\"")
600
+ result = self.char_p_to_bytes(self.amlg.GetJSONPtrFromLabel(handle_buf, label_buf))
601
+ self._log_reply(result)
602
+
543
603
  del handle_buf
544
604
  del label_buf
545
605
  self.gc()
606
+
546
607
  return result
547
608
 
548
609
  def set_json_to_label(
@@ -568,8 +629,11 @@ class Amalgam:
568
629
  handle_buf = self.str_to_char_p(handle)
569
630
  label_buf = self.str_to_char_p(label)
570
631
  json_buf = self.str_to_char_p(json)
571
- self._log_execution(f"SET_JSON_TO_LABEL {handle} {label} {json}")
632
+
633
+ self._log_execution(f"SET_JSON_TO_LABEL \"{handle}\" \"{label}\" {json}")
572
634
  self.amlg.SetJSONToLabel(handle_buf, label_buf, json_buf)
635
+ self._log_reply(None)
636
+
573
637
  del handle_buf
574
638
  del label_buf
575
639
  del json_buf
@@ -583,7 +647,7 @@ class Amalgam:
583
647
  load_contained: bool = False,
584
648
  write_log: str = "",
585
649
  print_log: str = ""
586
- ) -> bool:
650
+ ) -> LoadEntityStatus:
587
651
  """
588
652
  Load an entity from an amalgam source file.
589
653
 
@@ -607,33 +671,126 @@ class Amalgam:
607
671
 
608
672
  Returns
609
673
  -------
610
- bool
611
- True if the entity was successfully loaded.
674
+ LoadEntityStatus
675
+ Status of LoadEntity call.
612
676
  """
613
677
  self.amlg.LoadEntity.argtype = [
614
678
  c_char_p, c_char_p, c_bool, c_bool, c_char_p, c_char_p]
615
- self.amlg.LoadEntity.restype = c_bool
679
+ self.amlg.LoadEntity.restype = _LoadEntityStatus
616
680
  handle_buf = self.str_to_char_p(handle)
617
681
  amlg_path_buf = self.str_to_char_p(amlg_path)
618
682
  write_log_buf = self.str_to_char_p(write_log)
619
683
  print_log_buf = self.str_to_char_p(print_log)
620
684
 
621
- self.load_command_log_entry = (
622
- f"LOAD_ENTITY {handle} \"{amlg_path}\" {str(persist).lower()} "
623
- f"{str(load_contained).lower()} {write_log} {print_log}"
685
+ load_command_log_entry = (
686
+ f"LOAD_ENTITY \"{handle}\" \"{amlg_path}\" {str(persist).lower()} "
687
+ f"{str(load_contained).lower()} \"{write_log}\" \"{print_log}\""
624
688
  )
625
- self._log_execution(self.load_command_log_entry)
626
- result = self.amlg.LoadEntity(
689
+ self._log_execution(load_command_log_entry)
690
+ result = LoadEntityStatus(self, self.amlg.LoadEntity(
627
691
  handle_buf, amlg_path_buf, persist, load_contained,
628
- write_log_buf, print_log_buf)
692
+ write_log_buf, print_log_buf))
629
693
  self._log_reply(result)
694
+
630
695
  del handle_buf
631
696
  del amlg_path_buf
632
697
  del write_log_buf
633
698
  del print_log_buf
634
699
  self.gc()
700
+
635
701
  return result
636
702
 
703
+ def verify_entity(
704
+ self,
705
+ amlg_path: str
706
+ ) -> LoadEntityStatus:
707
+ """
708
+ Verify an entity from an amalgam source file.
709
+
710
+ Parameters
711
+ ----------
712
+ amlg_path : str
713
+ The path to the filename.amlg/caml file.
714
+
715
+ Returns
716
+ -------
717
+ LoadEntityStatus
718
+ Status of VerifyEntity call.
719
+ """
720
+ self.amlg.VerifyEntity.argtype = [c_char_p]
721
+ self.amlg.VerifyEntity.restype = _LoadEntityStatus
722
+ amlg_path_buf = self.str_to_char_p(amlg_path)
723
+
724
+ self._log_execution(f"VERIFY_ENTITY \"{amlg_path}\"")
725
+ result = LoadEntityStatus(self, self.amlg.VerifyEntity(amlg_path_buf))
726
+ self._log_reply(result)
727
+
728
+ del amlg_path_buf
729
+ self.gc()
730
+
731
+ return result
732
+
733
+ def store_entity(
734
+ self,
735
+ handle: str,
736
+ amlg_path: str,
737
+ update_persistence_location: bool = False,
738
+ store_contained: bool = False
739
+ ) -> None:
740
+ """
741
+ Stores an entity to the file type specified within amlg_path.
742
+
743
+ Parameters
744
+ ----------
745
+ handle : str
746
+ The handle of the amalgam entity.
747
+ amlg_path : str
748
+ The path to the filename.amlg/caml file.
749
+ update_persistence_location : bool
750
+ If set to true, updates location entity is persisted to.
751
+ store_contained : bool
752
+ If set to true, contained entities will be stored.
753
+ """
754
+ self.amlg.StoreEntity.argtype = [
755
+ c_char_p, c_char_p, c_bool, c_bool]
756
+ handle_buf = self.str_to_char_p(handle)
757
+ amlg_path_buf = self.str_to_char_p(amlg_path)
758
+
759
+ store_command_log_entry = (
760
+ f"STORE_ENTITY \"{handle}\" \"{amlg_path}\" {str(update_persistence_location).lower()} "
761
+ f"{str(store_contained).lower()}"
762
+ )
763
+ self._log_execution(store_command_log_entry)
764
+ self.amlg.StoreEntity(
765
+ handle_buf, amlg_path_buf, update_persistence_location, store_contained)
766
+ self._log_reply(None)
767
+
768
+ del handle_buf
769
+ del amlg_path_buf
770
+ self.gc()
771
+
772
+ def destroy_entity(
773
+ self,
774
+ handle: str
775
+ ) -> None:
776
+ """
777
+ Destroys an entity.
778
+
779
+ Parameters
780
+ ----------
781
+ handle : str
782
+ The handle of the amalgam entity.
783
+ """
784
+ self.amlg.DestroyEntity.argtype = [c_char_p]
785
+ handle_buf = self.str_to_char_p(handle)
786
+
787
+ self._log_execution(f"DESTROY_ENTITY \"{handle}\"")
788
+ self.amlg.DestroyEntity(handle_buf)
789
+ self._log_reply(None)
790
+
791
+ del handle_buf
792
+ self.gc()
793
+
637
794
  def get_entities(self) -> List[str]:
638
795
  """
639
796
  Get loaded top level entities.
@@ -648,9 +805,11 @@ class Amalgam:
648
805
  num_entities = c_uint64()
649
806
  entities = self.amlg.GetEntities(byref(num_entities))
650
807
  result = [entities[i].decode() for i in range(num_entities.value)]
808
+
651
809
  del entities
652
810
  del num_entities
653
811
  self.gc()
812
+
654
813
  return result
655
814
 
656
815
  def execute_entity_json(
@@ -676,21 +835,24 @@ class Amalgam:
676
835
  bytes
677
836
  A byte-encoded json representation of the response.
678
837
  """
679
- self.amlg.ExecuteEntityJsonPtr.restype = c_char_p
838
+ self.amlg.ExecuteEntityJsonPtr.restype = POINTER(c_char)
680
839
  self.amlg.ExecuteEntityJsonPtr.argtype = [
681
840
  c_char_p, c_char_p, c_char_p]
682
841
  handle_buf = self.str_to_char_p(handle)
683
842
  label_buf = self.str_to_char_p(label)
684
843
  json_buf = self.str_to_char_p(json)
844
+
685
845
  self._log_time("EXECUTION START")
686
- self._log_execution(f"EXECUTE_ENTITY_JSON {handle} {label} {json}")
687
- result = self.amlg.ExecuteEntityJsonPtr(
688
- handle_buf, label_buf, json_buf)
846
+ self._log_execution(f"EXECUTE_ENTITY_JSON \"{handle}\" \"{label}\" {json}")
847
+ result = self.char_p_to_bytes(self.amlg.ExecuteEntityJsonPtr(
848
+ handle_buf, label_buf, json_buf))
689
849
  self._log_time("EXECUTION STOP")
690
850
  self._log_reply(result)
851
+
691
852
  del handle_buf
692
853
  del label_buf
693
854
  del json_buf
855
+
694
856
  return result
695
857
 
696
858
  def set_number_value(self, handle: str, label: str, value: float) -> None:
@@ -711,7 +873,9 @@ class Amalgam:
711
873
  handle_buf = self.str_to_char_p(handle)
712
874
  label_buf = self.str_to_char_p(label)
713
875
  val = c_double(value)
876
+
714
877
  self.amlg.SetNumberValue(handle_buf, label_buf, val)
878
+
715
879
  del handle_buf
716
880
  del label_buf
717
881
  del val
@@ -737,9 +901,12 @@ class Amalgam:
737
901
  self.amlg.GetNumberValue.argtype = [c_char_p, c_char_p]
738
902
  handle_buf = self.str_to_char_p(handle)
739
903
  label_buf = self.str_to_char_p(label)
904
+
740
905
  result = self.amlg.GetNumberValue(handle_buf, label_buf)
906
+
741
907
  del handle_buf
742
908
  del label_buf
909
+
743
910
  return result
744
911
 
745
912
  def set_string_value(
@@ -765,7 +932,9 @@ class Amalgam:
765
932
  handle_buf = self.str_to_char_p(handle)
766
933
  label_buf = self.str_to_char_p(label)
767
934
  val_buf = self.str_to_char_p(value)
935
+
768
936
  self.amlg.SetStringValue(handle_buf, label_buf, val_buf)
937
+
769
938
  del handle_buf
770
939
  del label_buf
771
940
  del val_buf
@@ -791,15 +960,18 @@ class Amalgam:
791
960
  self.amlg.GetStringListPtr.argtype = [c_char_p, c_char_p]
792
961
  handle_buf = self.str_to_char_p(handle)
793
962
  label_buf = self.str_to_char_p(label)
963
+
794
964
  size = self.amlg.GetStringListLength(handle_buf, label_buf)
795
965
  value_buf = self.amlg.GetStringListPtr(handle_buf, label_buf)
796
966
  result = None
797
967
  if value_buf is not None and size > 0:
798
968
  result = value_buf[0]
969
+
799
970
  del handle_buf
800
971
  del label_buf
801
972
  del value_buf
802
973
  self.gc()
974
+
803
975
  return result
804
976
 
805
977
  def set_string_list(
@@ -835,6 +1007,7 @@ class Amalgam:
835
1007
  handle_buf = self.str_to_char_p(handle)
836
1008
  label_buf = self.str_to_char_p(label)
837
1009
  self.amlg.SetStringList(handle_buf, label_buf, value_buf, size)
1010
+
838
1011
  del handle_buf
839
1012
  del label_buf
840
1013
  del value_buf
@@ -863,13 +1036,16 @@ class Amalgam:
863
1036
  self.amlg.GetStringListPtr.argtype = [c_char_p, c_char_p]
864
1037
  handle_buf = self.str_to_char_p(handle)
865
1038
  label_buf = self.str_to_char_p(label)
1039
+
866
1040
  size = self.amlg.GetStringListLength(handle_buf, label_buf)
867
1041
  value_buf = self.amlg.GetStringListPtr(handle_buf, label_buf)
868
1042
  value = [value_buf[i] for i in range(size)]
1043
+
869
1044
  del handle_buf
870
1045
  del label_buf
871
1046
  del value_buf
872
1047
  self.gc()
1048
+
873
1049
  return value
874
1050
 
875
1051
  def get_version_string(self) -> bytes:
@@ -881,8 +1057,8 @@ class Amalgam:
881
1057
  bytes
882
1058
  A version byte-encoded string with semver.
883
1059
  """
884
- self.amlg.GetVersionString.restype = c_char_p
885
- amlg_version = self.amlg.GetVersionString()
1060
+ self.amlg.GetVersionString.restype = POINTER(c_char)
1061
+ amlg_version = self.char_p_to_bytes(self.amlg.GetVersionString())
886
1062
  self._log_comment(f"call to amlg.GetVersionString() - returned: "
887
1063
  f"{amlg_version}\n")
888
1064
  return amlg_version
@@ -897,8 +1073,8 @@ class Amalgam:
897
1073
  A byte-encoded string with library concurrency type.
898
1074
  Ex. b'MultiThreaded'
899
1075
  """
900
- self.amlg.GetConcurrencyTypeString.restype = c_char_p
901
- amlg_concurrency_type = self.amlg.GetConcurrencyTypeString()
1076
+ self.amlg.GetConcurrencyTypeString.restype = POINTER(c_char)
1077
+ amlg_concurrency_type = self.char_p_to_bytes(self.amlg.GetConcurrencyTypeString())
902
1078
  self._log_comment(
903
1079
  f"call to amlg.GetConcurrencyTypeString() - returned: "
904
1080
  f"{amlg_concurrency_type}\n")
Binary file
Binary file
Binary file
amalgam/lib/version.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": {
3
- "amalgam": "47.1.6",
4
- "amalgam_sha": "fe3a382869c8d998fc9c5111609e5a4b6e3d3713",
5
- "amalgam_url": "https://github.com/howsoai/amalgam/releases/tag/47.1.6",
3
+ "amalgam": "48.0.0",
4
+ "amalgam_sha": "8e95a5c4869e99d23f9f9861a601cd4dcaa06890",
5
+ "amalgam_url": "https://github.com/howsoai/amalgam/releases/tag/48.0.0",
6
6
  "amalgam_build_date": "",
7
7
  "amalgam_display_title": ""
8
8
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: amalgam-lang
3
- Version: 6.1.6
3
+ Version: 7.0.0
4
4
  Summary: A direct interface with Amalgam compiled DLL or so.
5
5
  Author: Howso Incorporated
6
6
  Author-email: support@howso.com
@@ -0,0 +1,11 @@
1
+ amalgam/__init__.py,sha256=oHu7Zr4eGDUqj93pLwz8t7gLa8lpAx6Q-xbGiJ3nJx0,18
2
+ amalgam/api.py,sha256=8DnZnEa9_qYg-zCz6_myus516bgpTwZHMhG5BFiyuBA,36170
3
+ amalgam/lib/version.json,sha256=JIjcmHmyYEW-3KNELYtQrgpWIEWc139M6hHoRWJ0YmE,250
4
+ amalgam/lib/darwin/arm64/amalgam-mt.dylib,sha256=iWyWxpVLRvPR7TLPRDct4ZxODYfAiBV_wOPjotkWkCE,2197696
5
+ amalgam/lib/darwin/arm64/amalgam-omp.dylib,sha256=AYTmBBzRjj8H7pMUtvimTxbKiwFe23YtLSfAeaQiHSA,2622576
6
+ amalgam/lib/darwin/arm64/amalgam-st.dylib,sha256=Cn5Nzeo1lGYM4w-y81aLt0Ba_9dWC3FSIpfsW4vTUA0,2125456
7
+ amalgam_lang-7.0.0.dist-info/LICENSE.txt,sha256=2xqHuoHohba7gpcZZKtOICRjzeKsQANXG8WoV9V35KM,33893
8
+ amalgam_lang-7.0.0.dist-info/METADATA,sha256=C-9e-Rrk_KjK4BfLiYN6g2YoxYluyeTBxlEt9E6mbI0,43351
9
+ amalgam_lang-7.0.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
10
+ amalgam_lang-7.0.0.dist-info/top_level.txt,sha256=rmPHU144SyaB25u5-FAQyECAQnJ39NvuJEcKXMRcdBo,8
11
+ amalgam_lang-7.0.0.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- amalgam/__init__.py,sha256=oHu7Zr4eGDUqj93pLwz8t7gLa8lpAx6Q-xbGiJ3nJx0,18
2
- amalgam/api.py,sha256=9L-DEdqclKi2sKHls9ONdf9jDDRpS8klqDAk0SE8XOQ,31600
3
- amalgam/lib/version.json,sha256=1WXY87EdeHzxbAeEm6pOQwGg_tIvLKdQrP--Dt4Apms,250
4
- amalgam/lib/darwin/arm64/amalgam-mt.dylib,sha256=D6Ge3ssKU5IsUpaGEgiTPjebxA9kV4HEnnDTDDT7D8k,2176896
5
- amalgam/lib/darwin/arm64/amalgam-omp.dylib,sha256=zAsLOW84pSL9ac9gCF7-9Cc2pgeheLUfhS28HNvRIG8,2618400
6
- amalgam/lib/darwin/arm64/amalgam-st.dylib,sha256=UlaS5oIHQFL3oW60w7n-p0my3IWHSI4bGIaJNLs8c8M,2104736
7
- amalgam_lang-6.1.6.dist-info/LICENSE.txt,sha256=2xqHuoHohba7gpcZZKtOICRjzeKsQANXG8WoV9V35KM,33893
8
- amalgam_lang-6.1.6.dist-info/METADATA,sha256=bvi4yWX_WxMXvuf1hWtDKr1gKL57IF451LOiwtsYg74,43351
9
- amalgam_lang-6.1.6.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
10
- amalgam_lang-6.1.6.dist-info/top_level.txt,sha256=rmPHU144SyaB25u5-FAQyECAQnJ39NvuJEcKXMRcdBo,8
11
- amalgam_lang-6.1.6.dist-info/RECORD,,