python-jack-knife 0.5.0__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.
- pjk/__init__.py +5 -0
- pjk/base.py +377 -0
- pjk/common.py +150 -0
- pjk/log.py +67 -0
- pjk/main.py +106 -0
- pjk/man_page.py +125 -0
- pjk/parser.py +284 -0
- pjk/pipes/__init__.py +0 -0
- pjk/pipes/denorm.py +68 -0
- pjk/pipes/factory.py +62 -0
- pjk/pipes/filter.py +57 -0
- pjk/pipes/head.py +34 -0
- pjk/pipes/join.py +85 -0
- pjk/pipes/let_reduce.py +198 -0
- pjk/pipes/map.py +91 -0
- pjk/pipes/move_field.py +36 -0
- pjk/pipes/postgres_pipe.py +209 -0
- pjk/pipes/remove_field.py +36 -0
- pjk/pipes/select.py +42 -0
- pjk/pipes/sort.py +63 -0
- pjk/pipes/tail.py +39 -0
- pjk/pipes/user_pipe_factory.py +45 -0
- pjk/pipes/where.py +49 -0
- pjk/registry.py +143 -0
- pjk/sinks/__init__.py +0 -0
- pjk/sinks/csv_sink.py +33 -0
- pjk/sinks/ddb.py +54 -0
- pjk/sinks/devnull.py +31 -0
- pjk/sinks/dir_sink.py +59 -0
- pjk/sinks/expect.py +53 -0
- pjk/sinks/factory.py +108 -0
- pjk/sinks/graph.py +57 -0
- pjk/sinks/graph_bar_line.py +229 -0
- pjk/sinks/graph_cumulative.py +55 -0
- pjk/sinks/graph_hist.py +72 -0
- pjk/sinks/graph_scatter.py +29 -0
- pjk/sinks/json_sink.py +23 -0
- pjk/sinks/s3_sink.py +100 -0
- pjk/sinks/sinks.py +68 -0
- pjk/sinks/stdout.py +44 -0
- pjk/sinks/tsv_sink.py +22 -0
- pjk/sinks/user_sink_factory.py +43 -0
- pjk/sources/__init__.py +0 -0
- pjk/sources/csv_source.py +28 -0
- pjk/sources/dir_source.py +69 -0
- pjk/sources/factory.py +100 -0
- pjk/sources/format_usage.py +11 -0
- pjk/sources/inline_source.py +56 -0
- pjk/sources/json_source.py +35 -0
- pjk/sources/lazy_file.py +16 -0
- pjk/sources/lazy_file_local.py +22 -0
- pjk/sources/lazy_file_s3.py +28 -0
- pjk/sources/parquet_source.py +32 -0
- pjk/sources/s3_source.py +146 -0
- pjk/sources/source_list.py +23 -0
- pjk/sources/sql_source.py +32 -0
- pjk/sources/tsv_source.py +15 -0
- pjk/sources/user_source_factory.py +33 -0
- pjk/version.py +4 -0
- python_jack_knife-0.5.0.dist-info/METADATA +254 -0
- python_jack_knife-0.5.0.dist-info/RECORD +65 -0
- python_jack_knife-0.5.0.dist-info/WHEEL +5 -0
- python_jack_knife-0.5.0.dist-info/entry_points.txt +2 -0
- python_jack_knife-0.5.0.dist-info/licenses/LICENSE +202 -0
- python_jack_knife-0.5.0.dist-info/top_level.txt +1 -0
pjk/sources/s3_source.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024-2025 Mike Schultz
|
|
3
|
+
|
|
4
|
+
from threading import Lock
|
|
5
|
+
from typing import Optional, Any, Iterator, Tuple
|
|
6
|
+
from pjk.base import Source, ParsedToken
|
|
7
|
+
from pjk.sources.lazy_file_s3 import LazyFileS3
|
|
8
|
+
from pjk.log import logger
|
|
9
|
+
|
|
10
|
+
class _SharedS3State:
|
|
11
|
+
"""
|
|
12
|
+
Shared, thread-safe lazy iterator over S3 objects for a given bucket/prefix.
|
|
13
|
+
All S3Source instances created via deep_copy() share this state so that:
|
|
14
|
+
- Keys are produced lazily (no initial drain into a queue).
|
|
15
|
+
- Each consumer reserves distinct work atomically.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
s3_client,
|
|
21
|
+
bucket: str,
|
|
22
|
+
prefix: str,
|
|
23
|
+
override_format: Optional[str],
|
|
24
|
+
get_format_class_gz: Any,
|
|
25
|
+
):
|
|
26
|
+
self.s3 = s3_client
|
|
27
|
+
self.bucket = bucket
|
|
28
|
+
self.prefix = prefix
|
|
29
|
+
self.override_format = override_format
|
|
30
|
+
self.get_format_class_gz = get_format_class_gz
|
|
31
|
+
|
|
32
|
+
# Build a *single* lazy iterator over keys from the paginator.
|
|
33
|
+
self._key_iter = self._iter_s3_keys()
|
|
34
|
+
self._lock = Lock()
|
|
35
|
+
self._exhausted = False # explicit flag; avoids extra paginator calls after completion
|
|
36
|
+
|
|
37
|
+
def _iter_s3_keys(self) -> Iterator[str]:
|
|
38
|
+
paginator = self.s3.get_paginator("list_objects_v2")
|
|
39
|
+
# Paginate lazily; do not force iteration here.
|
|
40
|
+
for page in paginator.paginate(Bucket=self.bucket, Prefix=self.prefix):
|
|
41
|
+
contents = page.get("Contents", [])
|
|
42
|
+
# Preserve original S3 ordering within each page.
|
|
43
|
+
for obj in contents:
|
|
44
|
+
# Defensive: ensure Key exists and is str
|
|
45
|
+
key = obj.get("Key")
|
|
46
|
+
if isinstance(key, str) and key:
|
|
47
|
+
yield key
|
|
48
|
+
|
|
49
|
+
def _build_source_for_key(self, key: str) -> Source:
|
|
50
|
+
# Respect override format if provided.
|
|
51
|
+
file_token = key if not self.override_format else f"{key}@format={self.override_format}"
|
|
52
|
+
file_ptok = ParsedToken(file_token)
|
|
53
|
+
|
|
54
|
+
format_class, is_gz = self.get_format_class_gz(file_ptok)
|
|
55
|
+
if not format_class:
|
|
56
|
+
raise RuntimeError(f"No format for file: {key}")
|
|
57
|
+
|
|
58
|
+
#logger.info(f"S3Source starting s3://{self.bucket}/{key}")
|
|
59
|
+
|
|
60
|
+
lazy_file = LazyFileS3(self.bucket, key, is_gz)
|
|
61
|
+
return format_class(lazy_file)
|
|
62
|
+
|
|
63
|
+
def reserve_next_source(self) -> Optional[Source]:
|
|
64
|
+
"""
|
|
65
|
+
Atomically reserve and construct the next file-backed Source.
|
|
66
|
+
Returns None when the iterator is exhausted.
|
|
67
|
+
"""
|
|
68
|
+
if self._exhausted:
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
with self._lock:
|
|
72
|
+
if self._exhausted:
|
|
73
|
+
return None
|
|
74
|
+
try:
|
|
75
|
+
key = next(self._key_iter)
|
|
76
|
+
except StopIteration:
|
|
77
|
+
self._exhausted = True
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
# Construct outside the lock to minimize critical section time.
|
|
81
|
+
return self._build_source_for_key(key)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class S3Source(Source):
|
|
85
|
+
"""
|
|
86
|
+
A Source that draws from a shared, lazy S3 key stream.
|
|
87
|
+
- Iteration pulls a new inner Source on demand.
|
|
88
|
+
- deep_copy() proactively reserves one unit of work for the clone, mirroring your queue split.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
def __init__(self, shared_state: _SharedS3State, reserved: Optional[Source] = None):
|
|
92
|
+
self._state = shared_state
|
|
93
|
+
self._current: Optional[Source] = reserved
|
|
94
|
+
|
|
95
|
+
def __iter__(self):
|
|
96
|
+
while True:
|
|
97
|
+
if self._current is None:
|
|
98
|
+
# Reserve the next unit of work lazily.
|
|
99
|
+
self._current = self._state.reserve_next_source()
|
|
100
|
+
if self._current is None:
|
|
101
|
+
return # exhausted
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
# Delegate to the inner file Source (whatever format_class produced).
|
|
105
|
+
yield from self._current
|
|
106
|
+
finally:
|
|
107
|
+
# Always move on to the next unit of work after finishing current.
|
|
108
|
+
self._current = None
|
|
109
|
+
|
|
110
|
+
def deep_copy(self):
|
|
111
|
+
"""
|
|
112
|
+
Proactively reserve one unit of work for the clone so that multiple workers
|
|
113
|
+
can start immediately without racing on the first item.
|
|
114
|
+
"""
|
|
115
|
+
reserved = self._state.reserve_next_source()
|
|
116
|
+
if reserved is None:
|
|
117
|
+
return None
|
|
118
|
+
return S3Source(self._state, reserved)
|
|
119
|
+
|
|
120
|
+
@classmethod
|
|
121
|
+
def create(cls, ptok: ParsedToken, get_format_class_gz: Any):
|
|
122
|
+
"""
|
|
123
|
+
Returns immediately with a lazily-backed S3Source (no pre-enqueue).
|
|
124
|
+
"""
|
|
125
|
+
import boto3 # lazy import
|
|
126
|
+
s3_uri = ptok.all_but_params
|
|
127
|
+
params = ptok.get_params()
|
|
128
|
+
override = params.get("format")
|
|
129
|
+
|
|
130
|
+
raw = s3_uri[3:] # strip 's3:'
|
|
131
|
+
raw = raw.removeprefix("//")
|
|
132
|
+
bucket, _, prefix = raw.partition("/")
|
|
133
|
+
|
|
134
|
+
# Build shared, lazy state. No listing performed yet.
|
|
135
|
+
s3 = boto3.client("s3")
|
|
136
|
+
shared = _SharedS3State(
|
|
137
|
+
s3_client=s3,
|
|
138
|
+
bucket=bucket,
|
|
139
|
+
prefix=prefix,
|
|
140
|
+
override_format=override,
|
|
141
|
+
get_format_class_gz=get_format_class_gz,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Return a source immediately (no blocking on S3).
|
|
145
|
+
# If there are zero keys, the first __iter__ call will end cleanly.
|
|
146
|
+
return cls(shared)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024 Mike Schultz
|
|
3
|
+
|
|
4
|
+
from typing import Iterable
|
|
5
|
+
from pjk.base import Source
|
|
6
|
+
|
|
7
|
+
class SourceListSource(Source):
|
|
8
|
+
def __init__(self, source_iter: Iterable[Source]):
|
|
9
|
+
self.sources = iter(source_iter)
|
|
10
|
+
self.current = None
|
|
11
|
+
|
|
12
|
+
def __iter__(self):
|
|
13
|
+
while True:
|
|
14
|
+
if self.current is None:
|
|
15
|
+
try:
|
|
16
|
+
self.current = next(self.sources)
|
|
17
|
+
except StopIteration:
|
|
18
|
+
return # all sources exhausted
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
yield from self.current
|
|
22
|
+
finally:
|
|
23
|
+
self.current = None
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024 Mike Schultz
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
from pjk.base import Source, NoBindUsage
|
|
6
|
+
from pjk.sources.format_usage import FormatUsage
|
|
7
|
+
from pjk.sources.lazy_file import LazyFile
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SQLSource(Source):
|
|
11
|
+
is_format = True
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def usage(cls):
|
|
15
|
+
return FormatUsage(
|
|
16
|
+
"sql",
|
|
17
|
+
component_class=cls,
|
|
18
|
+
desc_override="SQL source. Emits SQL in single record in 'query' field."
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def __init__(self, lazy_file: LazyFile):
|
|
22
|
+
self.lazy_file = lazy_file
|
|
23
|
+
self.num_recs = 0
|
|
24
|
+
|
|
25
|
+
def __iter__(self):
|
|
26
|
+
with self.lazy_file.open() as f:
|
|
27
|
+
sql_text = f.read().strip()
|
|
28
|
+
sql_text = sql_text.replace("\r", " ").replace("\n", " ").strip()
|
|
29
|
+
|
|
30
|
+
if sql_text:
|
|
31
|
+
self.num_recs += 1
|
|
32
|
+
yield {"query": sql_text}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024 Mike Schultz
|
|
3
|
+
|
|
4
|
+
from pjk.sources.csv_source import CSVSource
|
|
5
|
+
from pjk.sources.lazy_file import LazyFile
|
|
6
|
+
from pjk.sources.format_usage import FormatUsage
|
|
7
|
+
|
|
8
|
+
class TSVSource(CSVSource):
|
|
9
|
+
is_format = True
|
|
10
|
+
@classmethod
|
|
11
|
+
def usage(cls):
|
|
12
|
+
return FormatUsage('tsv', component_class=cls)
|
|
13
|
+
|
|
14
|
+
def __init__(self, lazy_file: LazyFile):
|
|
15
|
+
super().__init__(lazy_file, delimiter="\t")
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024 Mike Schultz
|
|
3
|
+
|
|
4
|
+
import importlib.util
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from pjk.base import Source, Pipe, Sink, ParsedToken, UsageError
|
|
7
|
+
|
|
8
|
+
class UserSourceFactory:
|
|
9
|
+
@staticmethod
|
|
10
|
+
def create(ptok: ParsedToken) -> Optional[Source]:
|
|
11
|
+
script_path = ptok.pre_colon
|
|
12
|
+
try:
|
|
13
|
+
spec = importlib.util.spec_from_file_location("user_source", script_path)
|
|
14
|
+
if spec is None or spec.loader is None:
|
|
15
|
+
raise UsageError(f"Could not load Python file: {script_path}")
|
|
16
|
+
|
|
17
|
+
module = importlib.util.module_from_spec(spec)
|
|
18
|
+
spec.loader.exec_module(module)
|
|
19
|
+
except Exception as e:
|
|
20
|
+
raise UsageError(f"Failed to import {script_path}: {e}")
|
|
21
|
+
|
|
22
|
+
for value in vars(module).values():
|
|
23
|
+
if (
|
|
24
|
+
isinstance(value, type)
|
|
25
|
+
and issubclass(value, Source)
|
|
26
|
+
and not issubclass(value, Pipe)
|
|
27
|
+
and not issubclass(value, Sink)
|
|
28
|
+
and value is not Source
|
|
29
|
+
and value.__module__ == module.__name__ # 🧠 only user-defined classes
|
|
30
|
+
):
|
|
31
|
+
return value(ptok)
|
|
32
|
+
|
|
33
|
+
return None
|
pjk/version.py
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-jack-knife
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Python Jack Knife – a command line data processor
|
|
5
|
+
Author-email: Mike Schultz <mike.schultz@gmail.com>
|
|
6
|
+
License:
|
|
7
|
+
Apache License
|
|
8
|
+
Version 2.0, January 2004
|
|
9
|
+
http://www.apache.org/licenses/
|
|
10
|
+
|
|
11
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
12
|
+
|
|
13
|
+
1. Definitions.
|
|
14
|
+
|
|
15
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
16
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
17
|
+
|
|
18
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
19
|
+
the copyright owner that is granting the License.
|
|
20
|
+
|
|
21
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
22
|
+
other entities that control, are controlled by, or are under common
|
|
23
|
+
control with that entity. For the purposes of this definition,
|
|
24
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
25
|
+
direction or management of such entity, whether by contract or
|
|
26
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
27
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
28
|
+
|
|
29
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
30
|
+
exercising permissions granted by this License.
|
|
31
|
+
|
|
32
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
33
|
+
including but not limited to software source code, documentation
|
|
34
|
+
source, and configuration files.
|
|
35
|
+
|
|
36
|
+
"Object" form shall mean any form resulting from mechanical
|
|
37
|
+
transformation or translation of a Source form, including but
|
|
38
|
+
not limited to compiled object code, generated documentation,
|
|
39
|
+
and conversions to other media types.
|
|
40
|
+
|
|
41
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
42
|
+
Object form, made available under the License, as indicated by a
|
|
43
|
+
copyright notice that is included in or attached to the work
|
|
44
|
+
(an example is provided in the Appendix below).
|
|
45
|
+
|
|
46
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
47
|
+
form, that is based on (or derived from) the Work and for which the
|
|
48
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
49
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
50
|
+
of this License, Derivative Works shall not include works that remain
|
|
51
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
52
|
+
the Work and Derivative Works thereof.
|
|
53
|
+
|
|
54
|
+
"Contribution" shall mean any work of authorship, including
|
|
55
|
+
the original version of the Work and any modifications or additions
|
|
56
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
57
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
58
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
59
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
60
|
+
means any form of electronic, verbal, or written communication sent
|
|
61
|
+
to the Licensor or its representatives, including but not limited to
|
|
62
|
+
communication on electronic mailing lists, source code control systems,
|
|
63
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
64
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
65
|
+
excluding communication that is conspicuously marked or otherwise
|
|
66
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
67
|
+
|
|
68
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
69
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
70
|
+
subsequently incorporated within the Work.
|
|
71
|
+
|
|
72
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
73
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
74
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
75
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
76
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
77
|
+
Work and such Derivative Works in Source or Object form.
|
|
78
|
+
|
|
79
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
(except as stated in this section) patent license to make, have made,
|
|
83
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
84
|
+
where such license applies only to those patent claims licensable
|
|
85
|
+
by such Contributor that are necessarily infringed by their
|
|
86
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
87
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
88
|
+
institute patent litigation against any entity (including a
|
|
89
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
90
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
91
|
+
or contributory patent infringement, then any patent licenses
|
|
92
|
+
granted to You under this License for that Work shall terminate
|
|
93
|
+
as of the date such litigation is filed.
|
|
94
|
+
|
|
95
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
96
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
97
|
+
modifications, and in Source or Object form, provided that You
|
|
98
|
+
meet the following conditions:
|
|
99
|
+
|
|
100
|
+
(a) You must give any other recipients of the Work or
|
|
101
|
+
Derivative Works a copy of this License; and
|
|
102
|
+
|
|
103
|
+
(b) You must cause any modified files to carry prominent notices
|
|
104
|
+
stating that You changed the files; and
|
|
105
|
+
|
|
106
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
107
|
+
that You distribute, all copyright, patent, trademark, and
|
|
108
|
+
attribution notices from the Source form of the Work,
|
|
109
|
+
excluding those notices that do not pertain to any part of
|
|
110
|
+
the Derivative Works; and
|
|
111
|
+
|
|
112
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
113
|
+
distribution, then any Derivative Works that You distribute must
|
|
114
|
+
include a readable copy of the attribution notices contained
|
|
115
|
+
within such NOTICE file, excluding those notices that do not
|
|
116
|
+
pertain to any part of the Derivative Works, in at least one
|
|
117
|
+
of the following places: within a NOTICE text file distributed
|
|
118
|
+
as part of the Derivative Works; within the Source form or
|
|
119
|
+
documentation, if provided along with the Derivative Works; or,
|
|
120
|
+
within a display generated by the Derivative Works, if and
|
|
121
|
+
wherever such third-party notices normally appear. The contents
|
|
122
|
+
of the NOTICE file are for informational purposes only and
|
|
123
|
+
do not modify the License. You may add Your own attribution
|
|
124
|
+
notices within Derivative Works that You distribute, alongside
|
|
125
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
126
|
+
that such additional attribution notices cannot be construed
|
|
127
|
+
as modifying the License.
|
|
128
|
+
|
|
129
|
+
You may add Your own copyright statement to Your modifications and
|
|
130
|
+
may provide additional or different license terms and conditions
|
|
131
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
132
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
133
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
134
|
+
the conditions stated in this License.
|
|
135
|
+
|
|
136
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
137
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
138
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
139
|
+
this License, without any additional terms or conditions.
|
|
140
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
141
|
+
the terms of any separate license agreement you may have executed
|
|
142
|
+
with Licensor regarding such Contributions.
|
|
143
|
+
|
|
144
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
145
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
146
|
+
except as required for reasonable and customary use in describing the
|
|
147
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
148
|
+
|
|
149
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
150
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
151
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
152
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
153
|
+
implied, including, without limitation, any warranties or conditions
|
|
154
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
155
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
156
|
+
appropriateness of using or redistributing the Work and assume any
|
|
157
|
+
risks associated with Your exercise of permissions under this License.
|
|
158
|
+
|
|
159
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
160
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
161
|
+
unless required by applicable law (such as deliberate and grossly
|
|
162
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
163
|
+
liable to You for damages, including any direct, indirect, special,
|
|
164
|
+
incidental, or consequential damages of any character arising as a
|
|
165
|
+
result of this License or out of the use or inability to use the
|
|
166
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
167
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
168
|
+
other commercial damages or losses), even if such Contributor
|
|
169
|
+
has been advised of the possibility of such damages.
|
|
170
|
+
|
|
171
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
172
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
173
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
174
|
+
or other liability obligations and/or rights consistent with this
|
|
175
|
+
License. However, in accepting such obligations, You may act only
|
|
176
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
177
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
178
|
+
defend, and hold each Contributor harmless for any liability
|
|
179
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
180
|
+
of your accepting any such warranty or additional liability.
|
|
181
|
+
|
|
182
|
+
END OF TERMS AND CONDITIONS
|
|
183
|
+
|
|
184
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
185
|
+
|
|
186
|
+
To apply the Apache License to your work, attach the following
|
|
187
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
188
|
+
replaced with your own identifying information. (Don't include
|
|
189
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
190
|
+
comment syntax for the file format. We also recommend that a
|
|
191
|
+
file or class name and description of purpose be included on the
|
|
192
|
+
same "printed page" as the copyright notice for easier
|
|
193
|
+
identification within third-party archives.
|
|
194
|
+
|
|
195
|
+
Copyright [yyyy] [name of copyright owner]
|
|
196
|
+
|
|
197
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
198
|
+
you may not use this file except in compliance with the License.
|
|
199
|
+
You may obtain a copy of the License at
|
|
200
|
+
|
|
201
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
202
|
+
|
|
203
|
+
Unless required by applicable law or agreed to in writing, software
|
|
204
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
205
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
206
|
+
See the License for the specific language governing permissions and
|
|
207
|
+
limitations under the License.
|
|
208
|
+
|
|
209
|
+
Requires-Python: >=3.11
|
|
210
|
+
Description-Content-Type: text/markdown
|
|
211
|
+
License-File: LICENSE
|
|
212
|
+
Requires-Dist: hjson>=3.1.0
|
|
213
|
+
Requires-Dist: pyyaml>=6.0
|
|
214
|
+
Requires-Dist: requests>=2.32.0
|
|
215
|
+
Provides-Extra: aws
|
|
216
|
+
Requires-Dist: boto3>=1.34; extra == "aws"
|
|
217
|
+
Provides-Extra: postgres
|
|
218
|
+
Requires-Dist: pg8000>=1.30.0; extra == "postgres"
|
|
219
|
+
Provides-Extra: parquet
|
|
220
|
+
Requires-Dist: pyarrow>=15.0.0; extra == "parquet"
|
|
221
|
+
Provides-Extra: plot
|
|
222
|
+
Requires-Dist: matplotlib>=3.9.0; extra == "plot"
|
|
223
|
+
Requires-Dist: pandas>=2.2.0; extra == "plot"
|
|
224
|
+
Provides-Extra: dev
|
|
225
|
+
Requires-Dist: pytest; extra == "dev"
|
|
226
|
+
Requires-Dist: black; extra == "dev"
|
|
227
|
+
Requires-Dist: ruff; extra == "dev"
|
|
228
|
+
Provides-Extra: all
|
|
229
|
+
Requires-Dist: boto3>=1.34; extra == "all"
|
|
230
|
+
Requires-Dist: pg8000>=1.30.0; extra == "all"
|
|
231
|
+
Requires-Dist: pyarrow>=15.0.0; extra == "all"
|
|
232
|
+
Requires-Dist: matplotlib>=3.9.0; extra == "all"
|
|
233
|
+
Requires-Dist: pandas>=2.2.0; extra == "all"
|
|
234
|
+
Requires-Dist: pytest; extra == "all"
|
|
235
|
+
Requires-Dist: black; extra == "all"
|
|
236
|
+
Requires-Dist: ruff; extra == "all"
|
|
237
|
+
Dynamic: license-file
|
|
238
|
+
|
|
239
|
+
# python-jack-knife (pjk)
|
|
240
|
+
|
|
241
|
+
A clean Python rewrite of the original open-source **Data Jack Knife (DJK)**.
|
|
242
|
+
|
|
243
|
+
The Java version will eventually die — this is its reincarnation.
|
|
244
|
+
|
|
245
|
+
For now, the CLI entrypoint is `pjk`, since `djk` is still bound to the old Java implementation.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## 🚀 Installation (Pre-1.0 Release)
|
|
250
|
+
|
|
251
|
+
Until 1.0 is reached, you can install directly from GitHub:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pip install git+https://github.com/jmikeschultz/python-jack-knife.git@v0.5.0
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
pjk/__init__.py,sha256=6HGDVcFOFv6VPSNjxVnusm9wHqy01pELX3AyCWFzqWg,128
|
|
2
|
+
pjk/base.py,sha256=-rhV4MTTtCRjhw4GtCjARM_9v0hFpjQ89GwX96sWWbE,12131
|
|
3
|
+
pjk/common.py,sha256=1zl8mVum_DBdjc7l_rgJE4zxh2HCVAjpOiawpQWl1mA,4501
|
|
4
|
+
pjk/log.py,sha256=hfzPD_tFhaTwfDFcDfHdsferBg26tdfee6TO9-9P-s0,2309
|
|
5
|
+
pjk/main.py,sha256=vQp7ys5vy7R1QXOuF15qhfhaRH8GDGm7nu51fJYcaWA,3070
|
|
6
|
+
pjk/man_page.py,sha256=-TQe_vKm1YmKCrpliyGpHq9lqHgB_wi1usIMmsumL8o,4341
|
|
7
|
+
pjk/parser.py,sha256=thaObK9UDa32AsLTsEgOnM7qSihJu4PJpG1NjuIZV7E,9585
|
|
8
|
+
pjk/registry.py,sha256=Rs8HNbw2dz3bHo2mRIpM9yP38KyChba3nvmm8iGnyts,4384
|
|
9
|
+
pjk/version.py,sha256=MuxIDFvGjjoHX3fwvjCLu0SzLrQYnsCTtASVNv5_cSM,91
|
|
10
|
+
pjk/pipes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
pjk/pipes/denorm.py,sha256=3zY8E34e5ORiddP3zEXRg1_iLYV6ivsdEBilNBjjHTo,2065
|
|
12
|
+
pjk/pipes/factory.py,sha256=eP9DMiC8nNaCKma1iw-XGhKeDVXmWgRUULx_lRO-2Us,1816
|
|
13
|
+
pjk/pipes/filter.py,sha256=oML_UkqEPnmZuc7fi1C0W2yx5j2XvAy34vud8IwBPZY,1781
|
|
14
|
+
pjk/pipes/head.py,sha256=wCkLyL_yjH98H7Xu2Zp8lRR2CNiIToW8L8uSQWC_sOI,948
|
|
15
|
+
pjk/pipes/join.py,sha256=yY6I5_Qs54H9gxaiQeTqDNjBHMbd4vXICQsQpiIu8F0,2657
|
|
16
|
+
pjk/pipes/let_reduce.py,sha256=QfCs-omZq-a2hMFr5Nnt1hhQuiXol0IMA2diXwesVUA,7153
|
|
17
|
+
pjk/pipes/map.py,sha256=dJv78yxqG1YOjeAYXqOuaFWqioLrPLX9CwiqJ-tnJQM,3289
|
|
18
|
+
pjk/pipes/move_field.py,sha256=1jv33zCyJqJZJ50wAyXAdZTZPiybgI3zRm3xjSrW_sU,1026
|
|
19
|
+
pjk/pipes/postgres_pipe.py,sha256=3HduRyazG0CSrT-3obmcpH-acw4MTJG95JqkqvN0Cl4,6915
|
|
20
|
+
pjk/pipes/remove_field.py,sha256=QjEO6-phRngM2emBJ6xv8UA2d_iA44tYN8Crx4lhqQ0,1169
|
|
21
|
+
pjk/pipes/select.py,sha256=-zVuMl2sXzjByGapQ58pdgxqaDgExw2mpufA-WCIBfo,1347
|
|
22
|
+
pjk/pipes/sort.py,sha256=437DoZd5fBVPe7SJ3nuFMUAafHVg1z5PPx13ZhY7WxY,2136
|
|
23
|
+
pjk/pipes/tail.py,sha256=Xv4mfhndUoaielyK8LZF4F5INI0Ypkg6pyh0txo3xds,1086
|
|
24
|
+
pjk/pipes/user_pipe_factory.py,sha256=KfH7fdVfQp0LKRZkWwcyLSH8dtYtWIHrzfs1BSPhJLk,1572
|
|
25
|
+
pjk/pipes/where.py,sha256=Qs9aH3rZTW_O46WImqein89t9Cn2rbnVjVCAzz9GNY4,1745
|
|
26
|
+
pjk/sinks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
pjk/sinks/csv_sink.py,sha256=U5PqtbaOGfVwkEI1gtWfLxJQpeMWSIRPtp74qEDM2SI,996
|
|
28
|
+
pjk/sinks/ddb.py,sha256=TxsoszjcynS0GdneK6D4MLxRjBMhq9XpjCs-PcVyPp0,1678
|
|
29
|
+
pjk/sinks/devnull.py,sha256=GDjX7zRH7C3DZYxu7wKJX_u0cyneu4TZ-3k7BF0UgQE,843
|
|
30
|
+
pjk/sinks/dir_sink.py,sha256=y69esWtFS6eTla5UyJ_I_o8Dboysi_xhH3--sHgAoj0,1767
|
|
31
|
+
pjk/sinks/expect.py,sha256=xaIpF1lyq6dmtaKllJiiXApPWjHXqlW3zOEow7wsRow,1933
|
|
32
|
+
pjk/sinks/factory.py,sha256=V1QeIeRevKbSkkz9symObY5T_47TWZuR5QDFcsUiKig,3351
|
|
33
|
+
pjk/sinks/graph.py,sha256=4mvKHwUxAWEzSJgqOhNaW4EM0Uj-S7ATGG9E9reu680,1988
|
|
34
|
+
pjk/sinks/graph_bar_line.py,sha256=FKrR1ZCBOojKGZ6s920peZBEUWUp5fsbnhkjD-bq-xs,8842
|
|
35
|
+
pjk/sinks/graph_cumulative.py,sha256=fFXI9MSLhxKk5Xwb4df4-QqrctHeiwyXqj4S_pUNHAw,1711
|
|
36
|
+
pjk/sinks/graph_hist.py,sha256=drkAeAMhSXRM-Qm_xfK7WJ1u_usMVlC_TDP1GF_xppI,1994
|
|
37
|
+
pjk/sinks/graph_scatter.py,sha256=3nnIdux9oy8Na2Nt80UzPm03abEglXZyrrHB6ciJabc,1027
|
|
38
|
+
pjk/sinks/json_sink.py,sha256=DOs6tg6IVb-euR3IuD1nuSNBFlAg4gl_pTbns8lS8yo,787
|
|
39
|
+
pjk/sinks/s3_sink.py,sha256=AeV-ObqYh1dkbgFnVmg11ehhLT0R_JbyZimWPzwhDhM,3065
|
|
40
|
+
pjk/sinks/sinks.py,sha256=7oFpDfu-NktFFX2yTh3IvMPnQ5hjv3edsMJIoQmtBsQ,2014
|
|
41
|
+
pjk/sinks/stdout.py,sha256=5l-WrIGosTYEYw_L8mf7jsmoPkoaQjfCGTT8htVfSpE,1661
|
|
42
|
+
pjk/sinks/tsv_sink.py,sha256=XngZ3EZXa0gJPVtsS1ru4KnhJyYr8zZJeaySQDBYRWg,660
|
|
43
|
+
pjk/sinks/user_sink_factory.py,sha256=b8sh_nmEt_Oq5s73Tdx4iIhrt6m7Rh9Ojqx18R0FrGk,1355
|
|
44
|
+
pjk/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
+
pjk/sources/csv_source.py,sha256=4FDqddqi6Oh3EYCWaReczDRrydKSQtzTmjrBVCj7sAc,785
|
|
46
|
+
pjk/sources/dir_source.py,sha256=a0zpSD8OP4LyaDL5BuDKxItf4I5za20c7F8oaGxxpXk,2229
|
|
47
|
+
pjk/sources/factory.py,sha256=wwtOptFnhiYX-mTWn1whzyucidVcgzI6sdHRhMBKCAU,3181
|
|
48
|
+
pjk/sources/format_usage.py,sha256=FDX4wCGoFaILgsSq0nIB0ZH16Jh73mG3RgWKzk9hgWM,605
|
|
49
|
+
pjk/sources/inline_source.py,sha256=iskdhxoJ6uzzBZpy-1N2fH0UyJuSATMw7soE_ZRz1Yg,1703
|
|
50
|
+
pjk/sources/json_source.py,sha256=NLNqhzYxKZFWNl8N1DcaT3Ne4tMs0TMGb4bo3U9LFs8,1145
|
|
51
|
+
pjk/sources/lazy_file.py,sha256=fQYaQz7bytG9vY4JNtIQJxfHWFowCn5il51H7vQrTNg,400
|
|
52
|
+
pjk/sources/lazy_file_local.py,sha256=giDruMzRJSfUmWtuuJcXb2mUF2Cz0og-l-HOk3tFv0I,588
|
|
53
|
+
pjk/sources/lazy_file_s3.py,sha256=a4PyBM_WoHfmKrbMucTlqxOPF79KGRyJGxECD-dVq5Q,877
|
|
54
|
+
pjk/sources/parquet_source.py,sha256=5r4k-VNfdIjyR1ZQ9FcO5nzDaGEqg2j-rAecGP5aGtk,974
|
|
55
|
+
pjk/sources/s3_source.py,sha256=lcbrIXy9YGSQQ3_tzgJGhhLA82BpId0y3ezBQI68zgs,5225
|
|
56
|
+
pjk/sources/source_list.py,sha256=5L2vFrtVSl9rKf2NjfpUFOOAb-iypVDKYCw1-3xgcEo,644
|
|
57
|
+
pjk/sources/sql_source.py,sha256=yROxQYxYCHkFRCXClqzy_XLUeJl9QT8DIMe09SQshy4,868
|
|
58
|
+
pjk/sources/tsv_source.py,sha256=OYhRa9Vm4zkMbBOT_5c_h8vBq0WJ6HL2gyiiO26GCAo,450
|
|
59
|
+
pjk/sources/user_source_factory.py,sha256=if10G9ON4kRepdEBK6i--t0dbgv7lNh4slVnRsEqzSA,1199
|
|
60
|
+
python_jack_knife-0.5.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
61
|
+
python_jack_knife-0.5.0.dist-info/METADATA,sha256=HlXcQQ6UdSi0ny9tjZSCiN-GQDjNdJMEE5wP1MHnsjI,14641
|
|
62
|
+
python_jack_knife-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
63
|
+
python_jack_knife-0.5.0.dist-info/entry_points.txt,sha256=kzZ10zEisvEaG2xYqqw7xRpuV62rAO_dPEHnM6USelk,38
|
|
64
|
+
python_jack_knife-0.5.0.dist-info/top_level.txt,sha256=r-Ef_I9SbVDL9jD-W0WtshstLos_7guWbpItYxxSllQ,4
|
|
65
|
+
python_jack_knife-0.5.0.dist-info/RECORD,,
|