chemql-python 1.4.1__tar.gz → 1.4.2__tar.gz

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.
Files changed (37) hide show
  1. {chemql_python-1.4.1/src/chemql_python.egg-info → chemql_python-1.4.2}/PKG-INFO +76 -41
  2. {chemql_python-1.4.1 → chemql_python-1.4.2}/README.md +74 -39
  3. {chemql_python-1.4.1 → chemql_python-1.4.2}/pyproject.toml +1 -1
  4. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/__init__.py +245 -33
  5. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/README.md +28 -0
  6. chemql_python-1.4.2/src/chemql/stdlib/decimal.cql +23 -0
  7. chemql_python-1.4.2/src/chemql/stdlib/fractions.cql +29 -0
  8. chemql_python-1.4.2/src/chemql/stdlib/pathlib.cql +38 -0
  9. chemql_python-1.4.2/src/chemql/stdlib/random.cql +29 -0
  10. {chemql_python-1.4.1 → chemql_python-1.4.2/src/chemql_python.egg-info}/PKG-INFO +76 -41
  11. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql_python.egg-info/SOURCES.txt +6 -1
  12. chemql_python-1.4.2/tests/test_public_api.py +87 -0
  13. chemql_python-1.4.2/tests/test_stdlib.py +49 -0
  14. chemql_python-1.4.1/tests/test_public_api.py +0 -28
  15. {chemql_python-1.4.1 → chemql_python-1.4.2}/LICENSE +0 -0
  16. {chemql_python-1.4.1 → chemql_python-1.4.2}/setup.cfg +0 -0
  17. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/__main__.py +0 -0
  18. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/BondEnergies.json +0 -0
  19. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/MoleculeBonds.json +0 -0
  20. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/Molecules.json +0 -0
  21. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/PeriodicTableJSON.json +0 -0
  22. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/Reactions.json +0 -0
  23. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  24. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  25. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/html/periodic_table.html +0 -0
  26. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/collections.cql +0 -0
  27. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/datetime.cql +0 -0
  28. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/json.cql +0 -0
  29. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/math/statistics.cql +0 -0
  30. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/math.cql +0 -0
  31. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql/stdlib/text.cql +0 -0
  32. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  33. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql_python.egg-info/entry_points.txt +0 -0
  34. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql_python.egg-info/requires.txt +0 -0
  35. {chemql_python-1.4.1 → chemql_python-1.4.2}/src/chemql_python.egg-info/top_level.txt +0 -0
  36. {chemql_python-1.4.1 → chemql_python-1.4.2}/tests/test_external_molecule_lookup.py +0 -0
  37. {chemql_python-1.4.1 → chemql_python-1.4.2}/tests/test_reactions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: A chemistry-focused query language and REPL
5
5
  Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -19,7 +19,7 @@ SQL-inspired syntax, inspect elements and molecules, look up reactions,
19
19
  balance equations, and combine chemistry queries with Python and shell
20
20
  commands.
21
21
 
22
- - **Version:** `1.4.0`
22
+ - **Version:** `1.4.1`
23
23
  - **PyPI distribution:** `chemql-python`
24
24
  - **Python import / CLI name:** `chemql`
25
25
  - **Author:** Mohammad Rakibul Islam
@@ -522,49 +522,55 @@ ChemQL provides `risk`, `fix`, `cleanup`, and `signal` for handling errors, resp
522
522
 
523
523
  ### `risk`
524
524
 
525
- Use `risk` to mark a block of code that may encounter an error and needs special handling.
525
+ `risk` executes its body. If a command raises an exception, ChemQL stores
526
+ the error type name in the Python variable `error` and runs the optional
527
+ `fix` body. A returned string that happens to contain error-looking text
528
+ does not trigger `fix`.
526
529
 
527
530
  ```text
528
531
  risk
529
- [result = 10 / 0]
532
+ [result = 10 / 2]
533
+ print(result)
534
+ fix
535
+ print(error)
536
+ cleanup
537
+ print("Always runs")
530
538
  endrisk
531
539
  ```
532
540
 
533
- This illustrates the idea of protecting potentially failing code. The exact behaviour depends on ChemQL's implementation of `risk`.
534
-
535
541
  ### `fix`
536
542
 
537
- Use `fix` to define how ChemQL should respond when an error occurs in a corresponding `risk` block.
543
+ The `fix` section runs only when the `risk` section raises an exception.
544
+ The `error` variable contains the exception type name, such as
545
+ `ChemQLError`, `ValueError`, or the error name carried by `signal`.
538
546
 
539
547
  ```text
540
548
  risk
541
549
  [result = 10 / 0]
542
550
  fix
543
- [print("An error occurred")]
551
+ print("Handled:", error)
544
552
  endrisk
545
553
  ```
546
554
 
547
- This example illustrates the intended relationship between `risk` and `fix`. Check the implementation for the precise syntax and whether execution continues after an error.
548
-
549
555
  ### `cleanup`
550
556
 
551
- Use `cleanup` to organize code that should run as part of a cleanup phase associated with a protected operation.
557
+ The optional `cleanup` section runs whether the `risk` section succeeds
558
+ or fails, after the risk body and any fix body.
552
559
 
553
560
  ```text
554
561
  risk
555
- [print("Performing operation")]
562
+ print("Performing operation")
556
563
  fix
557
- [print("Handling an error")]
564
+ print("Handling an error")
558
565
  cleanup
559
- [print("Cleaning up")]
566
+ print("Cleaning up")
560
567
  endrisk
561
568
  ```
562
569
 
563
- Cleanup logic is useful for keeping resource-management steps separate from the main operation and its error-handling logic.
564
-
565
570
  ### `signal`
566
571
 
567
- Use `signal` to explicitly raise or report an error when a condition cannot be handled normally.
572
+ Use `signal` to raise a named ChemQL error that can be handled by
573
+ `fix`.
568
574
 
569
575
  ```text
570
576
  if temperature < 0
@@ -572,19 +578,18 @@ if temperature < 0
572
578
  endif
573
579
  ```
574
580
 
575
- A signal can make an invalid state or failed operation explicit instead of allowing execution to proceed silently.
576
-
577
581
  ### Summary
578
582
 
579
583
  | Keyword | Purpose |
580
584
  |---|---|
581
- | `risk` | Marks potentially failing code for special handling |
582
- | `fix` | Specifies error-handling behaviour |
583
- | `cleanup` | Organizes cleanup logic |
584
- | `signal` | Raises or reports an error |
585
+ | `risk` | Executes the protected body |
586
+ | `fix` | Runs when the risk body raises an exception |
587
+ | `cleanup` | Runs after the risk and fix bodies |
588
+ | `signal` | Raises a named error |
585
589
  | `endrisk` | Ends the risk handler |
586
590
 
587
- These features help make ChemQL scripts easier to maintain by separating normal execution, error handling, and cleanup responsibilities.
591
+ Without a `fix` section, an ordinary exception propagates. `cleanup`
592
+ still runs during exception propagation.
588
593
 
589
594
  ## Functions, definitions, and macros
590
595
 
@@ -647,7 +652,8 @@ command lists definitions in the current session.
647
652
 
648
653
  ## Structs and records
649
654
 
650
- ChemQL v1.4.0 allows required fields defined by a trailing exclamation mark `!` or the `required` keyword
655
+ ChemQL 1.4.1 supports required fields, marked with a trailing `!` or the
656
+ `required` keyword:
651
657
 
652
658
  ```text
653
659
  struct Fruit
@@ -661,8 +667,8 @@ apple.name
661
667
  apple.price
662
668
  let orange = Fruit{"Orange", 20} // you can use position rather than just keyword arguments
663
669
  let banana = Fruit{"Banana", price = 10} // or you can even mix
664
-
665
670
  ```
671
+
666
672
  ```text
667
673
  struct Vegetable
668
674
  name!
@@ -680,24 +686,24 @@ is fully implemented.
680
686
 
681
687
  ## Namespaces
682
688
 
683
- Namespaces store functions, structs, records, variables, etc.
684
-
685
- To declare functions accessible in the global scope you must use the `public` keyword, everything is private by default, you may still add the `private` keyword for fun
686
- Example
687
- ```text
688
- namespace math
689
- public let PI = 3.14159265358979
690
- public let E = 2.718281828459045
691
- public
692
-
689
+ Namespaces group functions, structs, records, and variables. Members are
690
+ private by default; use `public` to expose a member through the namespace:
693
691
 
