chemql-python 1.1.0__tar.gz → 1.2.1__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 (24) hide show
  1. {chemql_python-1.1.0/src/chemql_python.egg-info → chemql_python-1.2.1}/PKG-INFO +93 -11
  2. {chemql_python-1.1.0 → chemql_python-1.2.1}/README.md +92 -10
  3. {chemql_python-1.1.0 → chemql_python-1.2.1}/pyproject.toml +1 -1
  4. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/__init__.py +902 -511
  5. {chemql_python-1.1.0 → chemql_python-1.2.1/src/chemql_python.egg-info}/PKG-INFO +93 -11
  6. {chemql_python-1.1.0 → chemql_python-1.2.1}/LICENSE +0 -0
  7. {chemql_python-1.1.0 → chemql_python-1.2.1}/setup.cfg +0 -0
  8. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/__main__.py +0 -0
  9. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/BondEnergies.json +0 -0
  10. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/MoleculeBonds.json +0 -0
  11. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/Molecules.json +0 -0
  12. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/PeriodicTableJSON.json +0 -0
  13. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/Reactions.json +0 -0
  14. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  15. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  16. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql/html/periodic_table.html +0 -0
  17. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql_python.egg-info/SOURCES.txt +0 -0
  18. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  19. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql_python.egg-info/entry_points.txt +0 -0
  20. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql_python.egg-info/requires.txt +0 -0
  21. {chemql_python-1.1.0 → chemql_python-1.2.1}/src/chemql_python.egg-info/top_level.txt +0 -0
  22. {chemql_python-1.1.0 → chemql_python-1.2.1}/tests/test_external_molecule_lookup.py +0 -0
  23. {chemql_python-1.1.0 → chemql_python-1.2.1}/tests/test_public_api.py +0 -0
  24. {chemql_python-1.1.0 → chemql_python-1.2.1}/tests/test_reactions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 1.1.0
3
+ Version: 1.2.1
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
@@ -17,13 +17,15 @@ Dynamic: license-file
17
17
  shell commands in one interactive environment.**
18
18
 
19
19
  ChemQL is a command-line chemistry query language for exploring chemical
20
- elements, molecules, and reactions. It combines a small SQL-inspired
20
+ elements, molecules, and reactions. Version 1.2.0 combines database-style
21
+ chemistry queries, reaction tools, Python interoperability, reusable functions
22
+ and macros, and a persistent shell in one scriptable environment. It combines a small SQL-inspired
21
23
  query syntax with a persistent Python environment, reaction utilities,
22
24
  optional external molecule lookup, and tools for running repeatable
23
25
  scripts.
24
26
 
25
- > **Version covered by this README:** 1.1.0\
26
- > The examples below describe the current ChemQL 1.1.0 source. Dataset
27
+ > **Version covered by this README:** 1.2.0\
28
+ > The examples below describe the ChemQL 1.2.0 source. Dataset
27
29
  > contents and external-service availability can affect individual
28
30
  > lookup results.
29
31
 
