fakesnow 0.8.2__py3-none-any.whl → 0.9.1__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.
- fakesnow/__init__.py +8 -2
- fakesnow/checks.py +3 -3
- fakesnow/cli.py +54 -12
- fakesnow/fakes.py +135 -90
- fakesnow/fixtures.py +6 -6
- fakesnow/info_schema.py +9 -7
- fakesnow/macros.py +13 -0
- fakesnow/transforms.py +195 -32
- fakesnow-0.9.1.dist-info/LICENSE +201 -0
- fakesnow-0.9.1.dist-info/METADATA +362 -0
- fakesnow-0.9.1.dist-info/RECORD +17 -0
- fakesnow-0.8.2.dist-info/LICENSE +0 -20
- fakesnow-0.8.2.dist-info/METADATA +0 -174
- fakesnow-0.8.2.dist-info/RECORD +0 -16
- {fakesnow-0.8.2.dist-info → fakesnow-0.9.1.dist-info}/WHEEL +0 -0
- {fakesnow-0.8.2.dist-info → fakesnow-0.9.1.dist-info}/entry_points.txt +0 -0
- {fakesnow-0.8.2.dist-info → fakesnow-0.9.1.dist-info}/top_level.txt +0 -0
fakesnow/transforms.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
from pathlib import Path
|
4
|
+
from string import Template
|
3
5
|
from typing import cast
|
4
6
|
|
5
7
|
import sqlglot
|
@@ -19,7 +21,7 @@ def array_size(expression: exp.Expression) -> exp.Expression:
|
|
19
21
|
|
20
22
|
|
21
23
|
# TODO: move this into a Dialect as a transpilation
|
22
|
-
def create_database(expression: exp.Expression) -> exp.Expression:
|
24
|
+
def create_database(expression: exp.Expression, db_path: Path | None = None) -> exp.Expression:
|
23
25
|
"""Transform create database to attach database.
|
24
26
|
|
25
27
|
Example:
|
@@ -36,15 +38,71 @@ def create_database(expression: exp.Expression) -> exp.Expression:
|
|
36
38
|
if isinstance(expression, exp.Create) and str(expression.args.get("kind")).upper() == "DATABASE":
|
37
39
|
assert (ident := expression.find(exp.Identifier)), f"No identifier in {expression.sql}"
|
38
40
|
db_name = ident.this
|
41
|
+
db_file = f"{db_path/db_name}.db" if db_path else ":memory:"
|
42
|
+
|
39
43
|
return exp.Command(
|
40
44
|
this="ATTACH",
|
41
|
-
expression=exp.Literal(this=f"DATABASE '
|
45
|
+
expression=exp.Literal(this=f"DATABASE '{db_file}' AS {db_name}", is_string=True),
|
42
46
|
create_db_name=db_name,
|
43
47
|
)
|
44
48
|
|
45
49
|
return expression
|
46
50
|
|
47
51
|
|
52
|
+
SQL_DESCRIBE_TABLE = Template(
|
53
|
+
"""
|
54
|
+
SELECT
|
55
|
+
column_name AS "name",
|
56
|
+
CASE WHEN data_type = 'NUMBER' THEN 'NUMBER(' || numeric_precision || ',' || numeric_scale || ')'
|
57
|
+
WHEN data_type = 'TEXT' THEN 'VARCHAR(' || coalesce(character_maximum_length,16777216) || ')'
|
58
|
+
WHEN data_type = 'TIMESTAMP_NTZ' THEN 'TIMESTAMP_NTZ(9)'
|
59
|
+
WHEN data_type = 'TIMESTAMP_TZ' THEN 'TIMESTAMP_TZ(9)'
|
60
|
+
WHEN data_type = 'TIME' THEN 'TIME(9)'
|
61
|
+
WHEN data_type = 'BINARY' THEN 'BINARY(8388608)'
|
62
|
+
ELSE data_type END AS "type",
|
63
|
+
'COLUMN' AS "kind",
|
64
|
+
CASE WHEN is_nullable = 'YES' THEN 'Y' ELSE 'N' END AS "null?",
|
65
|
+
column_default AS "default",
|
66
|
+
'N' AS "primary key",
|
67
|
+
'N' AS "unique key",
|
68
|
+
NULL AS "check",
|
69
|
+
NULL AS "expression",
|
70
|
+
NULL AS "comment",
|
71
|
+
NULL AS "policy name",
|
72
|
+
NULL AS "privacy domain",
|
73
|
+
FROM information_schema._fs_columns_snowflake
|
74
|
+
WHERE table_catalog = '${catalog}' AND table_schema = '${schema}' AND table_name = '${table}'
|
75
|
+
ORDER BY ordinal_position
|
76
|
+
"""
|
77
|
+
)
|
78
|
+
|
79
|
+
|
80
|
+
def describe_table(
|
81
|
+
expression: exp.Expression, current_database: str | None = None, current_schema: str | None = None
|
82
|
+
) -> exp.Expression:
|
83
|
+
"""Redirect to the information_schema._fs_describe_table to match snowflake.
|
84
|
+
|
85
|
+
See https://docs.snowflake.com/en/sql-reference/sql/desc-table
|
86
|
+
"""
|
87
|
+
|
88
|
+
if (
|
89
|
+
isinstance(expression, exp.Describe)
|
90
|
+
and (kind := expression.args.get("kind"))
|
91
|
+
and isinstance(kind, str)
|
92
|
+
and kind.upper() == "TABLE"
|
93
|
+
and (table := expression.find(exp.Table))
|
94
|
+
):
|
95
|
+
catalog = table.catalog or current_database
|
96
|
+
schema = table.db or current_schema
|
97
|
+
|
98
|
+
return sqlglot.parse_one(
|
99
|
+
SQL_DESCRIBE_TABLE.substitute(catalog=catalog, schema=schema, table=table.name),
|
100
|
+
read="duckdb",
|
101
|
+
)
|
102
|
+
|
103
|
+
return expression
|
104
|
+
|
105
|
+
|
48
106
|
def drop_schema_cascade(expression: exp.Expression) -> exp.Expression:
|
49
107
|
"""Drop schema cascade.
|
50
108
|
|
@@ -75,7 +133,37 @@ def drop_schema_cascade(expression: exp.Expression) -> exp.Expression:
|
|
75
133
|
return new
|
76
134
|
|
77
135
|
|
78
|
-
def
|
136
|
+
def extract_comment_on_columns(expression: exp.Expression) -> exp.Expression:
|
137
|
+
"""Extract column comments, removing it from the Expression.
|
138
|
+
|
139
|
+
duckdb doesn't support comments. So we remove them from the expression and store them in the column_comment arg.
|
140
|
+
We also replace the transform the expression to NOP if the statement can't be executed by duckdb.
|
141
|
+
|
142
|
+
Args:
|
143
|
+
expression (exp.Expression): the expression that will be transformed.
|
144
|
+
|
145
|
+
Returns:
|
146
|
+
exp.Expression: The transformed expression, with any comment stored in the new 'table_comment' arg.
|
147
|
+
"""
|
148
|
+
|
149
|
+
if isinstance(expression, exp.AlterTable) and (actions := expression.args.get("actions")):
|
150
|
+
new_actions: list[exp.Expression] = []
|
151
|
+
col_comments: list[tuple[str, str]] = []
|
152
|
+
for a in actions:
|
153
|
+
if isinstance(a, exp.AlterColumn) and (comment := a.args.get("comment")):
|
154
|
+
col_comments.append((a.name, comment.this))
|
155
|
+
else:
|
156
|
+
new_actions.append(a)
|
157
|
+
if not new_actions:
|
158
|
+
expression = SUCCESS_NOP.copy()
|
159
|
+
else:
|
160
|
+
expression.set("actions", new_actions)
|
161
|
+
expression.args["col_comments"] = col_comments
|
162
|
+
|
163
|
+
return expression
|
164
|
+
|
165
|
+
|
166
|
+
def extract_comment_on_table(expression: exp.Expression) -> exp.Expression:
|
79
167
|
"""Extract table comment, removing it from the Expression.
|
80
168
|
|
81
169
|
duckdb doesn't support comments. So we remove them from the expression and store them in the table_comment arg.
|
@@ -106,7 +194,6 @@ def extract_comment(expression: exp.Expression) -> exp.Expression:
|
|
106
194
|
elif (
|
107
195
|
isinstance(expression, exp.Comment)
|
108
196
|
and (cexp := expression.args.get("expression"))
|
109
|
-
and isinstance(cexp, exp.Literal)
|
110
197
|
and (table := expression.find(exp.Table))
|
111
198
|
):
|
112
199
|
new = SUCCESS_NOP.copy()
|
@@ -117,9 +204,9 @@ def extract_comment(expression: exp.Expression) -> exp.Expression:
|
|
117
204
|
and (sexp := expression.find(exp.Set))
|
118
205
|
and not sexp.args["tag"]
|
119
206
|
and (eq := sexp.find(exp.EQ))
|
120
|
-
and (
|
121
|
-
and isinstance(
|
122
|
-
and
|
207
|
+
and (eid := eq.find(exp.Identifier))
|
208
|
+
and isinstance(eid.this, str)
|
209
|
+
and eid.this.upper() == "COMMENT"
|
123
210
|
and (lit := eq.find(exp.Literal))
|
124
211
|
and (table := expression.find(exp.Table))
|
125
212
|
):
|
@@ -266,8 +353,8 @@ def indices_to_json_extract(expression: exp.Expression) -> exp.Expression:
|
|
266
353
|
return expression
|
267
354
|
|
268
355
|
|
269
|
-
def
|
270
|
-
"""Redirect to the information_schema.
|
356
|
+
def information_schema_fs_columns_snowflake(expression: exp.Expression) -> exp.Expression:
|
357
|
+
"""Redirect to the information_schema._fs_columns_snowflake view which has metadata that matches snowflake.
|
271
358
|
|
272
359
|
Because duckdb doesn't store character_maximum_length or character_octet_length.
|
273
360
|
"""
|
@@ -278,13 +365,13 @@ def information_schema_columns_snowflake(expression: exp.Expression) -> exp.Expr
|
|
278
365
|
and tbl_exp.name.upper() == "COLUMNS"
|
279
366
|
and tbl_exp.db.upper() == "INFORMATION_SCHEMA"
|
280
367
|
):
|
281
|
-
tbl_exp.set("this", exp.Identifier(this="
|
368
|
+
tbl_exp.set("this", exp.Identifier(this="_FS_COLUMNS_SNOWFLAKE", quoted=False))
|
282
369
|
|
283
370
|
return expression
|
284
371
|
|
285
372
|
|
286
|
-
def
|
287
|
-
"""Join to information_schema.
|
373
|
+
def information_schema_fs_tables_ext(expression: exp.Expression) -> exp.Expression:
|
374
|
+
"""Join to information_schema._fs_tables_ext to access additional metadata columns (eg: comment)."""
|
288
375
|
|
289
376
|
if (
|
290
377
|
isinstance(expression, exp.Select)
|
@@ -293,12 +380,12 @@ def information_schema_tables_ext(expression: exp.Expression) -> exp.Expression:
|
|
293
380
|
and tbl_exp.db.upper() == "INFORMATION_SCHEMA"
|
294
381
|
):
|
295
382
|
return expression.join(
|
296
|
-
"information_schema.
|
383
|
+
"information_schema._fs_tables_ext",
|
297
384
|
on=(
|
298
385
|
"""
|
299
|
-
tables.table_catalog =
|
300
|
-
tables.table_schema =
|
301
|
-
tables.table_name =
|
386
|
+
tables.table_catalog = _fs_tables_ext.ext_table_catalog AND
|
387
|
+
tables.table_schema = _fs_tables_ext.ext_table_schema AND
|
388
|
+
tables.table_name = _fs_tables_ext.ext_table_name
|
302
389
|
"""
|
303
390
|
),
|
304
391
|
join_type="left",
|
@@ -328,12 +415,12 @@ def integer_precision(expression: exp.Expression) -> exp.Expression:
|
|
328
415
|
|
329
416
|
|
330
417
|
def json_extract_cased_as_varchar(expression: exp.Expression) -> exp.Expression:
|
331
|
-
"""Convert json to varchar inside
|
418
|
+
"""Convert json to varchar inside JSONExtract.
|
332
419
|
|
333
420
|
Snowflake case conversion (upper/lower) turns variant into varchar. This
|
334
421
|
mimics that behaviour within get_path.
|
335
422
|
|
336
|
-
TODO: a generic version that works on any variant, not just
|
423
|
+
TODO: a generic version that works on any variant, not just JSONExtract
|
337
424
|
|
338
425
|
Returns a raw string using the Duckdb ->> operator, aka the json_extract_string function, see
|
339
426
|
https://duckdb.org/docs/extensions/json#json-extraction-functions
|
@@ -341,13 +428,11 @@ def json_extract_cased_as_varchar(expression: exp.Expression) -> exp.Expression:
|
|
341
428
|
if (
|
342
429
|
isinstance(expression, (exp.Upper, exp.Lower))
|
343
430
|
and (gp := expression.this)
|
344
|
-
and isinstance(gp, exp.
|
431
|
+
and isinstance(gp, exp.JSONExtract)
|
345
432
|
and (path := gp.expression)
|
346
|
-
and isinstance(path, exp.
|
433
|
+
and isinstance(path, exp.JSONPath)
|
347
434
|
):
|
348
|
-
expression.set(
|
349
|
-
"this", exp.JSONExtractScalar(this=gp.this, expression=exp.Literal(this=f"$.{path.this}", is_string=True))
|
350
|
-
)
|
435
|
+
expression.set("this", exp.JSONExtractScalar(this=gp.this, expression=path))
|
351
436
|
|
352
437
|
return expression
|
353
438
|
|
@@ -360,13 +445,12 @@ def json_extract_cast_as_varchar(expression: exp.Expression) -> exp.Expression:
|
|
360
445
|
"""
|
361
446
|
if (
|
362
447
|
isinstance(expression, exp.Cast)
|
363
|
-
and (
|
364
|
-
and isinstance(
|
365
|
-
and (path :=
|
366
|
-
and isinstance(path, exp.
|
448
|
+
and (je := expression.this)
|
449
|
+
and isinstance(je, exp.JSONExtract)
|
450
|
+
and (path := je.expression)
|
451
|
+
and isinstance(path, exp.JSONPath)
|
367
452
|
):
|
368
|
-
return exp.JSONExtractScalar(this=
|
369
|
-
|
453
|
+
return exp.JSONExtractScalar(this=je.this, expression=path)
|
370
454
|
return expression
|
371
455
|
|
372
456
|
|
@@ -592,6 +676,87 @@ def set_schema(expression: exp.Expression, current_database: str | None) -> exp.
|
|
592
676
|
return expression
|
593
677
|
|
594
678
|
|
679
|
+
SQL_SHOW_OBJECTS = """
|
680
|
+
select
|
681
|
+
to_timestamp(0)::timestamptz as 'created_on',
|
682
|
+
table_name as 'name',
|
683
|
+
case when table_type='BASE TABLE' then 'TABLE' else table_type end as 'kind',
|
684
|
+
table_catalog as 'database_name',
|
685
|
+
table_schema as 'schema_name'
|
686
|
+
from information_schema.tables
|
687
|
+
"""
|
688
|
+
|
689
|
+
|
690
|
+
def show_objects_tables(expression: exp.Expression, current_database: str | None = None) -> exp.Expression:
|
691
|
+
"""Transform SHOW OBJECTS/TABLES to a query against the information_schema.tables table.
|
692
|
+
|
693
|
+
See https://docs.snowflake.com/en/sql-reference/sql/show-objects
|
694
|
+
https://docs.snowflake.com/en/sql-reference/sql/show-tables
|
695
|
+
"""
|
696
|
+
if (
|
697
|
+
isinstance(expression, exp.Show)
|
698
|
+
and isinstance(expression.this, str)
|
699
|
+
and expression.this.upper() in ["OBJECTS", "TABLES"]
|
700
|
+
):
|
701
|
+
scope_kind = expression.args.get("scope_kind")
|
702
|
+
table = expression.find(exp.Table)
|
703
|
+
|
704
|
+
if scope_kind == "DATABASE":
|
705
|
+
catalog = (table and table.name) or current_database
|
706
|
+
schema = None
|
707
|
+
elif scope_kind == "SCHEMA" and table:
|
708
|
+
catalog = table.db or current_database
|
709
|
+
schema = table.name
|
710
|
+
else:
|
711
|
+
# all objects / tables
|
712
|
+
catalog = None
|
713
|
+
schema = None
|
714
|
+
|
715
|
+
tables_only = "table_type = 'BASE TABLE' and " if expression.this.upper() == "TABLES" else ""
|
716
|
+
exclude_fakesnow_tables = "not (table_schema == 'information_schema' and table_name like '_fs_%%')"
|
717
|
+
# without a database will show everything in the "account"
|
718
|
+
table_catalog = f" and table_catalog = '{catalog}'" if catalog else ""
|
719
|
+
schema = f" and table_schema = '{schema}'" if schema else ""
|
720
|
+
limit = limit.sql() if (limit := expression.args.get("limit")) and isinstance(limit, exp.Expression) else ""
|
721
|
+
|
722
|
+
return sqlglot.parse_one(
|
723
|
+
f"{SQL_SHOW_OBJECTS} where {tables_only}{exclude_fakesnow_tables}{table_catalog}{schema}{limit}",
|
724
|
+
read="duckdb",
|
725
|
+
)
|
726
|
+
|
727
|
+
return expression
|
728
|
+
|
729
|
+
|
730
|
+
SQL_SHOW_SCHEMAS = """
|
731
|
+
select
|
732
|
+
to_timestamp(0)::timestamptz as 'created_on',
|
733
|
+
schema_name as 'name',
|
734
|
+
NULL as 'kind',
|
735
|
+
catalog_name as 'database_name',
|
736
|
+
NULL as 'schema_name'
|
737
|
+
from information_schema.schemata
|
738
|
+
where catalog_name not in ('memory', 'system', 'temp') and schema_name not in ('main', 'pg_catalog')
|
739
|
+
"""
|
740
|
+
|
741
|
+
|
742
|
+
def show_schemas(expression: exp.Expression, current_database: str | None = None) -> exp.Expression:
|
743
|
+
"""Transform SHOW SCHEMAS to a query against the information_schema.schemata table.
|
744
|
+
|
745
|
+
See https://docs.snowflake.com/en/sql-reference/sql/show-schemas
|
746
|
+
"""
|
747
|
+
if isinstance(expression, exp.Show) and isinstance(expression.this, str) and expression.this.upper() == "SCHEMAS":
|
748
|
+
if (ident := expression.find(exp.Identifier)) and isinstance(ident.this, str):
|
749
|
+
database = ident.this
|
750
|
+
else:
|
751
|
+
database = current_database
|
752
|
+
|
753
|
+
return sqlglot.parse_one(
|
754
|
+
f"{SQL_SHOW_SCHEMAS} and catalog_name = '{database}'" if database else SQL_SHOW_SCHEMAS, read="duckdb"
|
755
|
+
)
|
756
|
+
|
757
|
+
return expression
|
758
|
+
|
759
|
+
|
595
760
|
def tag(expression: exp.Expression) -> exp.Expression:
|
596
761
|
"""Handle tags. Transfer tags into upserts of the tag table.
|
597
762
|
|
@@ -646,9 +811,7 @@ def to_date(expression: exp.Expression) -> exp.Expression:
|
|
646
811
|
and expression.this.upper() == "TO_DATE"
|
647
812
|
):
|
648
813
|
return exp.Cast(
|
649
|
-
|
650
|
-
# and avoid https://github.com/duckdb/duckdb/issues/7672
|
651
|
-
this=exp.DateTrunc(unit=exp.Literal(this="day", is_string=True), this=expression.expressions[0]),
|
814
|
+
this=expression.expressions[0],
|
652
815
|
to=exp.DataType(this=exp.DataType.Type.DATE, nested=False, prefix=False),
|
653
816
|
)
|
654
817
|
return expression
|
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2023 Oliver Mannion
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|