692
+ ```chemql
693
+ namespace geometry
694
+ public let PI = 3.141592653589793
695
+ public func circle_area
696
+ return [PI * \1 * \1]
697
+ endfunc
698
+ endnamespace
699
+
700
+ geometry::circle_area{2}
694
701
  ```
695
702
 
696
703
  ## Standard library
697
704
 
698
- ChemQL loads reusable `.cql` packages with `load`. The loader searches the current
699
- directory and then the interpreter's adjacent `stdlib/` directory. Preserve the
700
- folder structure when extracting `chemql_stdlib.zip`.
705
+ ChemQL loads reusable `.cql` packages with `load`. The loader searches the
706
+ current directory first and then ChemQL's bundled `stdlib/` directory.
701
707
 
702
708
  | Package | Purpose |
703
709
  | --- | --- |
@@ -707,6 +713,10 @@ folder structure when extracting `chemql_stdlib.zip`.
707
713
  | `collections` | `unique`, `flatten`, `zip`, `pairwise`, frequency counts, product |
708
714
  | `datetime` | Current date/time, ISO dates, timestamps, weekday and date arithmetic |
709
715
  | `json` | JSON serialization, pretty serialization, parsing and type inspection |
716
+ | `random` | Pseudo-random numbers and sequence sampling |
717
+ | `decimal` | Base-10 decimal arithmetic and quantization |
718
+ | `fractions` | Exact rational numbers and fraction arithmetic |
719
+ | `pathlib` | Path inspection and UTF-8 text file operations |
710
720
 
711
721
  ```chemql
712
722
  load math
@@ -731,9 +741,30 @@ datetime::date_add_days{"2026-10-20", 7}
731
741
 
732
742
  load json
733
743
  json::loads{"{\"formula\": \"H2O\"}"}
744
+
745
+ load random
746
+ random::seed{42}
747
+ random::randint{1, 6}
748
+
749
+ load decimal
750
+ decimal::add{"0.1", "0.2"}
751
+ decimal::quantize{"3.14159", "0.01"}
752
+
753
+ load fractions
754
+ fractions::create{1, 3}
755
+ fractions::add{"1/3", "1/6"}
756
+
757
+ load pathlib
758
+ pathlib::name{"data/results.csv"}
759
+ pathlib::join{"data", "results.csv"}
734
760
  ```
735
761
 
736
762
  These packages use Python's standard library only; they add no third-party dependencies.
763
+ Use `help{stdlib}` for the package index, `help{math}` for a module
764
+ overview, and `help{math::sqrt}` for function help. These help pages are
765
+ available before loading the package. `pathlib::read_text` and
766
+ `pathlib::write_text` access files with the permissions of the ChemQL
767
+ process.
737
768
 
738
769
  ## Built-in help
739
770
 
@@ -747,10 +778,14 @@ help{syntax}
747
778
  help{errors}
748
779
  help{files}
749
780
  help{chemistry}
781
+ help{stdlib}
782
+ help{math}
783
+ help{math::sqrt}
750
784
  ```
751
785
 
752
- Use `help{function_name}` for built-in documentation. The ANSI-colored help screen
753
- also includes a quick reference to the standard-library packages.
786
+ Use `help{function_name}` for built-in documentation and
787
+ `help{module::function}` for standard-library function documentation. The
788
+ help index also lists the available standard-library packages.
754
789
 
755
790
  ## Shell integration and scripting
756
791
 
@@ -6,7 +6,7 @@ SQL-inspired syntax, inspect elements and molecules, look up reactions,
6
6
  balance equations, and combine chemistry queries with Python and shell
7
7
  commands.
8
8
 
9
- - **Version:** `1.4.0`
9
+ - **Version:** `1.4.1`
10
10
  - **PyPI distribution:** `chemql-python`
11
11
  - **Python import / CLI name:** `chemql`
12
12
  - **Author:** Mohammad Rakibul Islam
@@ -509,49 +509,55 @@ ChemQL provides `risk`, `fix`, `cleanup`, and `signal` for handling errors, resp
509
509
 
510
510
  ### `risk`
511
511
 
512
- Use `risk` to mark a block of code that may encounter an error and needs special handling.
512
+ `risk` executes its body. If a command raises an exception, ChemQL stores
513
+ the error type name in the Python variable `error` and runs the optional
514
+ `fix` body. A returned string that happens to contain error-looking text
515
+ does not trigger `fix`.
513
516
 
514
517
  ```text
