omlish 0.0.0.dev199__py3-none-any.whl → 0.0.0.dev201__py3-none-any.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.
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev199'
2
- __revision__ = '19849595c30a781a42e5587cf2915dd1fcc1211a'
1
+ __version__ = '0.0.0.dev201'
2
+ __revision__ = '77be9dbd97d16b54293dbf9f3803e3fa882ecc5f'
3
3
 
4
4
 
5
5
  #
omlish/configs/all.py ADDED
@@ -0,0 +1,43 @@
1
+ # ruff: noqa: I001
2
+ from .formats import ( # noqa
3
+ ConfigData as Data,
4
+
5
+ ConfigLoader as Loader,
6
+
7
+ ConfigRenderer as Renderer,
8
+
9
+ ObjConfigData as ObjData,
10
+
11
+ JsonConfigData as JsonData,
12
+ JsonConfigLoader as JsonLoader,
13
+ JsonConfigRenderer as JsonRenderer,
14
+
15
+ TomlConfigData as TomlData,
16
+ TomlConfigLoader as TomlLoader,
17
+ TomlConfigRenderer as TomlRenderer,
18
+
19
+ YamlConfigData as YamlData,
20
+ YamlConfigLoader as YamlLoader,
21
+ YamlConfigRenderer as YamlRenderer,
22
+
23
+ IniConfigData as IniData,
24
+ IniConfigLoader as IniLoader,
25
+ IniConfigRenderer as IniRenderer,
26
+
27
+ SwitchedConfigFileLoader as SwitchedFileLoader,
28
+
29
+ DEFAULT_CONFIG_LOADERS as DEFAULT_LOADERS,
30
+ DEFAULT_CONFIG_LOADER as DEFAULT_LOADER,
31
+ DEFAULT_CONFIG_FILE_LOADER as DEFAULT_FILE_LOADER,
32
+
33
+ SwitchedConfigRenderer as SwitchedRenderer,
34
+
35
+ DEFAULT_CONFIG_RENDERERS as DEFAULT_RENDERERS,
36
+ DEFAULT_CONFIG_RENDERER as DEFAULT_RENDERER,
37
+ )
38
+
39
+ from .types import ( # noqa
40
+ ConfigMap as Map,
41
+ )
42
+
43
+ from .processing import all as processing # noqa
@@ -0,0 +1,33 @@
1
+ # ruff: noqa: I001
2
+ from .flattening import ( # noqa
3
+ ConfigFlattening as Flattening,
4
+ )
5
+
6
+ from .inheritance import ( # noqa
7
+ build_config_inherited_values as build_inherited_values,
8
+ )
9
+
10
+ from .matching import ( # noqa
11
+ MatchingConfigRewriter as MatchingRewriter,
12
+
13
+ matched_config_rewrite as matched_rewrite,
14
+ )
15
+
16
+ from .names import ( # noqa
17
+ build_config_named_children as build_named_children,
18
+ )
19
+
20
+ from .rewriting import ( # noqa
21
+ ConfigRewriterItem as RewriterItem,
22
+ ConfigRewriterPath as RewriterPath,
23
+
24
+ RawConfigMetadata as RawMetadata,
25
+
26
+ ConfigRewriter as Rewriter,
27
+ )
28
+
29
+ from .strings import ( # noqa
30
+ StringConfigRewriter as StringRewriter,
31
+
32
+ format_config_strings as format_strings,
33
+ )
@@ -17,13 +17,13 @@ class StdBuilder(
17
17
  SelectBuilder,
18
18
  StmtBuilder,
19
19
 
20
+ RelationBuilder,
21
+
20
22
  MultiBuilder,
21
23
  BinaryBuilder,
22
24
  UnaryBuilder,
23
25
  ExprBuilder,
24
26
 
25
- RelationBuilder,
26
-
27
27
  ParamBuilder,
28
28
 
29
29
  NameBuilder,
@@ -30,7 +30,7 @@ class Insert(Stmt, lang.Final):
30
30
  CanValues: ta.TypeAlias = Values | ta.Sequence[CanExpr]
31
31
 
32
32
 
33
- class InsertBuilder(ExprBuilder, RelationBuilder):
33
+ class InsertBuilder(RelationBuilder, ExprBuilder):
34
34
  def values(self, vs: CanValues) -> Values:
35
35
  if isinstance(vs, Values):
36
36
  return vs
@@ -17,6 +17,7 @@ from .binary import BinaryOps
17
17
  from .exprs import Expr
18
18
  from .inserts import Values
19
19
  from .multi import MultiKind
20
+ from .relations import JoinKind
20
21
  from .relations import Relation
21
22
  from .selects import Select
22
23
  from .stmts import Stmt
@@ -66,8 +67,12 @@ def _install_standard_marshalling() -> None:
66
67
  msh.STANDARD_MARSHALER_FACTORIES[0:0] = [msh.TypeMapMarshalerFactory({ty: OpMarshalerUnmarshaler(ty, ns)})]
67
68
  msh.STANDARD_UNMARSHALER_FACTORIES[0:0] = [msh.TypeMapUnmarshalerFactory({ty: OpMarshalerUnmarshaler(ty, ns)})]
68
69
 
69
- msh.STANDARD_MARSHALER_FACTORIES[0:0] = [msh.TypeMapMarshalerFactory({MultiKind: LowerEnumMarshaler(MultiKind)})]
70
- msh.STANDARD_UNMARSHALER_FACTORIES[0:0] = [msh.TypeMapUnmarshalerFactory({MultiKind: LowerEnumMarshaler(MultiKind)})] # noqa
70
+ ets = [
71
+ JoinKind,
72
+ MultiKind,
73
+ ]
74
+ msh.STANDARD_MARSHALER_FACTORIES[0:0] = [msh.TypeMapMarshalerFactory({t: LowerEnumMarshaler(t) for t in ets})]
75
+ msh.STANDARD_UNMARSHALER_FACTORIES[0:0] = [msh.TypeMapUnmarshalerFactory({t: LowerEnumMarshaler(t) for t in ets})]
71
76
 
72
77
  for cls in [
73
78
  Expr,
@@ -3,15 +3,18 @@ TODO:
3
3
  - join
4
4
  - subquery
5
5
  """
6
+ import enum
6
7
  import typing as ta
7
8
 
8
9
  from ... import dataclasses as dc
9
10
  from ... import lang
10
11
  from .base import Node
12
+ from .exprs import CanExpr
13
+ from .exprs import Expr
11
14
  from .idents import Ident
15
+ from .multi import MultiBuilder
12
16
  from .names import CanName
13
17
  from .names import Name
14
- from .names import NameBuilder
15
18
 
16
19
 
17
20
  ##
@@ -21,22 +24,100 @@ class Relation(Node, lang.Abstract):
21
24
  pass
22
25
 
23
26
 
27
+ #
28
+
29
+
24
30
  class Table(Relation, lang.Final):
25
31
  n: Name
26
32
  a: Ident | None = dc.xfield(None, repr_fn=dc.opt_repr)
27
33
 
28
34
 
35
+ #
36
+
37
+
38
+ class JoinKind(enum.Enum):
39
+ DEFAULT = enum.auto()
40
+ INNER = enum.auto()
41
+ LEFT = enum.auto()
42
+ LEFT_OUTER = enum.auto()
43
+ RIGHT = enum.auto()
44
+ RIGHT_OUTER = enum.auto()
45
+ FULL = enum.auto()
46
+ FULL_OUTER = enum.auto()
47
+ CROSS = enum.auto()
48
+ NATURAL = enum.auto()
49
+
50
+
51
+ class Join(Relation, lang.Final):
52
+ k: JoinKind
53
+ l: Relation
54
+ r: Relation
55
+
56
+ c: Expr | None = None
57
+
58
+
59
+ ##
60
+
61
+
29
62
  CanTable: ta.TypeAlias = Table | CanName
30
63
  CanRelation: ta.TypeAlias = Relation | CanTable
31
64
 
32
65
 
33
- class RelationBuilder(NameBuilder):
66
+ class RelationBuilder(MultiBuilder):
34
67
  def table(self, n: CanTable) -> Table:
35
68
  if isinstance(n, Table):
36
69
  return n
37
70
  else:
38
71
  return Table(self.name(n))
39
72
 
73
+ #
74
+
75
+ def join(
76
+ self,
77
+ k: JoinKind,
78
+ l: CanRelation,
79
+ r: CanRelation,
80
+ *cs: CanExpr,
81
+ ) -> Join:
82
+ return Join(
83
+ k,
84
+ self.relation(l),
85
+ self.relation(r),
86
+ self.or_(*cs) if cs else None,
87
+ )
88
+
89
+ def default_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
90
+ return self.join(JoinKind.DEFAULT, l, r, *cs)
91
+
92
+ def inner_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
93
+ return self.join(JoinKind.INNER, l, r, *cs)
94
+
95
+ def left_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
96
+ return self.join(JoinKind.LEFT, l, r, *cs)
97
+
98
+ def left_outer_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
99
+ return self.join(JoinKind.LEFT_OUTER, l, r, *cs)
100
+
101
+ def right_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
102
+ return self.join(JoinKind.RIGHT, l, r, *cs)
103
+
104
+ def right_outer_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
105
+ return self.join(JoinKind.RIGHT_OUTER, l, r, *cs)
106
+
107
+ def full_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
108
+ return self.join(JoinKind.FULL, l, r, *cs)
109
+
110
+ def full_outer_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
111
+ return self.join(JoinKind.FULL_OUTER, l, r, *cs)
112
+
113
+ def cross_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
114
+ return self.join(JoinKind.CROSS, l, r, *cs)
115
+
116
+ def natural_join(self, l: CanRelation, r: CanRelation, *cs: CanExpr) -> Join:
117
+ return self.join(JoinKind.NATURAL, l, r, *cs)
118
+
119
+ #
120
+
40
121
  def relation(self, o: CanRelation) -> Relation:
41
122
  if isinstance(o, Relation):
42
123
  return o
@@ -36,6 +36,8 @@ from .multi import Multi
36
36
  from .multi import MultiKind
37
37
  from .names import Name
38
38
  from .params import Param
39
+ from .relations import Join
40
+ from .relations import JoinKind
39
41
  from .relations import Table
40
42
  from .selects import Select
41
43
  from .selects import SelectItem
@@ -156,7 +158,6 @@ class StdRenderer(Renderer):
156
158
  MULTI_KIND_TO_STR: ta.ClassVar[ta.Mapping[MultiKind, str]] = {
157
159
  MultiKind.AND: 'and',
158
160
  MultiKind.OR: 'or',
159
-
160
161
  }
161
162
 
162
163
  @Renderer.render.register
@@ -187,6 +188,30 @@ class StdRenderer(Renderer):
187
188
  self._out.write(' as ')
188
189
  self.render(o.a)
189
190
 
191
+ JOIN_KIND_TO_STR: ta.ClassVar[ta.Mapping[JoinKind, str]] = {
192
+ JoinKind.DEFAULT: 'join',
193
+ JoinKind.INNER: 'inner join',
194
+ JoinKind.LEFT: 'left join',
195
+ JoinKind.LEFT_OUTER: 'left outer join',
196
+ JoinKind.RIGHT: 'right join',
197
+ JoinKind.RIGHT_OUTER: 'right outer join',
198
+ JoinKind.FULL: 'full join',
199
+ JoinKind.FULL_OUTER: 'full outer join',
200
+ JoinKind.CROSS: 'cross join',
201
+ JoinKind.NATURAL: 'natural join',
202
+ }
203
+
204
+ @Renderer.render.register
205
+ def render_join(self, o: Join) -> None:
206
+ self.render(o.l)
207
+ self._out.write(' ')
208
+ self._out.write(self.JOIN_KIND_TO_STR[o.k])
209
+ self._out.write(' ')
210
+ self.render(o.r)
211
+ if o.c is not None:
212
+ self._out.write(' on ')
213
+ self.render(o.c)
214
+
190
215
  # selects
191
216
 
192
217
  @Renderer.render.register
@@ -30,7 +30,7 @@ class Select(Stmt, lang.Final):
30
30
  CanSelectItem: ta.TypeAlias = SelectItem | CanExpr
31
31
 
32
32
 
33
- class SelectBuilder(ExprBuilder, RelationBuilder):
33
+ class SelectBuilder(RelationBuilder, ExprBuilder):
34
34
  def select_item(self, o: CanSelectItem) -> SelectItem:
35
35
  if isinstance(o, SelectItem):
36
36
  return o
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: omlish
3
- Version: 0.0.0.dev199
3
+ Version: 0.0.0.dev201
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=dyIpveH7Z8OnQp2pTn6NVv7LCDXVrozJWAzbk8PBavg,7950
2
- omlish/__about__.py,sha256=5dGYq3bnMhCNzQiqCyBYVrYz1wa-t6EDj7KPBgzN0nU,3409
2
+ omlish/__about__.py,sha256=nozjeM6WZjCDpl0YL18Qfh8ve_0Ihl-hf7OLBlfHY70,3409
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/c3.py,sha256=ubu7lHwss5V4UznbejAI0qXhXahrU01MysuHOZI9C4U,8116
5
5
  omlish/cached.py,sha256=UI-XTFBwA6YXWJJJeBn-WkwBkfzDjLBBaZf4nIJA9y0,510
@@ -150,11 +150,13 @@ omlish/concurrent/executors.py,sha256=FYKCDYYuj-OgMa8quLsA47SfFNX3KDJvRENVk8NDsr
150
150
  omlish/concurrent/futures.py,sha256=J2s9wYURUskqRJiBbAR0PNEAp1pXbIMYldOVBTQduQY,4239
151
151
  omlish/concurrent/threadlets.py,sha256=JfirbTDJgy9Ouokz_VmHeAAPS7cih8qMUJrN-owwXD4,2423
152
152
  omlish/configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
153
+ omlish/configs/all.py,sha256=kziwjzUBkf8AT0w7Pq7JX2jtkQVOQ5R1wJyn6hfTN5k,1055
153
154
  omlish/configs/classes.py,sha256=GLbB8xKjHjjoUQRCUQm3nEjM8z1qNTx9gPV7ODSt5dg,1317
154
155
  omlish/configs/formats.py,sha256=RJw4Rzp7vlTd5YyAvpAoruQnk45v8dGPtPWwqH7aYyE,5301
155
156
  omlish/configs/nginx.py,sha256=XuX9yyb0_MwkJ8esKiMS9gFkqHUPza_uCprhnWykNy8,2051
156
157
  omlish/configs/types.py,sha256=t5_32MVRSKxbxor1hl1wRGKYm75F6Atisd_RYsN5ELU,103
157
158
  omlish/configs/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
159
+ omlish/configs/processing/all.py,sha256=roIQ7EZJXSzsyUxNHNJaZsXcD2jdT46Ly1XXfG8xEcI,722
158
160
  omlish/configs/processing/flattening.py,sha256=1duZH5zbrGuoYqaJco5LN5qx6e76QP5pHbIyItkQsFY,5021
159
161
  omlish/configs/processing/inheritance.py,sha256=lFD8eWRE0cG0Z3-eCu7pMsP2skWhUNaoAtWi9fNfn8k,1218
160
162
  omlish/configs/processing/matching.py,sha256=JMS9r58pMCBbpewOhPY5oPtBu3uD6z6YBfZq4jnLwBE,1236
@@ -543,18 +545,18 @@ omlish/sql/alchemy/sqlean.py,sha256=RbkuOuFIfM4fowwKk8-sQ6Dxk-tTUwxS94nY5Kxt52s,
543
545
  omlish/sql/queries/__init__.py,sha256=8wdq6PBf5YzqQWFu-CE8om6BN38sDAD9UEz9VzkojzM,1337
544
546
  omlish/sql/queries/base.py,sha256=_8O3MbH_OEjBnhp2oIJUZ3ClaQ8l4Sj9BdPdsP0Ie-g,224
545
547
  omlish/sql/queries/binary.py,sha256=dcEzeEn104AMPuQ7QrJU2O-YCN3SUdxB5S4jaWKOUqY,2253
546
- omlish/sql/queries/building.py,sha256=lmHItVEi0IkIDEhYL1le8adNhjah0SHhffm59CZtpH4,643
548
+ omlish/sql/queries/building.py,sha256=J2ZDfDyLzRm8q5-TLAN6I_qjhs-7RpfW23yuCYYLf5k,643
547
549
  omlish/sql/queries/exprs.py,sha256=THeSyFF8bouDvU-Keej-hyFUwbp63bw0HpAF4lCYuiQ,1187
548
550
  omlish/sql/queries/idents.py,sha256=w2RxO6SR3K-u30S259OtnAZaPv7YA70PzY9R7RtuCQ8,891
549
- omlish/sql/queries/inserts.py,sha256=Uo0ewnLPEt43dnX5AJWOC9ioViou7xYes7sGT9lD_0k,1281
550
- omlish/sql/queries/marshal.py,sha256=uLN_gOqiYHBQioZEvg7OREycY0bzKwzBw5mnbg_0cio,2938
551
+ omlish/sql/queries/inserts.py,sha256=H0Dv_6l--T7WXuoJQbLFd23PnjXA-3RETegjYnPr9lc,1281
552
+ omlish/sql/queries/marshal.py,sha256=T94501RbQn8UsUiRJkklvehtxJTYm2XTp03urMl1fas,3011
551
553
  omlish/sql/queries/multi.py,sha256=7x6x-4jnPzxA6ZasBjnjFuhHFpWt5rGCua3UvuTMIJ0,837
552
554
  omlish/sql/queries/names.py,sha256=4sDvgRobMEt_6mDeuYVbCqHzLCOwpXUdEyyB4-QjxKo,1996
553
555
  omlish/sql/queries/ops.py,sha256=B7IDfjr2DW5LJhWoNaY1WW90BJhe5ZtmxIELhWXbW-0,129
554
556
  omlish/sql/queries/params.py,sha256=iR8tnetkZFWY378iUbPe08d86g-Wf1J3YqfZr_KhIwQ,1175
555
- omlish/sql/queries/relations.py,sha256=-d3n-dN17c3TPMZmzSplhWawllUzdq12XPDAuzoeMEQ,838
556
- omlish/sql/queries/rendering.py,sha256=NOJqwxK8yt3Morq5yhgI-zU_51MSyhDvSc8S-8tURVM,5946
557
- omlish/sql/queries/selects.py,sha256=8dqm4KyrJvOsW3KHSO7qLEfPlZa7sJDp8puuGxrfvoA,1369
557
+ omlish/sql/queries/relations.py,sha256=7YrEC9IjoVpRGLAFKRSRsHHnTmx-g7hBNXsOgP2HOuI,2998
558
+ omlish/sql/queries/rendering.py,sha256=8naCMwxVEFAJaMP5m2bf6kCyhvwFZhXiWYEma51fQ4k,6813
559
+ omlish/sql/queries/selects.py,sha256=RFySZ9sb-nE29QrLLbQ7JYZW_V_ifaFTcl-RQTgQncY,1369
558
560
  omlish/sql/queries/stmts.py,sha256=pBqwD7dRlqMu6uh6vR3xaWOEgbZCcFWbOQ9ryYd17T4,441
559
561
  omlish/sql/queries/unary.py,sha256=MEYBDZn_H0bexmUrJeONOv5-gIpYowUaXOsEHeQM4ks,1144
560
562
  omlish/sql/tabledefs/__init__.py,sha256=TvtQsp-jJu6_ZahyCOFAaElSSBcRftNyJpdiDPGYCDk,190
@@ -607,9 +609,9 @@ omlish/text/indent.py,sha256=YjtJEBYWuk8--b9JU_T6q4yxV85_TR7VEVr5ViRCFwk,1336
607
609
  omlish/text/minja.py,sha256=jZC-fp3Xuhx48ppqsf2Sf1pHbC0t8XBB7UpUUoOk2Qw,5751
608
610
  omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
609
611
  omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
610
- omlish-0.0.0.dev199.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
611
- omlish-0.0.0.dev199.dist-info/METADATA,sha256=5CdSnaX-AfmSBPr7KAcB65m0NC5yoHNFYaPcJSXYTI0,4264
612
- omlish-0.0.0.dev199.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
613
- omlish-0.0.0.dev199.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
614
- omlish-0.0.0.dev199.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
615
- omlish-0.0.0.dev199.dist-info/RECORD,,
612
+ omlish-0.0.0.dev201.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
613
+ omlish-0.0.0.dev201.dist-info/METADATA,sha256=_xm1Dh4zcl8xwhcC7IQ83_lZs18KGg7gufxEsCbfPHA,4264
614
+ omlish-0.0.0.dev201.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
615
+ omlish-0.0.0.dev201.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
616
+ omlish-0.0.0.dev201.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
617
+ omlish-0.0.0.dev201.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.7.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5