@@ -42,6 +44,7 @@ scripts.
42
44
  sources](#molecules-from-external-chemistry-sources)
43
45
  - [Chemical reactions](#chemical-reactions)
44
46
  - [Balancing equations](#balancing-equations)
47
+ - [Preprocessor, functions, and macros](#preprocessor-functions-and-macros)
45
48
  - [Mixing ChemQL with Python](#mixing-chemql-with-python)
46
49
  - [Multiline Python blocks](#multiline-python-blocks)
47
50
  - [Running shell commands](#running-shell-commands)
@@ -81,6 +84,12 @@ scripts.
81
84
  - **Hybrid Python:** execute Python expressions and statements, retain
82
85
  variables between commands, and embed ChemQL query results directly
83
86
  inside Python.
87
+ - **Preprocessor definitions:** define reusable literal values with `define`
88
+ and `@NAME` references.
89
+ - **User-defined functions:** define reusable Python-backed functions with
90
+ positional arguments and return values.
91
+ - **Source-generating macros:** define reusable ChemQL command sequences
92
+ and expand them with arguments.
84
93
  - **Python control flow:** use `if`/`elif`/`else`, `for`, `while`,
85
94
  `break`, and `continue` blocks.
86
95
  - **Multiline Python:** use `[[[` ... `]]]` for a single multiline
@@ -527,6 +536,71 @@ balance N2 + H2 <-> NH3
527
536
  The result is represented as a reaction object, which can also be
528
537
  queried or inspected from Python.
529
538
 
539
+ ## Preprocessor, functions, and macros
540
+
541
+ ChemQL 1.2.0 adds three ways to reuse values and logic. These declarations
542
+ are processed in source order: definitions affect later lines, not earlier
543
+ ones. They persist during the current ChemQL process/session; they are not
544
+ saved automatically between separate launches.
545
+
546
+ ### Literal definitions
547
+
548
+ Use `define NAME value` to store a literal replacement. Reference it as
549
+ `@NAME` in later ChemQL commands, Python blocks, or shell commands.
550
+
551
+ ``` text
552
+ define MAX 9
553
+ define ELEMENT "Hydrogen"
554
+ definitions
555
+
556
+ search elements number <= @MAX return name symbol number
557
+ search elements name = @ELEMENT
558
+ remove definition MAX
559
+ ```
560
+
561
+ Definitions are textual replacements, not typed variables. They are
562
+ expanded literally, including inside quoted strings, and a definition's
563
+ replacement text is not recursively expanded in the same pass. `definitions`
564
+ shows active definitions; `remove definition NAME` removes one.
565
+
566
+ ### User-defined functions
567
+
568
+ Declare a function with `func NAME` and finish it with `endfunc`. Use `\1`,
569
+ `\2`, and so on as positional argument placeholders. A `return` line gives
570
+ the function's result; arguments are evaluated as Python expressions.
571
+
572
+ ``` text
573
+ func square
574
+ return [\1 * \1]
575
+ endfunc
576
+
577
+ square{5}
578
+ search molecules molecular_weight < square{5} return name formula molecular_weight
579
+ ```
580
+
581
+ Functions can contain multiple commands and `[[[` multiline Python blocks.
582
+ Function-local Python assignments are restored after the call; return a value
583
+ explicitly when you need one. Function calls use braces, for example
584
+ `name{argument1, argument2}`.
585
+
586
+ ### Macros
587
+
588
+ Macros expand into ChemQL source lines. Declare one using `define NAME{}`
589
+ and close it with `enddefine`. Use `\1`, `\2`, etc. for arguments, then call
590
+ the macro with `@NAME{arguments}`.
591
+
592
+ ``` text
593
+ define light_molecules{}
594
+ search molecules molecular_weight < \1 return name formula molecular_weight
595
+ enddefine
596
+
597
+ @light_molecules{50}
598
+ ```
599
+
600
+ Macros are useful for reusable query recipes or command sequences. Arguments
601
+ are substituted into the macro's source text, so quote or validate values
602
+ appropriately when passing text that contains spaces or special characters.
603
+
530
604
  ## Mixing ChemQL with Python
531
605
 
532
606
  ChemQL is a hybrid language: a single-line Python expression or
@@ -754,6 +828,19 @@ cat explore.cql | chemql
754
828
  On Windows PowerShell, use `Get-Content explore.cql | chemql` or
755
829
  redirect a file into the command.
756
830
 
831
+ ### Show version and upgrade
832
+
833
+ ``` bash
834
+ chemql --version
835
+ chemql --upgrade
836
+ chemql --upgrade 1.2.0
837
+ ```
838
+
839
+ `--upgrade` installs the latest published `chemql-python` release; supplying a
840
+ version requests that specific release. The optional `--force` (also accepted
841
+ as `--dangerously`) bypasses system-package protections. Use that option only
842
+ when you understand the consequences for your Python environment.
843
+
757
844
  ### Disable ANSI escape sequences
758
845
 
759
846
  ``` bash
@@ -975,11 +1062,6 @@ against appropriate primary or authoritative sources.
975
1062
  Python and shell blocks execute real code with your operating-system
976
1063
  user's permissions. Do not run scripts or commands you do not trust.
977
1064
 
978
- ## License
979
-
980
- [MIT License](https://github.com/rakibulofficial1017/ChemQL/blob/main/LICENSE)
981
-
982
- Created by [Mohammad Rakibul Islam](https://github.com/rakibulofficial1017).
983
- Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017/ChemQL).
984
-
1065
+ ------------------------------------------------------------------------
985
1066
 
1067
+ **ChemQL --- Python Chemistry Query Language**
@@ -4,13 +4,15 @@
4
4
  shell commands in one interactive environment.**
5
5
 
6
6
  ChemQL is a command-line chemistry query language for exploring chemical
7
- elements, molecules, and reactions. It combines a small SQL-inspired
7
+ elements, molecules, and reactions. Version 1.2.0 combines database-style
8
+ chemistry queries, reaction tools, Python interoperability, reusable functions
9
+ and macros, and a persistent shell in one scriptable environment. It combines a small SQL-inspired
8
10
  query syntax with a persistent Python environment, reaction utilities,
9
11
  optional external molecule lookup, and tools for running repeatable
10
12
  scripts.
11
13
 
12
- > **Version covered by this README:** 1.1.0\
13
- > The examples below describe the current ChemQL 1.1.0 source. Dataset
14
+ > **Version covered by this README:** 1.2.0\
15
+ > The examples below describe the ChemQL 1.2.0 source. Dataset
14
16
  > contents and external-service availability can affect individual
15
17
  > lookup results.
16
18
 
@@ -29,6 +31,7 @@ scripts.
29
31
  sources](#molecules-from-external-chemistry-sources)
30
32
  - [Chemical reactions](#chemical-reactions)
31
33
  - [Balancing equations](#balancing-equations)
34
+ - [Preprocessor, functions, and macros](#preprocessor-functions-and-macros)
32
35
  - [Mixing ChemQL with Python](#mixing-chemql-with-python)
33
36
  - [Multiline Python blocks](#multiline-python-blocks)
34
37
  - [Running shell commands](#running-shell-commands)
@@ -68,6 +71,12 @@ scripts.
68
71
  - **Hybrid Python:** execute Python expressions and statements, retain
69
72
  variables between commands, and embed ChemQL query results directly
70
73
  inside Python.
74
+ - **Preprocessor definitions:** define reusable literal values with `define`
75
+ and `@NAME` references.
76
+ - **User-defined functions:** define reusable Python-backed functions with
77
+ positional arguments and return values.
78
+ - **Source-generating macros:** define reusable ChemQL command sequences
79
+ and expand them with arguments.
71
80
  - **Python control flow:** use `if`/`elif`/`else`, `for`, `while`,
72
81
  `break`, and `continue` blocks.
73
82
  - **Multiline Python:** use `[[[` ... `]]]` for a single multiline
@@ -514,6 +523,71 @@ balance N2 + H2 <-> NH3
514
523
  The result is represented as a reaction object, which can also be
515
524
  queried or inspected from Python.
516
525
 
526
+ ## Preprocessor, functions, and macros
527
+
528
+ ChemQL 1.2.0 adds three ways to reuse values and logic. These declarations
529
+ are processed in source order: definitions affect later lines, not earlier
530
+ ones. They persist during the current ChemQL process/session; they are not
531
+ saved automatically between separate launches.
532
+
533
+ ### Literal definitions
534
+
535
+ Use `define NAME value` to store a literal replacement. Reference it as
536
+ `@NAME` in later ChemQL commands, Python blocks, or shell commands.
537
+
538
+ ``` text
539
+ define MAX 9
540
+ define ELEMENT "Hydrogen"
541
+ definitions
542
+
543
+ search elements number <= @MAX return name symbol number
544
+ search elements name = @ELEMENT
545
+ remove definition MAX
546
+ ```
547
+
548
+ Definitions are textual replacements, not typed variables. They are
549
+ expanded literally, including inside quoted strings, and a definition's
550
+ replacement text is not recursively expanded in the same pass. `definitions`
551
+ shows active definitions; `remove definition NAME` removes one.
552
+
553
+ ### User-defined functions
554
+
555
+ Declare a function with `func NAME` and finish it with `endfunc`. Use `\1`,
556
+ `\2`, and so on as positional argument placeholders. A `return` line gives
557
+ the function's result; arguments are evaluated as Python expressions.
558
+
559
+ ``` text
560
+ func square
561
+ return [\1 * \1]
562
+ endfunc
563
+
564
+ square{5}
565
+ search molecules molecular_weight < square{5} return name formula molecular_weight
566
+ ```
567
+
568
+ Functions can contain multiple commands and `[[[` multiline Python blocks.
569
+ Function-local Python assignments are restored after the call; return a value
570
+ explicitly when you need one. Function calls use braces, for example
571
+ `name{argument1, argument2}`.
572
+
573
+ ### Macros
574
+
575
+ Macros expand into ChemQL source lines. Declare one using `define NAME{}`
576
+ and close it with `enddefine`. Use `\1`, `\2`, etc. for arguments, then call
577
+ the macro with `@NAME{arguments}`.
578
+
579
+ ``` text
580
+ define light_molecules{}
581
+ search molecules molecular_weight < \1 return name formula molecular_weight
582
+ enddefine
583
+
584
+ @light_molecules{50}
585
+ ```
586
+
587
+ Macros are useful for reusable query recipes or command sequences. Arguments
588
+ are substituted into the macro's source text, so quote or validate values
589
+ appropriately when passing text that contains spaces or special characters.
590
+
517
591
  ## Mixing ChemQL with Python
518
592
 
519
593
  ChemQL is a hybrid language: a single-line Python expression or
@@ -741,6 +815,19 @@ cat explore.cql | chemql
741
815
  On Windows PowerShell, use `Get-Content explore.cql | chemql` or
742
816
  redirect a file into the command.
743
817
 
818
+ ### Show version and upgrade
819
+
820
+ ``` bash
821
+ chemql --version
822
+ chemql --upgrade
823
+ chemql --upgrade 1.2.0
824
+ ```
825
+
826
+ `--upgrade` installs the latest published `chemql-python` release; supplying a
827
+ version requests that specific release. The optional `--force` (also accepted
828
+ as `--dangerously`) bypasses system-package protections. Use that option only
829
+ when you understand the consequences for your Python environment.
830
+
744
831
  ### Disable ANSI escape sequences
745
832
 
746
833
  ``` bash
@@ -962,11 +1049,6 @@ against appropriate primary or authoritative sources.
962
1049
  Python and shell blocks execute real code with your operating-system
963
1050
  user's permissions. Do not run scripts or commands you do not trust.
964
1051
 
965
- ## License
966
-
967
- [MIT License](https://github.com/rakibulofficial1017/ChemQL/blob/main/LICENSE)
968
-
969
- Created by [Mohammad Rakibul Islam](https://github.com/rakibulofficial1017).
970
- Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017/ChemQL).
971
-
1052
+ ------------------------------------------------------------------------
972
1053
 
1054
+ **ChemQL --- Python Chemistry Query Language**
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chemql-python"
7
- version = "1.1.0"
7
+ version = "1.2.1"
8
8
  authors = [
9
9
  { name = "Mohammad Rakibul Islam", email = "rakibulofficial1017@gmail.com" }
10
10
  ]