515
518
  risk
516
- [result = 10 / 0]
519
+ [result = 10 / 2]
520
+ print(result)
521
+ fix
522
+ print(error)
523
+ cleanup
524
+ print("Always runs")
517
525
  endrisk
518
526
  ```
519
527
 
520
- This illustrates the idea of protecting potentially failing code. The exact behaviour depends on ChemQL's implementation of `risk`.
521
-
522
528
  ### `fix`
523
529
 
524
- Use `fix` to define how ChemQL should respond when an error occurs in a corresponding `risk` block.
530
+ The `fix` section runs only when the `risk` section raises an exception.
531
+ The `error` variable contains the exception type name, such as
532
+ `ChemQLError`, `ValueError`, or the error name carried by `signal`.
525
533
 
526
534
  ```text
527
535
  risk
528
536
  [result = 10 / 0]
529
537
  fix
530
- [print("An error occurred")]
538
+ print("Handled:", error)
531
539
  endrisk
532
540
  ```
533
541
 
534
- This example illustrates the intended relationship between `risk` and `fix`. Check the implementation for the precise syntax and whether execution continues after an error.
535
-
536
542
  ### `cleanup`
537
543
 
538
- Use `cleanup` to organize code that should run as part of a cleanup phase associated with a protected operation.
544
+ The optional `cleanup` section runs whether the `risk` section succeeds
545
+ or fails, after the risk body and any fix body.
539
546
 
540
547
  ```text
541
548
  risk
542
- [print("Performing operation")]
549
+ print("Performing operation")
543
550
  fix
544
- [print("Handling an error")]
551
+ print("Handling an error")
545
552
  cleanup
546
- [print("Cleaning up")]
553
+ print("Cleaning up")
547
554
  endrisk
548
555
  ```
549
556
 
550
- Cleanup logic is useful for keeping resource-management steps separate from the main operation and its error-handling logic.
551
-
552
557
  ### `signal`
553
558
 
554
- Use `signal` to explicitly raise or report an error when a condition cannot be handled normally.
559
+ Use `signal` to raise a named ChemQL error that can be handled by
560
+ `fix`.
555
561
 
556
562
  ```text
557
563
  if temperature < 0
@@ -559,19 +565,18 @@ if temperature < 0
559
565
  endif
560
566
  ```
561
567
 
562
- A signal can make an invalid state or failed operation explicit instead of allowing execution to proceed silently.
563
-
564
568
  ### Summary
565
569
 
566
570
  | Keyword | Purpose |
567
571
  |---|---|
568
- | `risk` | Marks potentially failing code for special handling |
569
- | `fix` | Specifies error-handling behaviour |
570
- | `cleanup` | Organizes cleanup logic |
571
- | `signal` | Raises or reports an error |
572
+ | `risk` | Executes the protected body |
573
+ | `fix` | Runs when the risk body raises an exception |
574
+ | `cleanup` | Runs after the risk and fix bodies |
575
+ | `signal` | Raises a named error |
572
576
  | `endrisk` | Ends the risk handler |
573
577
 
574
- These features help make ChemQL scripts easier to maintain by separating normal execution, error handling, and cleanup responsibilities.
578
+ Without a `fix` section, an ordinary exception propagates. `cleanup`
579
+ still runs during exception propagation.
575
580
 
576
581
  ## Functions, definitions, and macros
577
582
 
@@ -634,7 +639,8 @@ command lists definitions in the current session.
634
639
 
635
640
  ## Structs and records
636
641
 
637
- ChemQL v1.4.0 allows required fields defined by a trailing exclamation mark `!` or the `required` keyword
642
+ ChemQL 1.4.1 supports required fields, marked with a trailing `!` or the
643
+ `required` keyword:
638
644
 
639
645
  ```text
640
646
  struct Fruit
@@ -648,8 +654,8 @@ apple.name
648
654
  apple.price
649
655
  let orange = Fruit{"Orange", 20} // you can use position rather than just keyword arguments
650
656
  let banana = Fruit{"Banana", price = 10} // or you can even mix
651
-
652
657
  ```
658
+
653
659
  ```text
654
660
  struct Vegetable
