chemql-python 1.2.3__tar.gz → 1.2.4__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.2.3/src/chemql_python.egg-info → chemql_python-1.2.4}/PKG-INFO +1 -1
  2. {chemql_python-1.2.3 → chemql_python-1.2.4}/pyproject.toml +1 -1
  3. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/__init__.py +38 -11
  4. {chemql_python-1.2.3 → chemql_python-1.2.4/src/chemql_python.egg-info}/PKG-INFO +1 -1
  5. {chemql_python-1.2.3 → chemql_python-1.2.4}/LICENSE +0 -0
  6. {chemql_python-1.2.3 → chemql_python-1.2.4}/README.md +0 -0
  7. {chemql_python-1.2.3 → chemql_python-1.2.4}/setup.cfg +0 -0
  8. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/__main__.py +0 -0
  9. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/BondEnergies.json +0 -0
  10. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/MoleculeBonds.json +0 -0
  11. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/Molecules.json +0 -0
  12. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/PeriodicTableJSON.json +0 -0
  13. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/Reactions.json +0 -0
  14. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  15. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  16. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql/html/periodic_table.html +0 -0
  17. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql_python.egg-info/SOURCES.txt +0 -0
  18. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  19. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql_python.egg-info/entry_points.txt +0 -0
  20. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql_python.egg-info/requires.txt +0 -0
  21. {chemql_python-1.2.3 → chemql_python-1.2.4}/src/chemql_python.egg-info/top_level.txt +0 -0
  22. {chemql_python-1.2.3 → chemql_python-1.2.4}/tests/test_external_molecule_lookup.py +0 -0
  23. {chemql_python-1.2.3 → chemql_python-1.2.4}/tests/test_public_api.py +0 -0
  24. {chemql_python-1.2.3 → chemql_python-1.2.4}/tests/test_reactions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 1.2.3
3
+ Version: 1.2.4
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chemql-python"
7
- version = "1.2.3"
7
+ version = "1.2.4"
8
8
  authors = [
9
9
  { name = "Mohammad Rakibul Islam", email = "rakibulofficial1017@gmail.com" }
10
10
  ]
@@ -47,7 +47,7 @@ __all__ = [
47
47
  "__version__"
48
48
  ]
49
49
 
50
- __version__ = "1.2.3"
50
+ __version__ = "1.2.4"
51
51
 
52
52
  # Persistent preprocessor/function state for the current ChemQL session.
53
53
  DEFINITIONS = {}
@@ -108,6 +108,18 @@ def _split_function_arguments(source):
108
108
  if tail or source.strip():
109
109
  args.append(tail)
110
110
  return args
111
+ def is_block_header(line):
112
+ """Return True only for actual ChemQL block headers."""
113
+ if not (line.startswith("[") and line.endswith("]")):
114
+ return False
115
+
116
+ code = line[1:-1].strip()
117
+
118
+ return (
119
+ code.startswith("if ")
120
+ or code.startswith("for ")
121
+ or code.startswith("while ")
122
+ )
111
123
 
112
124
  def _call_function(name, arguments):
113
125
  """Call a ChemQL function, including let assignments and block syntax."""
@@ -194,13 +206,13 @@ def _call_function(name, arguments):
194
206
 
195
207
  # Recognize block headers generically, while excluding
196
208
  # closing and branch markers from being treated as headers.
197
- generic_header = re.match(
198
- r"^\[\s*(?!endblock\b|else\b|elif\b)"
199
- r"[A-Za-z_]\w*\b.*\]\s*$",
200
- line,
201
- )
209
+ # generic_header = re.match(
210
+ # r"^\[\s*(?!endblock\b|else\b|elif\b)"
211
+ # r"[A-Za-z_]\w*\b.*\]\s*$",
212
+ # line,
213
+ # )
202
214
 
203
- if is_python_block_header(line) or generic_header:
215
+ if is_block_header(line):
204
216
  end = find_endblock(lines, i + 1)
205
217
 
206
218
  block_body = [
@@ -2509,15 +2521,30 @@ def find_endblock(lines, start):
2509
2521
  for i in range(start, len(lines)):
2510
2522
  stripped = lines[i].strip()
2511
2523
 
2512
- if is_python_block_header(stripped):
2513
- depth += 1
2514
-
2515
- elif stripped == "[endblock]":
2524
+ # Closing block.
2525
+ if stripped == "[endblock]":
2516
2526
  depth -= 1
2517
2527
 
2518
2528
  if depth == 0:
2519
2529
  return i
2520
2530
 
2531
+ continue
2532
+
2533
+ # Branch markers do not start new blocks.
2534
+ if stripped in ("[else]", "[endif]", "[endfor]", "[endwhile]"):
2535
+ continue
2536
+
2537
+ # Recognize both validated Python headers and generic
2538
+ # ChemQL block headers, consistently with _call_function().
2539
+ generic_header = re.match(
2540
+ r"^\[\s*(?!endblock\b|else\b|elif\b)"
2541
+ r"[A-Za-z_]\w*\b.*\]\s*$",
2542
+ stripped,
2543
+ )
2544
+
2545
+ if is_block_header(stripped):
2546
+ depth += 1
2547
+
2521
2548
  raise SyntaxError("Missing `[endblock]`")
2522
2549
 
2523
2550
  def remove_comments(line):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 1.2.3
3
+ Version: 1.2.4
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
File without changes
File without changes
File without changes