starbash 0.1.9__py3-none-any.whl → 0.1.11__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.
starbash/commands/info.py CHANGED
@@ -76,6 +76,75 @@ def filter():
76
76
  dump_column(sb, "Filter", Database.FILTER_KEY)
77
77
 
78
78
 
79
+ kind_arg = typer.Argument(
80
+ help="Optional image type to filter by (e.g., BIAS, DARK, FLAT, LIGHT)",
81
+ )
82
+
83
+
84
+ @app.command()
85
+ def master(
86
+ kind: Annotated[
87
+ str | None,
88
+ kind_arg,
89
+ ] = None,
90
+ ):
91
+ """List all precalculated master images (darks, biases, flats)."""
92
+ with Starbash("info.master") as sb:
93
+ # Get the master repo
94
+ images = sb.get_master_images(kind)
95
+
96
+ if not images:
97
+ kind_msg = f" of type '{kind}'" if kind else ""
98
+ console.print(f"[yellow]No master images{kind_msg} found.[/yellow]")
99
+ return
100
+
101
+ # Create table to display results
102
+ title = f"Master Images ({len(images)} total)"
103
+ if kind:
104
+ title = f"Master {kind} Images ({len(images)} total)"
105
+ table = Table(title=title)
106
+ table.add_column("Date", style=TABLE_COLUMN_STYLE, no_wrap=True)
107
+ table.add_column("Type", style=TABLE_COLUMN_STYLE, no_wrap=True)
108
+ table.add_column("Filename", style=TABLE_VALUE_STYLE, no_wrap=False)
109
+
110
+ # Sort by date, then by type
111
+ sorted_images = sorted(
112
+ images,
113
+ key=lambda img: (
114
+ img.get(Database.DATE_OBS_KEY) or img.get(Database.DATE_KEY) or "",
115
+ img.get(Database.IMAGETYP_KEY) or "",
116
+ ),
117
+ )
118
+
119
+ for image in sorted_images:
120
+ date = (
121
+ image.get(Database.DATE_OBS_KEY)
122
+ or image.get(Database.DATE_KEY)
123
+ or "Unknown"
124
+ )
125
+ # Extract just the date part (YYYY-MM-DD) if it's a full ISO timestamp
126
+ if "T" in date:
127
+ date = date.split("T")[0]
128
+
129
+ kind = image.get(Database.IMAGETYP_KEY) or "Unknown"
130
+ filename = image.get("path") or "Unknown"
131
+
132
+ table.add_row(date, kind, filename)
133
+
134
+ console.print(table)
135
+
136
+
137
+ @app.command(hidden=True)
138
+ def masters(
139
+ kind: Annotated[
140
+ str | None,
141
+ kind_arg,
142
+ ] = None,
143
+ ):
144
+ """Alias for 'info master' command."""
145
+ master(kind)
146
+
147
+
79
148
  @app.callback(invoke_without_command=True)
80
149
  def main_callback(ctx: typer.Context):
81
150
  """Show user preferences location and other app info.
starbash/commands/repo.py CHANGED
@@ -7,6 +7,7 @@ import starbash
7
7
  from repo import repo_suffix, Repo
8
8
  from starbash.app import Starbash
9
9
  from starbash import console, log_filter_level
10
+ from starbash.paths import get_user_documents_dir
10
11
  from starbash.toml import toml_from_template
11
12
 
12
13
  app = typer.Typer(invoke_without_command=True)
@@ -87,10 +88,15 @@ def main(
87
88
 
88
89
  @app.command()
89
90
  def add(
90
- path: str,
91
+ path: Annotated[str | None, typer.Argument(help="Path to the respository")] = None,
91
92
  master: bool = typer.Option(
92
93
  False, "--master", help="Mark this new repository for master files."
93
94
  ),
95
+ processed: bool = typer.Option(
96
+ False,
97
+ "--processed",
98
+ help="Mark this new repository for processed output files.",
99
+ ),
94
100
  ):
95
101
  """
96
102
  Add a repository. path is either a local path or a remote URL.
@@ -98,6 +104,17 @@ def add(
98
104
  repo_type = None
99
105
  if master:
100
106
  repo_type = "master"
107
+ elif processed:
108
+ repo_type = "processed"
109
+
110
+ if path is None:
111
+ if repo_type is not None:
112
+ # if we know the repo type we can auto create a default path
113
+ path = str(get_user_documents_dir() / "repos" / repo_type)
114
+ else:
115
+ console.print("[red]Error: path is required for input repositories[/red]")
116
+ raise typer.Exit(1)
117
+
101
118
  with Starbash("repo.add") as sb:
102
119
  p = Path(path)
103
120
 
@@ -115,7 +132,7 @@ def add(
115
132
  overrides={
116
133
  "REPO_TYPE": repo_type,
117
134
  "REPO_PATH": str(p),
118
- "DEFAULT_RELATIVE": "{instrument}/{date}/{imagetyp}/master_{imagetyp}.fits",
135
+ "DEFAULT_RELATIVE": "{instrument}/{date}/{imagetyp}/master_{session_config}.fit",
119
136
  },
120
137
  )
121
138
  else:
@@ -134,7 +151,6 @@ def add(
134
151
  # we don't yet always write default config files at roots of repos, but it would be easy to add here
135
152
  # r.write_config()
136
153
  sb.user_repo.write_config()
137
- # FIXME, we also need to index the newly added repo!!!
138
154
 
139
155
 
140
156
  def repo_url_to_repo(sb: Starbash, repo_url: str | None) -> Repo | None:
@@ -71,7 +71,7 @@ def complete_column(incomplete: str, column_name: str):
71
71
  c = get_column(sb, column_name)
72
72
 
73
73
  for item, count in c.items():
74
- if item.startswith(incomplete):
74
+ if item.lower().startswith(incomplete.lower()):
75
75
  yield (item, f"{count} sessions")
76
76
 
77
77
 
@@ -253,6 +253,13 @@ def list_sessions(
253
253
  telescope = get_key(Database.TELESCOP_KEY)
254
254
  telescopes.add(telescope)
255
255
 
256
+ # Show the non normalized target name
257
+ metadata = sess.get("metadata")
258
+ if metadata:
259
+ long_name = metadata.get("OBJECT")
260
+ if long_name:
261
+ object = long_name
262
+
256
263
  # Format total exposure time as integer seconds
257
264
  exptime_raw = get_key(Database.EXPTIME_TOTAL_KEY)
258
265
  try: