Skip to content

Commit 09d3256

Browse files
Move FS configs to their own module
1 parent 2f45921 commit 09d3256

File tree

3 files changed

+95
-86
lines changed

3 files changed

+95
-86
lines changed

tap_csv/filesystem_config.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""JSON Schema for each filesystem configuration."""
2+
3+
from __future__ import annotations
4+
5+
from singer_sdk import typing as th # JSON schema typing helpers
6+
7+
FTP = th.Property(
8+
"ftp",
9+
th.ObjectType(
10+
th.Property(
11+
"host",
12+
th.StringType,
13+
required=True,
14+
description="FTP server host",
15+
),
16+
th.Property(
17+
"port",
18+
th.IntegerType,
19+
default=21,
20+
description="FTP server port",
21+
),
22+
th.Property(
23+
"username",
24+
th.StringType,
25+
description="FTP username",
26+
),
27+
th.Property(
28+
"password",
29+
th.StringType,
30+
secret=True,
31+
description="FTP password",
32+
),
33+
th.Property(
34+
"encoding",
35+
th.StringType,
36+
default="utf-8",
37+
description="FTP server encoding",
38+
),
39+
),
40+
description="FTP connection settings",
41+
)
42+
43+
GITHUB = th.Property(
44+
"github",
45+
th.ObjectType(
46+
th.Property(
47+
"org",
48+
th.StringType,
49+
required=True,
50+
description=("GitHub organization or user where the repository is located"),
51+
),
52+
th.Property(
53+
"repo",
54+
th.StringType,
55+
required=True,
56+
description="GitHub repository",
57+
),
58+
th.Property(
59+
"username",
60+
th.StringType,
61+
required=False,
62+
description="GitHub username",
63+
),
64+
th.Property(
65+
"token",
66+
th.StringType,
67+
required=False,
68+
secret=True,
69+
description="GitHub token",
70+
),
71+
),
72+
description="GitHub connection settings",
73+
)
74+
75+
DROPBOX = th.Property(
76+
"dropbox",
77+
th.ObjectType(
78+
th.Property(
79+
"token",
80+
th.StringType,
81+
secret=True,
82+
required=True,
83+
description="Dropbox token",
84+
),
85+
),
86+
description="Dropbox connection settings",
87+
)

tap_csv/tap.py

Lines changed: 5 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from singer_sdk.helpers._classproperty import classproperty
1212
from singer_sdk.helpers.capabilities import TapCapabilities
1313

14-
from tap_csv.client import CSVStream
14+
from . import client, filesystem_config
1515

1616

1717
class TapCSV(Tap):
@@ -53,87 +53,9 @@ class TapCSV(Tap):
5353
"dropbox",
5454
],
5555
),
56-
th.Property(
57-
"ftp",
58-
th.ObjectType(
59-
th.Property(
60-
"host",
61-
th.StringType,
62-
required=True,
63-
description="FTP server host",
64-
),
65-
th.Property(
66-
"port",
67-
th.IntegerType,
68-
default=21,
69-
description="FTP server port",
70-
),
71-
th.Property(
72-
"username",
73-
th.StringType,
74-
description="FTP username",
75-
),
76-
th.Property(
77-
"password",
78-
th.StringType,
79-
secret=True,
80-
description="FTP password",
81-
),
82-
th.Property(
83-
"encoding",
84-
th.StringType,
85-
default="utf-8",
86-
description="FTP server encoding",
87-
),
88-
),
89-
description="FTP connection settings",
90-
),
91-
th.Property(
92-
"github",
93-
th.ObjectType(
94-
th.Property(
95-
"org",
96-
th.StringType,
97-
required=True,
98-
description=(
99-
"GitHub organization or user where the repository is located"
100-
),
101-
),
102-
th.Property(
103-
"repo",
104-
th.StringType,
105-
required=True,
106-
description="GitHub repository",
107-
),
108-
th.Property(
109-
"username",
110-
th.StringType,
111-
required=False,
112-
description="GitHub username",
113-
),
114-
th.Property(
115-
"token",
116-
th.StringType,
117-
required=False,
118-
secret=True,
119-
description="GitHub token",
120-
),
121-
),
122-
description="GitHub connection settings",
123-
),
124-
th.Property(
125-
"dropbox",
126-
th.ObjectType(
127-
th.Property(
128-
"token",
129-
th.StringType,
130-
secret=True,
131-
required=True,
132-
description="Dropbox token",
133-
),
134-
),
135-
description="Dropbox connection settings",
136-
),
56+
filesystem_config.FTP,
57+
filesystem_config.GITHUB,
58+
filesystem_config.DROPBOX,
13759
th.Property(
13860
"csv_files_definition",
13961
th.StringType,
@@ -189,7 +111,7 @@ def discover_streams(self) -> list[Stream]:
189111
raise ConfigValidationError(msg, errors=errors)
190112

191113
return [
192-
CSVStream(
114+
client.CSVStream(
193115
tap=self,
194116
name=file_config.get("entity"),
195117
file_config=file_config,

tests/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import os
66

7-
from tap_csv.tap import CSVStream, TapCSV
7+
from tap_csv import client, tap
88

99

1010
def test_get_file_paths_recursively():
@@ -21,8 +21,8 @@ def test_get_file_paths_recursively():
2121
]
2222
}
2323

24-
stream = CSVStream(
25-
tap=TapCSV(config=SAMPLE_CONFIG, catalog={}, state={}),
24+
stream = client.CSVStream(
25+
tap=tap.TapCSV(config=SAMPLE_CONFIG, catalog={}, state={}),
2626
name="test_recursive",
2727
file_config=SAMPLE_CONFIG.get("files")[0],
2828
filesystem="local",

0 commit comments

Comments
 (0)