linkinpycli 0.0.1__tar.gz → 0.0.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linkinpycli
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: CLI finder for LinkinPy integration
5
5
  Project-URL: Homepage, https://github.com/HenriquesLab/LinkinPy
6
6
  Project-URL: Repository, https://github.com/HenriquesLab/LinkinPy
@@ -15,6 +15,7 @@ Classifier: Operating System :: OS Independent
15
15
  Classifier: Programming Language :: Python :: 3
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Requires-Python: >=3.10
18
+ Requires-Dist: pyyaml>=6.0.0
18
19
  Description-Content-Type: text/markdown
19
20
 
20
21
  # linkinpycli
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "linkinpycli"
7
- version = "0.0.1"
7
+ version = "0.0.2"
8
8
  description = "CLI finder for LinkinPy integration"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -20,10 +20,13 @@ classifiers = [
20
20
  "Programming Language :: Python :: 3.10",
21
21
  "Operating System :: OS Independent",
22
22
  ]
23
- dependencies = []
23
+ dependencies = [
24
+ "PyYAML>=6.0.0",
25
+ ]
24
26
 
25
27
  [project.scripts]
26
28
  linkinpy-parse = "linkinpycli.linkinpycli:parse_linkinpy_scripts"
29
+ linkinpy-usage = "linkinpycli.linkinpycli:save_linkinpy_usage"
27
30
 
28
31
  [project.urls]
29
32
  Homepage = "https://github.com/HenriquesLab/LinkinPy"
@@ -1,11 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import argparse
3
4
  import inspect
4
5
  import json
6
+ from datetime import datetime, timezone
5
7
  from importlib import import_module
6
8
  from importlib.metadata import EntryPoint
7
9
  from pathlib import Path
8
10
 
11
+ import yaml
12
+
9
13
  from .crawler import find_linkinpy_entry_points
10
14
 
11
15
 
@@ -110,6 +114,59 @@ def parse_linkinpy_scripts() -> None:
110
114
  print(f"Saved {len(scripts)} scripts to {output_path}")
111
115
 
112
116
 
117
+ def save_linkinpy_usage() -> None:
118
+ """Append a LinkinPy run entry to ~/.linkinpy/usage.yaml."""
119
+ parser = argparse.ArgumentParser(
120
+ prog="linkinpy-usage",
121
+ description="Save LinkinPy run usage metadata.",
122
+ )
123
+ parser.add_argument("--package", required=True, help="Package used in the run.")
124
+ parser.add_argument("--method", required=True, help="Method name used in the run.")
125
+ parser.add_argument(
126
+ "--arg",
127
+ dest="arguments",
128
+ action="append",
129
+ default=[],
130
+ metavar="KEY=VALUE",
131
+ help="Argument pair used in the run. Can be passed multiple times.",
132
+ )
133
+ parsed = parser.parse_args()
134
+
135
+ arguments: dict[str, str] = {}
136
+ for item in parsed.arguments:
137
+ if "=" not in item:
138
+ raise SystemExit(f"Invalid --arg '{item}'. Expected KEY=VALUE.")
139
+ key, value = item.split("=", 1)
140
+ key = key.strip()
141
+ if not key:
142
+ raise SystemExit(f"Invalid --arg '{item}'. KEY cannot be empty.")
143
+ arguments[key] = value.strip()
144
+
145
+ linkinpy_home = Path.home() / ".linkinpy"
146
+ linkinpy_home.mkdir(parents=True, exist_ok=True)
147
+ usage_path = linkinpy_home / "usage.yaml"
148
+
149
+ existing = []
150
+ if usage_path.exists():
151
+ loaded = yaml.safe_load(usage_path.read_text(encoding="utf-8"))
152
+ if isinstance(loaded, list):
153
+ existing = loaded
154
+
155
+ entry = {
156
+ "timestamp": datetime.now(timezone.utc).isoformat(),
157
+ "package": parsed.package,
158
+ "method": parsed.method,
159
+ "arguments": arguments,
160
+ }
161
+ existing.append(entry)
162
+
163
+ usage_path.write_text(
164
+ yaml.safe_dump(existing, sort_keys=False, allow_unicode=False),
165
+ encoding="utf-8",
166
+ )
167
+ print(f"Saved usage entry to {usage_path}")
168
+
169
+
113
170
  class LinkinPyCLI:
114
171
  """Minimal example class generated by the template."""
115
172
 
@@ -0,0 +1,2 @@
1
+ def test_LinkinPyCLI() -> None:
2
+ pass
@@ -1,6 +0,0 @@
1
- from linkinpycli.linkinpycli import LinkinPyCLI
2
-
3
- def test_LinkinPyCLI() -> None:
4
- my_class = LinkinPyCLI()
5
- example_output = my_class.run()
6
- assert example_output == 1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes