datacontract-cli 0.10.31__py3-none-any.whl → 0.10.33__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.
Potentially problematic release.
This version of datacontract-cli might be problematic. Click here for more details.
- datacontract/cli.py +20 -5
- datacontract/data_contract.py +8 -2
- datacontract/export/excel_exporter.py +922 -0
- datacontract/export/exporter.py +1 -0
- datacontract/export/exporter_factory.py +4 -0
- datacontract/imports/excel_importer.py +274 -18
- datacontract/output/junit_test_results.py +3 -3
- {datacontract_cli-0.10.31.dist-info → datacontract_cli-0.10.33.dist-info}/METADATA +28 -4
- {datacontract_cli-0.10.31.dist-info → datacontract_cli-0.10.33.dist-info}/RECORD +13 -12
- {datacontract_cli-0.10.31.dist-info → datacontract_cli-0.10.33.dist-info}/WHEEL +0 -0
- {datacontract_cli-0.10.31.dist-info → datacontract_cli-0.10.33.dist-info}/entry_points.txt +0 -0
- {datacontract_cli-0.10.31.dist-info → datacontract_cli-0.10.33.dist-info}/licenses/LICENSE +0 -0
- {datacontract_cli-0.10.31.dist-info → datacontract_cli-0.10.33.dist-info}/top_level.txt +0 -0
datacontract/cli.py
CHANGED
|
@@ -210,12 +210,21 @@ def export(
|
|
|
210
210
|
# TODO: this should be a subcommand
|
|
211
211
|
template: Annotated[
|
|
212
212
|
Optional[Path],
|
|
213
|
-
typer.Option(
|
|
213
|
+
typer.Option(
|
|
214
|
+
help="The file path or URL of a template. For Excel format: path/URL to custom Excel template. For custom format: path to Jinja template."
|
|
215
|
+
),
|
|
214
216
|
] = None,
|
|
215
217
|
):
|
|
216
218
|
"""
|
|
217
219
|
Convert data contract to a specific format. Saves to file specified by `output` option if present, otherwise prints to stdout.
|
|
218
220
|
"""
|
|
221
|
+
# Validate that Excel format requires an output file path
|
|
222
|
+
if format == ExportFormat.excel and output is None:
|
|
223
|
+
console.print("❌ Error: Excel export requires an output file path.")
|
|
224
|
+
console.print("💡 Hint: Use --output to specify where to save the Excel file, e.g.:")
|
|
225
|
+
console.print(" datacontract export --format excel --output datacontract.xlsx")
|
|
226
|
+
raise typer.Exit(code=1)
|
|
227
|
+
|
|
219
228
|
# TODO exception handling
|
|
220
229
|
result = DataContract(data_contract_file=location, schema_location=schema, server=server).export(
|
|
221
230
|
export_format=format,
|
|
@@ -230,8 +239,13 @@ def export(
|
|
|
230
239
|
if output is None:
|
|
231
240
|
console.print(result, markup=False, soft_wrap=True)
|
|
232
241
|
else:
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
if isinstance(result, bytes):
|
|
243
|
+
# If the result is bytes, we assume it's a binary file (e.g., Excel, PDF)
|
|
244
|
+
with output.open(mode="wb") as f:
|
|
245
|
+
f.write(result)
|
|
246
|
+
else:
|
|
247
|
+
with output.open(mode="w", encoding="utf-8") as f:
|
|
248
|
+
f.write(result)
|
|
235
249
|
console.print(f"Written result to {output}")
|
|
236
250
|
|
|
237
251
|
|
|
@@ -482,13 +496,14 @@ def _get_uvicorn_arguments(port: int, host: str, context: typer.Context) -> dict
|
|
|
482
496
|
}
|
|
483
497
|
|
|
484
498
|
# Create a list of the extra arguments, remove the leading -- from the cli arguments
|
|
485
|
-
trimmed_keys = list(map(lambda x
|
|
499
|
+
trimmed_keys = list(map(lambda x: str(x).replace("--", ""), context.args[::2]))
|
|
486
500
|
# Merge the two dicts and return them as one dict
|
|
487
501
|
return default_args | dict(zip(trimmed_keys, context.args[1::2]))
|
|
488
502
|
|
|
503
|
+
|
|
489
504
|
@app.command(context_settings={"allow_extra_args": True, "ignore_unknown_options": True})
|
|
490
505
|
def api(
|
|
491
|
-
ctx: Annotated[typer.Context, typer.Option(help="Extra arguments to pass to uvicorn.run().")],
|
|
506
|
+
ctx: Annotated[typer.Context, typer.Option(help="Extra arguments to pass to uvicorn.run().")],
|
|
492
507
|
port: Annotated[int, typer.Option(help="Bind socket to this port.")] = 4242,
|
|
493
508
|
host: Annotated[
|
|
494
509
|
str, typer.Option(help="Bind socket to this host. Hint: For running in docker, set it to 0.0.0.0")
|
datacontract/data_contract.py
CHANGED
|
@@ -250,8 +250,14 @@ class DataContract:
|
|
|
250
250
|
inline_quality=self._inline_quality,
|
|
251
251
|
)
|
|
252
252
|
|
|
253
|
-
def export(
|
|
254
|
-
|
|
253
|
+
def export(
|
|
254
|
+
self, export_format: ExportFormat, model: str = "all", sql_server_type: str = "auto", **kwargs
|
|
255
|
+
) -> str | bytes:
|
|
256
|
+
if (
|
|
257
|
+
export_format == ExportFormat.html
|
|
258
|
+
or export_format == ExportFormat.mermaid
|
|
259
|
+
or export_format == ExportFormat.excel
|
|
260
|
+
):
|
|
255
261
|
data_contract = resolve.resolve_data_contract_v2(
|
|
256
262
|
self._data_contract_file,
|
|
257
263
|
self._data_contract_str,
|