Skip to content

Commit

Permalink
chore: Add __main__.py entry point to samples and cookiecutters
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 18, 2024
1 parent e9f2c17 commit d5c0e58
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cookiecutter/mapper-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"variant": "None (Skip)",
"include_ci_files": ["GitHub", "None (Skip)"],
"license": ["Apache-2.0"],
"ide": ["VSCode", "None"],
"__prompts__": {
"name": "The name of the mapper, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
"admin_email": "Provide your [bold yellow]email[/]",
"mapper_id": "The ID of the tap, in kebab-case",
"library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.",
"include_ci_files": "Whether to include CI files for a common CI services",
"license": "The license for the project"
"license": "The license for the project",
"ide": "Add configuration files for your preferred IDE"
}
}
17 changes: 17 additions & 0 deletions cookiecutter/mapper-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
from pathlib import Path
import shutil


BASE_PATH = Path("{{cookiecutter.library_name}}")


if __name__ == "__main__":
if "{{ cookiecutter.license }}" != "Apache-2.0":
Path("LICENSE").unlink()

if "{{ cookiecutter.include_ci_files }}" != "GitHub":
shutil.rmtree(Path(".github"))

if "{{ cookiecutter.ide }}" != "VSCode":
shutil.rmtree(".vscode")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""{{ cookiecutter.name }} entry point."""

from __future__ import annotations

from {{ cookiecutter.library_name }}.mapper import {{ cookiecutter.name }}Mapper

{{ cookiecutter.name }}Mapper.cli()
4 changes: 3 additions & 1 deletion cookiecutter/tap-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"include_ci_files": ["GitHub", "None"],
"license": ["Apache-2.0", "None"],
"ide": ["VSCode", "None"],
"__prompts__": {
"source_name": "The name of the source, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
Expand All @@ -25,6 +26,7 @@
"stream_type": "The type of stream the source provides",
"auth_method": "The [bold red]authentication[/] method used by the source, for REST and GraphQL sources",
"include_ci_files": "Whether to include CI files for a common CI services",
"license": "The license for the project"
"license": "The license for the project",
"ide": "Add configuration files for your preferred IDE"
}
}
3 changes: 3 additions & 0 deletions cookiecutter/tap-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@

if "{{ cookiecutter.include_ci_files }}" != "GitHub":
shutil.rmtree(".github")

if "{{ cookiecutter.ide }}" != "VSCode":
shutil.rmtree(".vscode")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""{{ cookiecutter.source_name }} entry point."""

from __future__ import annotations

from {{ cookiecutter.library_name }}.tap import Tap{{ cookiecutter.source_name }}

Tap{{ cookiecutter.source_name }}.cli()
4 changes: 3 additions & 1 deletion cookiecutter/target-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"serialization_method": ["Per record", "Per batch", "SQL"],
"include_ci_files": ["GitHub", "None (Skip)"],
"license": ["Apache-2.0"],
"ide": ["VSCode", "None"],
"__prompts__": {
"name": "The name of the mapper, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
Expand All @@ -16,6 +17,7 @@
"library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.",
"serialization_method": "The serialization method to use for loading data",
"include_ci_files": "Whether to include CI files for a common CI services",
"license": "The license for the project"
"license": "The license for the project",
"ide": "Add configuration files for your preferred IDE"
}
}
3 changes: 3 additions & 0 deletions cookiecutter/target-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@

if "{{ cookiecutter.include_ci_files }}" != "GitHub":
shutil.rmtree(Path(".github"))

if "{{ cookiecutter.ide }}" != "VSCode":
shutil.rmtree(".vscode")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""{{ cookiecutter.destination_name }} entry point."""

from __future__ import annotations

from {{ cookiecutter.library_name }}.target import Target{{ cookiecutter.destination_name }}

Target{{ cookiecutter.destination_name }}.cli()
5 changes: 5 additions & 0 deletions samples/sample_mapper/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_mapper.mapper import StreamTransform

StreamTransform.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_bigquery/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_bigquery import TapBigQuery

TapBigQuery.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_gitlab/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from sample_tap_gitlab.gitlab_tap import SampleTapGitlab

SampleTapGitlab.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_google_analytics/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_google_analytics.ga_tap import SampleTapGoogleAnalytics

SampleTapGoogleAnalytics.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_hostile/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_hostile import SampleTapHostile

SampleTapHostile.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_sqlite/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_sqlite import SQLiteTap

SQLiteTap.cli()
5 changes: 5 additions & 0 deletions samples/sample_target_parquet/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from sample_target_parquet.parquet_target import SampleTargetParquet

SampleTargetParquet.cli()

0 comments on commit d5c0e58

Please sign in to comment.