655
661
  name!
@@ -667,24 +673,24 @@ is fully implemented.
667
673
 
668
674
  ## Namespaces
669
675
 
670
- Namespaces store functions, structs, records, variables, etc.
671
-
672
- To declare functions accessible in the global scope you must use the `public` keyword, everything is private by default, you may still add the `private` keyword for fun
673
- Example
674
- ```text
675
- namespace math
676
- public let PI = 3.14159265358979
677
- public let E = 2.718281828459045
678
- public
676
+ Namespaces group functions, structs, records, and variables. Members are
677
+ private by default; use `public` to expose a member through the namespace:
679
678
 
679
+ ```chemql
680
+ namespace geometry
681
+ public let PI = 3.141592653589793
682
+ public func circle_area
683
+ return [PI * \1 * \1]
684
+ endfunc
685
+ endnamespace
680
686
 
687
+ geometry::circle_area{2}
681
688
  ```
682
689
 
683
690
  ## Standard library
684
691
 
685
- ChemQL loads reusable `.cql` packages with `load`. The loader searches the current
686
- directory and then the interpreter's adjacent `stdlib/` directory. Preserve the
687
- folder structure when extracting `chemql_stdlib.zip`.
692
+ ChemQL loads reusable `.cql` packages with `load`. The loader searches the
693
+ current directory first and then ChemQL's bundled `stdlib/` directory.
688
694
 
689
695
  | Package | Purpose |
690
696
  | --- | --- |
@@ -694,6 +700,10 @@ folder structure when extracting `chemql_stdlib.zip`.
694
700
  | `collections` | `unique`, `flatten`, `zip`, `pairwise`, frequency counts, product |
695
701
  | `datetime` | Current date/time, ISO dates, timestamps, weekday and date arithmetic |
696
702
  | `json` | JSON serialization, pretty serialization, parsing and type inspection |
703
+ | `random` | Pseudo-random numbers and sequence sampling |
704
+ | `decimal` | Base-10 decimal arithmetic and quantization |
705
+ | `fractions` | Exact rational numbers and fraction arithmetic |
706
+ | `pathlib` | Path inspection and UTF-8 text file operations |
697
707
 
698
708
  ```chemql
699
709
  load math
@@ -718,9 +728,30 @@ datetime::date_add_days{"2026-10-20", 7}
718
728
 
719
729
  load json
720
730
  json::loads{"{\"formula\": \"H2O\"}"}
731
+
732
+ load random
733
+ random::seed{42}
734
+ random::randint{1, 6}
735
+
736
+ load decimal
737
+ decimal::add{"0.1", "0.2"}
738
+ decimal::quantize{"3.14159", "0.01"}
739
+
740
+ load fractions
741
+ fractions::create{1, 3}
742
+ fractions::add{"1/3", "1/6"}
743
+
744
+ load pathlib
745
+ pathlib::name{"data/results.csv"}
746
+ pathlib::join{"data", "results.csv"}
721
747
  ```
722
748
 
723
749
  These packages use Python's standard library only; they add no third-party dependencies.
750
+ Use `help{stdlib}` for the package index, `help{math}` for a module
751
+ overview, and `help{math::sqrt}` for function help. These help pages are
752
+ available before loading the package. `pathlib::read_text` and
753
+ `pathlib::write_text` access files with the permissions of the ChemQL
754
+ process.
724
755
 
725
756
  ## Built-in help
726
757
 
@@ -734,10 +765,14 @@ help{syntax}
734
765
  help{errors}
735
766
  help{files}
736
767
  help{chemistry}
768
+ help{stdlib}
769
+ help{math}
770
+ help{math::sqrt}
737
771
  ```
738
772
 
739
- Use `help{function_name}` for built-in documentation. The ANSI-colored help screen
740
- also includes a quick reference to the standard-library packages.
773
+ Use `help{function_name}` for built-in documentation and
774
+ `help{module::function}` for standard-library function documentation. The
775
+ help index also lists the available standard-library packages.
741
776
 
742
777
  ## Shell integration and scripting
743
778
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chemql-python"
7
- version = "1.4.1"
7
+ version = "1.4.2"
8
8
  authors = [
9
9
  { name = "Mohammad Rakibul Islam", email = "rakibulofficial1017@gmail.com" }
10
10
  ]