machineconfig 4.98__py3-none-any.whl → 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.
- machineconfig/cluster/remote/script_execution.py +1 -1
- machineconfig/jobs/installer/custom/gh.py +68 -39
- machineconfig/jobs/installer/custom/hx.py +1 -1
- machineconfig/jobs/installer/custom_dev/bypass_paywall.py +1 -1
- machineconfig/jobs/installer/custom_dev/wezterm.py +68 -35
- machineconfig/jobs/python/python_ve_symlink.py +1 -1
- machineconfig/profile/create.py +59 -40
- machineconfig/profile/shell.py +1 -1
- machineconfig/scripts/python/cloud_copy.py +1 -1
- machineconfig/scripts/python/cloud_mount.py +1 -1
- machineconfig/scripts/python/cloud_repo_sync.py +1 -1
- machineconfig/scripts/python/count_lines.py +343 -0
- machineconfig/scripts/python/count_lines_frontend.py +12 -0
- machineconfig/scripts/python/croshell.py +1 -1
- machineconfig/scripts/python/devops.py +3 -1
- machineconfig/scripts/python/devops_add_identity.py +1 -1
- machineconfig/scripts/python/devops_add_ssh_key.py +1 -1
- machineconfig/scripts/python/devops_backup_retrieve.py +1 -1
- machineconfig/scripts/python/devops_update_repos.py +135 -65
- machineconfig/scripts/python/dotfile.py +41 -15
- machineconfig/scripts/python/fire_jobs.py +1 -1
- machineconfig/scripts/python/ftpx.py +101 -49
- machineconfig/scripts/python/helpers/helpers2.py +2 -2
- machineconfig/scripts/python/helpers/helpers4.py +1 -1
- machineconfig/scripts/python/helpers/repo_sync_helpers.py +1 -1
- machineconfig/scripts/python/mount_nfs.py +13 -7
- machineconfig/scripts/python/mount_ssh.py +1 -1
- machineconfig/scripts/python/repos.py +20 -6
- machineconfig/scripts/python/repos_helper_action.py +1 -1
- machineconfig/scripts/python/repos_helper_clone.py +4 -4
- machineconfig/scripts/python/repos_helper_record.py +1 -1
- machineconfig/scripts/python/sessions.py +5 -1
- machineconfig/scripts/python/share_terminal.py +13 -6
- machineconfig/scripts/python/start_slidev.py +1 -1
- machineconfig/scripts/python/wsl_windows_transfer.py +1 -1
- machineconfig/setup_windows/wt_and_pwsh/set_wt_settings.py +1 -1
- machineconfig/utils/code.py +1 -1
- machineconfig/utils/installer.py +1 -1
- machineconfig/utils/installer_utils/installer_abc.py +1 -1
- machineconfig/utils/installer_utils/installer_class.py +1 -1
- machineconfig/utils/links.py +1 -1
- machineconfig/utils/path_helper.py +1 -1
- machineconfig/utils/scheduler.py +1 -1
- {machineconfig-4.98.dist-info → machineconfig-5.0.dist-info}/METADATA +1 -1
- {machineconfig-4.98.dist-info → machineconfig-5.0.dist-info}/RECORD +51 -50
- machineconfig/cluster/templates/utils.py +0 -51
- /machineconfig/cluster/{templates → remote}/run_cloud.py +0 -0
- /machineconfig/cluster/{templates → remote}/run_cluster.py +0 -0
- /machineconfig/cluster/{templates → remote}/run_remote.py +0 -0
- {machineconfig-4.98.dist-info → machineconfig-5.0.dist-info}/WHEEL +0 -0
- {machineconfig-4.98.dist-info → machineconfig-5.0.dist-info}/entry_points.txt +0 -0
- {machineconfig-4.98.dist-info → machineconfig-5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
from git import Repo
|
|
5
|
+
from collections import defaultdict
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from rich.progress import track
|
|
10
|
+
import polars as pl
|
|
11
|
+
import plotly.graph_objects as go
|
|
12
|
+
import plotly.express as px
|
|
13
|
+
import typer
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from typing import Any, Dict, List, Optional, Union
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
app = typer.Typer()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def count_lines_in_commit(commit: "Any") -> int:
|
|
24
|
+
total_lines = 0
|
|
25
|
+
for file in commit.stats.files:
|
|
26
|
+
if str(file).endswith(".py"):
|
|
27
|
+
blob = commit.tree / file
|
|
28
|
+
total_lines += len(blob.data_stream.read().decode("utf-8").splitlines())
|
|
29
|
+
return total_lines
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def count_historical_loc(repo_path: str) -> int:
|
|
33
|
+
repo = Repo(repo_path)
|
|
34
|
+
file_line_counts: "Dict[str, int]" = defaultdict(int)
|
|
35
|
+
total_commits: int = sum(1 for _ in repo.iter_commits())
|
|
36
|
+
print(f"Total commits to process: {total_commits}")
|
|
37
|
+
for i, commit in enumerate(repo.iter_commits(), 1):
|
|
38
|
+
if i % 100 == 0 or i == total_commits:
|
|
39
|
+
print(f"Processing commit {i}/{total_commits} ({i / total_commits:.1%})")
|
|
40
|
+
try:
|
|
41
|
+
# Handle initial commits that have no parents
|
|
42
|
+
if not commit.parents:
|
|
43
|
+
# For initial commit, count all lines in Python files
|
|
44
|
+
for file in commit.stats.files:
|
|
45
|
+
if str(file).endswith(".py"):
|
|
46
|
+
file_line_counts[str(file)] += commit.stats.files[file]["insertions"]
|
|
47
|
+
else:
|
|
48
|
+
# For commits with parents, use stats
|
|
49
|
+
for file in commit.stats.files:
|
|
50
|
+
if str(file).endswith(".py"):
|
|
51
|
+
file_line_counts[str(file)] += commit.stats.files[file]["insertions"]
|
|
52
|
+
except Exception:
|
|
53
|
+
# If stats fail (e.g., corrupted parent), skip this commit
|
|
54
|
+
print(f"Warning: Could not get stats for commit {commit.hexsha[:8]}, skipping")
|
|
55
|
+
continue
|
|
56
|
+
|
|
57
|
+
print(f"\nProcessed files: {len(file_line_counts)}")
|
|
58
|
+
return sum(file_line_counts.values())
|
|
59
|
+
|
|
60
|
+
def count_python_lines(commit: "Any") -> int:
|
|
61
|
+
"""Count total lines in Python files for a specific commit"""
|
|
62
|
+
total_lines = 0
|
|
63
|
+
try:
|
|
64
|
+
for blob in commit.tree.traverse():
|
|
65
|
+
if blob.path.endswith(".py"):
|
|
66
|
+
try:
|
|
67
|
+
content = blob.data_stream.read().decode("utf-8")
|
|
68
|
+
total_lines += len(content.splitlines())
|
|
69
|
+
except Exception as _e:
|
|
70
|
+
continue
|
|
71
|
+
except Exception as _e:
|
|
72
|
+
return 0
|
|
73
|
+
return total_lines
|
|
74
|
+
def get_default_branch(repo: Repo) -> str:
|
|
75
|
+
"""Get the default branch name of the repository"""
|
|
76
|
+
try:
|
|
77
|
+
_ = repo.refs["main"]
|
|
78
|
+
return "main" # First try 'main'
|
|
79
|
+
except IndexError:
|
|
80
|
+
try:
|
|
81
|
+
_ = repo.refs["master"]
|
|
82
|
+
return "master" # Then try 'master'
|
|
83
|
+
except IndexError:
|
|
84
|
+
return repo.head.reference.name # If neither exists, get the branch the HEAD is pointing to
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@app.command()
|
|
88
|
+
def count_historical(repo_path: str = typer.Argument(..., help="Path to the git repository")):
|
|
89
|
+
"""Count total historical lines of Python code in the repository."""
|
|
90
|
+
print(f"Analyzing repository: {repo_path}")
|
|
91
|
+
total_loc: int = count_historical_loc(repo_path)
|
|
92
|
+
print(f"\nTotal historical lines of Python code: {total_loc}")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@app.command()
|
|
96
|
+
def analyze_over_time(repo_path: str = typer.Argument(..., help="Path to the git repository")):
|
|
97
|
+
"""Analyze a git repository to track Python code size over time with visualization."""
|
|
98
|
+
repo: Repo = Repo(repo_path)
|
|
99
|
+
branch_name: str = get_default_branch(repo)
|
|
100
|
+
print(f"🔍 Using branch: {branch_name}")
|
|
101
|
+
commit_data: "List[Dict[str, Any]]" = []
|
|
102
|
+
print("⏳ Analyzing commits...")
|
|
103
|
+
try:
|
|
104
|
+
commits = list(repo.iter_commits(branch_name))
|
|
105
|
+
from datetime import timezone
|
|
106
|
+
|
|
107
|
+
for commit in track(commits, description="Processing commits..."):
|
|
108
|
+
commit_data.append({"hash": commit.hexsha, "dtmExit": datetime.fromtimestamp(commit.committed_date, tz=timezone.utc), "lines": count_python_lines(commit)})
|
|
109
|
+
except Exception as e:
|
|
110
|
+
print(f"❌ Error analyzing commits: {str(e)}")
|
|
111
|
+
return
|
|
112
|
+
df = pl.DataFrame(commit_data)
|
|
113
|
+
df = df.sort("dtmExit")
|
|
114
|
+
# Create interactive plotly figure with dark theme and all bells and whistles
|
|
115
|
+
fig = go.Figure()
|
|
116
|
+
# Add line chart with gradient fill and sparkle effect
|
|
117
|
+
fig.add_trace(go.Scatter(x=df["dtmExit"], y=df["lines"], mode="lines", line={"width": 3, "color": "#00b4ff"}, fill="tozeroy", fillcolor="rgba(0, 180, 255, 0.2)", name="Lines of Code", hovertemplate="<b>Date:</b> %{x}<br><b>Lines:</b> %{y:,}<extra></extra>"))
|
|
118
|
+
# Add markers for significant points (min, max, last)
|
|
119
|
+
min_idx = df["lines"].arg_min()
|
|
120
|
+
max_idx = df["lines"].arg_max()
|
|
121
|
+
min_point = df.slice(min_idx, 1).to_dicts()[0] if min_idx is not None else {}
|
|
122
|
+
max_point = df.slice(max_idx, 1).to_dicts()[0] if max_idx is not None else {}
|
|
123
|
+
last_point = df.slice(-1, 1).to_dicts()[0]
|
|
124
|
+
|
|
125
|
+
# Add markers for significant points
|
|
126
|
+
fig.add_trace(
|
|
127
|
+
go.Scatter(
|
|
128
|
+
x=[min_point["dtmExit"], max_point["dtmExit"], last_point["dtmExit"]],
|
|
129
|
+
y=[min_point["lines"], max_point["lines"], last_point["lines"]],
|
|
130
|
+
mode="markers",
|
|
131
|
+
marker={"size": [10, 14, 12], "color": ["#ff4f4f", "#4fff4f", "#4f4fff"], "line": {"width": 2, "color": "white"}, "symbol": ["circle", "star", "diamond"]},
|
|
132
|
+
name="Key Points",
|
|
133
|
+
hovertemplate="<b>%{text}</b><br>Date: %{x}<br>Lines: %{y:,}<extra></extra>",
|
|
134
|
+
text=[f"🔽 Min: {min_point['lines']:,} lines", f"🔼 Max: {max_point['lines']:,} lines", f"📊 Current: {last_point['lines']:,} lines"],
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# Add annotation only for current point
|
|
139
|
+
# annotations = [
|
|
140
|
+
# {"x": last_point['date'], "y": last_point['lines'], "text": f"📊 Current: {last_point['lines']:,} lines", "showarrow": True, "arrowhead": 2, "arrowsize": 1,
|
|
141
|
+
# "arrowwidth": 2, "arrowcolor": "#ffffff", "font": {"size": 14, "color": "#ffffff"}, "bgcolor": "#00b4ff", "bordercolor": "#ffffff",
|
|
142
|
+
# "borderwidth": 1, "borderpad": 4, "ax": 40, "ay": -40}
|
|
143
|
+
# ]
|
|
144
|
+
|
|
145
|
+
# Update layout with dark theme and customizations
|
|
146
|
+
fig.update_layout(
|
|
147
|
+
title={"text": "✨ Python Code Base Size Over Time ✨", "y": 0.95, "x": 0.5, "xanchor": "center", "yanchor": "top", "font": {"size": 24, "color": "white"}},
|
|
148
|
+
xaxis_title="Date 📅",
|
|
149
|
+
yaxis_title="Lines of Code 📝",
|
|
150
|
+
hovermode="closest",
|
|
151
|
+
template="plotly_dark",
|
|
152
|
+
plot_bgcolor="rgba(25, 25, 35, 1)",
|
|
153
|
+
paper_bgcolor="rgba(15, 15, 25, 1)",
|
|
154
|
+
font={"family": "Arial, sans-serif", "size": 14, "color": "white"}, # annotations=annotations,
|
|
155
|
+
autosize=True,
|
|
156
|
+
height=700,
|
|
157
|
+
margin={"l": 80, "r": 80, "t": 100, "b": 80},
|
|
158
|
+
xaxis={"showgrid": True, "gridcolor": "rgba(80, 80, 100, 0.2)", "showline": True, "linecolor": "rgba(200, 200, 255, 0.2)", "tickfont": {"size": 12}},
|
|
159
|
+
yaxis={"showgrid": True, "gridcolor": "rgba(80, 80, 100, 0.2)", "showline": True, "linecolor": "rgba(200, 200, 255, 0.2)", "tickformat": ",", "tickfont": {"size": 12}},
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Add range slider for date selection
|
|
163
|
+
fig.update_xaxes(rangeslider_visible=True, rangeslider_thickness=0.05)
|
|
164
|
+
|
|
165
|
+
# Save as interactive HTML and static image
|
|
166
|
+
plot_dir = Path.home().joinpath("tmp_results", "tmp_images", Path(repo_path).name)
|
|
167
|
+
plot_dir.mkdir(parents=True, exist_ok=True)
|
|
168
|
+
|
|
169
|
+
html_path = plot_dir.joinpath("code_size_evolution.html")
|
|
170
|
+
png_path = plot_dir.joinpath("code_size_evolution.png")
|
|
171
|
+
|
|
172
|
+
fig.write_html(html_path, include_plotlyjs="cdn")
|
|
173
|
+
fig.write_image(png_path, width=1200, height=700, scale=2)
|
|
174
|
+
|
|
175
|
+
print(f"🖼️ Interactive plot saved as {html_path}")
|
|
176
|
+
print(f"🖼️ Static image saved as {png_path}")
|
|
177
|
+
# Print statistics
|
|
178
|
+
print("\n📊 Repository Statistics:")
|
|
179
|
+
print(f"📚 Total commits analyzed: {len(df)}")
|
|
180
|
+
print(f"🔙 Initial line count: {df['lines'][-1]:,}")
|
|
181
|
+
print(f"🔜 Final line count: {df['lines'][0]:,}")
|
|
182
|
+
print(f"📈 Net change: {df['lines'][0] - df['lines'][-1]:,} lines")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _print_python_files_by_size_impl(repo_path: str) -> "Union[pl.DataFrame, Exception]":
|
|
186
|
+
try:
|
|
187
|
+
import os
|
|
188
|
+
if not os.path.exists(repo_path):
|
|
189
|
+
return ValueError(f"Repository path does not exist: {repo_path}")
|
|
190
|
+
# Initialize data storage
|
|
191
|
+
file_data: "List[Dict[str, Union[str, int]]]" = []
|
|
192
|
+
|
|
193
|
+
# Walk through the repository
|
|
194
|
+
for root, _, files in os.walk(repo_path):
|
|
195
|
+
# Skip .git directory and other hidden directories
|
|
196
|
+
if ".git" in Path(root).parts or any(part.startswith(".") for part in Path(root).parts):
|
|
197
|
+
continue
|
|
198
|
+
|
|
199
|
+
for file in files:
|
|
200
|
+
if file.endswith(".py"):
|
|
201
|
+
file_path = os.path.join(root, file)
|
|
202
|
+
try:
|
|
203
|
+
# Count lines in the file
|
|
204
|
+
with open(file_path, "r", encoding="utf-8", errors="replace") as f:
|
|
205
|
+
line_count = sum(1 for _ in f)
|
|
206
|
+
|
|
207
|
+
# Make path relative to repo_path for better display
|
|
208
|
+
rel_path = os.path.relpath(file_path, repo_path)
|
|
209
|
+
file_data.append({"filename": rel_path, "lines": line_count})
|
|
210
|
+
except Exception as e:
|
|
211
|
+
print(f"⚠️ Warning: Could not read {file_path}: {str(e)}")
|
|
212
|
+
continue
|
|
213
|
+
|
|
214
|
+
# Check if any files were found
|
|
215
|
+
if not file_data:
|
|
216
|
+
return ValueError("❌ No Python files found in the repository")
|
|
217
|
+
|
|
218
|
+
# Convert to DataFrame
|
|
219
|
+
df = pl.DataFrame(file_data)
|
|
220
|
+
|
|
221
|
+
# Sort DataFrame by line count (descending)
|
|
222
|
+
df = df.sort("lines", descending=True)
|
|
223
|
+
df = df.filter(pl.col("lines") > 0) # Filter out empty files
|
|
224
|
+
|
|
225
|
+
# Add total count
|
|
226
|
+
total_lines = int(df["lines"].sum())
|
|
227
|
+
file_count: int = len(df)
|
|
228
|
+
|
|
229
|
+
# Print the DataFrame
|
|
230
|
+
print("\n📊 Python Files Line Count (sorted max to min):")
|
|
231
|
+
print(df)
|
|
232
|
+
print(f"\n📁 Total Python files: {file_count}")
|
|
233
|
+
print(f"📝 Total lines of Python code: {total_lines:,}")
|
|
234
|
+
|
|
235
|
+
# Create visualizations with Plotly
|
|
236
|
+
# Only visualize top files (too many files make the chart unreadable)
|
|
237
|
+
top_n: int = min(20, len(df))
|
|
238
|
+
top_files_df = df.head(top_n).clone()
|
|
239
|
+
|
|
240
|
+
# Calculate percentage of total for top files
|
|
241
|
+
top_files_df = top_files_df.with_columns((pl.col("lines") / total_lines * 100).round(1).alias("percentage"))
|
|
242
|
+
|
|
243
|
+
# Shorten filenames for better display
|
|
244
|
+
import os
|
|
245
|
+
|
|
246
|
+
top_files_df = top_files_df.with_columns(pl.col("filename").map_elements(lambda x: os.path.basename(x) if len(x) > 25 else x, return_dtype=pl.Utf8).alias("short_name"))
|
|
247
|
+
|
|
248
|
+
# Create bar chart with hover info showing full path
|
|
249
|
+
fig = go.Figure()
|
|
250
|
+
|
|
251
|
+
# Add bars with gradient color based on line count
|
|
252
|
+
fig.add_trace(
|
|
253
|
+
go.Bar(
|
|
254
|
+
x=top_files_df["short_name"].to_list(),
|
|
255
|
+
y=top_files_df["lines"].to_list(),
|
|
256
|
+
text=[f"{x}%" for x in top_files_df["percentage"].to_list()],
|
|
257
|
+
textposition="auto",
|
|
258
|
+
hovertemplate="<b>%{customdata}</b><br>Lines: %{y:,}<br>Percentage: %{text}<extra></extra>",
|
|
259
|
+
customdata=top_files_df["filename"],
|
|
260
|
+
marker={"color": top_files_df["lines"], "colorscale": "Viridis", "showscale": True, "colorbar": {"title": "Lines", "thickness": 20, "tickformat": ","}, "line": {"width": 1, "color": "white"}},
|
|
261
|
+
opacity=0.9,
|
|
262
|
+
)
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
# Update layout with dark theme
|
|
266
|
+
fig.update_layout(
|
|
267
|
+
title={"text": f"🏆 Top {top_n} Python Files by Size", "y": 0.95, "x": 0.5, "xanchor": "center", "yanchor": "top", "font": {"size": 24, "color": "white"}},
|
|
268
|
+
xaxis_title="File Name 📄",
|
|
269
|
+
yaxis_title="Lines of Code 📝",
|
|
270
|
+
template="plotly_dark",
|
|
271
|
+
plot_bgcolor="rgba(25, 25, 35, 1)",
|
|
272
|
+
paper_bgcolor="rgba(15, 15, 25, 1)",
|
|
273
|
+
font={"family": "Arial, sans-serif", "size": 14, "color": "white"},
|
|
274
|
+
height=700,
|
|
275
|
+
margin={"l": 80, "r": 80, "t": 100, "b": 100},
|
|
276
|
+
xaxis={"tickangle": 45, "showgrid": False, "showline": True, "linecolor": "rgba(200, 200, 255, 0.2)", "tickfont": {"size": 12}},
|
|
277
|
+
yaxis={"showgrid": True, "gridcolor": "rgba(80, 80, 100, 0.2)", "showline": True, "linecolor": "rgba(200, 200, 255, 0.2)", "tickformat": ",", "tickfont": {"size": 12}},
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
# Define pie chart figure before conditionally using it
|
|
281
|
+
fig2: "Optional[go.Figure]" = None
|
|
282
|
+
|
|
283
|
+
# Add pie chart showing distribution
|
|
284
|
+
if len(df) > top_n:
|
|
285
|
+
# Prepare data for pie chart - top files plus "Others"
|
|
286
|
+
others_lines = df.slice(top_n)["lines"].sum()
|
|
287
|
+
pie_labels = list(top_files_df["short_name"]) + ["Others"]
|
|
288
|
+
pie_values = list(top_files_df["lines"]) + [others_lines]
|
|
289
|
+
pie_customdata = list(top_files_df["filename"]) + [f"Other {len(df) - top_n} files"]
|
|
290
|
+
|
|
291
|
+
fig2 = go.Figure()
|
|
292
|
+
fig2.add_trace(go.Pie(labels=pie_labels, values=pie_values, customdata=pie_customdata, textinfo="percent", hovertemplate="<b>%{customdata}</b><br>Lines: %{value:,}<br>Percentage: %{percent}<extra></extra>", marker={"colors": px.colors.sequential.Viridis, "line": {"color": "white", "width": 1}}, hole=0.4, sort=False))
|
|
293
|
+
|
|
294
|
+
fig2.update_layout(
|
|
295
|
+
title={"text": "🍩 Python Code Distribution by File", "y": 0.95, "x": 0.5, "xanchor": "center", "yanchor": "top", "font": {"size": 24, "color": "white"}},
|
|
296
|
+
template="plotly_dark",
|
|
297
|
+
plot_bgcolor="rgba(25, 25, 35, 1)",
|
|
298
|
+
paper_bgcolor="rgba(15, 15, 25, 1)",
|
|
299
|
+
font={"family": "Arial, sans-serif", "size": 14, "color": "white"},
|
|
300
|
+
height=700,
|
|
301
|
+
annotations=[{"text": f"Total<br>{total_lines:,}<br>lines", "x": 0.5, "y": 0.5, "font": {"size": 18, "color": "white"}, "showarrow": False}],
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
# Save visualizations
|
|
305
|
+
plot_dir = Path.home().joinpath("tmp_results", "tmp_images", Path(repo_path).name)
|
|
306
|
+
plot_dir.mkdir(parents=True, exist_ok=True)
|
|
307
|
+
|
|
308
|
+
# Bar chart
|
|
309
|
+
bar_html_path = plot_dir.joinpath("top_files_by_size.html")
|
|
310
|
+
bar_png_path = plot_dir.joinpath("top_files_by_size.png")
|
|
311
|
+
fig.write_html(bar_html_path, include_plotlyjs="cdn")
|
|
312
|
+
fig.write_image(bar_png_path, width=1200, height=700, scale=2)
|
|
313
|
+
|
|
314
|
+
print(f"\n🖼️ Interactive bar chart saved as {bar_html_path}")
|
|
315
|
+
print(f"🖼️ Static bar chart saved as {bar_png_path}")
|
|
316
|
+
|
|
317
|
+
# Pie chart if available
|
|
318
|
+
if fig2 is not None:
|
|
319
|
+
pie_html_path = plot_dir.joinpath("files_distribution_pie.html")
|
|
320
|
+
pie_png_path = plot_dir.joinpath("files_distribution_pie.png")
|
|
321
|
+
fig2.write_html(pie_html_path, include_plotlyjs="cdn")
|
|
322
|
+
fig2.write_image(pie_png_path, width=1200, height=700, scale=2)
|
|
323
|
+
|
|
324
|
+
print(f"🖼️ Interactive pie chart saved as {pie_html_path}")
|
|
325
|
+
print(f"🖼️ Static pie chart saved as {pie_png_path}")
|
|
326
|
+
|
|
327
|
+
return df
|
|
328
|
+
|
|
329
|
+
except Exception as e:
|
|
330
|
+
return Exception(f"❌ Error analyzing repository: {str(e)}")
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
@app.command()
|
|
334
|
+
def print_python_files_by_size(repo_path: str = typer.Argument(..., help="Path to the git repository")):
|
|
335
|
+
"""Print Python files sorted by size with visualizations."""
|
|
336
|
+
result = _print_python_files_by_size_impl(repo_path)
|
|
337
|
+
if isinstance(result, Exception):
|
|
338
|
+
print(f"Error: {result}")
|
|
339
|
+
return
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
if __name__ == "__main__":
|
|
343
|
+
app()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import typer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def analyze_repo_development(repo_path: str = typer.Argument(..., help="Path to the git repository")):
|
|
6
|
+
cmd = f"""uv run --python 3.13 --with machineconfig machineconfig.scripts.python.count_lines analyze-over-time {repo_path}"""
|
|
7
|
+
from machineconfig.utils.code import run_script
|
|
8
|
+
run_script(cmd)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if __name__ == "__main__":
|
|
12
|
+
pass
|
|
@@ -6,7 +6,7 @@ croshell
|
|
|
6
6
|
|
|
7
7
|
from typing import Annotated, Optional
|
|
8
8
|
import typer
|
|
9
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
9
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
10
10
|
from machineconfig.utils.accessories import randstr
|
|
11
11
|
|
|
12
12
|
from machineconfig.utils.options import choose_from_options
|
|
@@ -4,9 +4,11 @@ import machineconfig.utils.installer_utils.installer as installer_entry_point
|
|
|
4
4
|
import machineconfig.scripts.python.share_terminal as share_terminal
|
|
5
5
|
import machineconfig.scripts.python.repos as repos
|
|
6
6
|
|
|
7
|
+
from machineconfig import __version__
|
|
7
8
|
import typer
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
app = typer.Typer(help=f"🛠️ DevOps operations @ machineconfig {__version__}", no_args_is_help=True)
|
|
10
12
|
|
|
11
13
|
app.command(name="install", help="📦 Install essential packages")(installer_entry_point.main)
|
|
12
14
|
app.command(name="share-terminal", help="📡 Share terminal via web browser")(share_terminal.main)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""ID"""
|
|
2
2
|
|
|
3
3
|
# from platform import system
|
|
4
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
4
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
5
5
|
from machineconfig.utils.options import choose_from_options
|
|
6
6
|
from rich.panel import Panel
|
|
7
7
|
from rich.text import Text
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from platform import system
|
|
4
4
|
from machineconfig.utils.source_of_truth import LIBRARY_ROOT
|
|
5
5
|
from machineconfig.utils.options import choose_from_options
|
|
6
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
6
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
7
7
|
from rich.console import Console
|
|
8
8
|
from rich.panel import Panel
|
|
9
9
|
from rich import box # Import box
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# import subprocess
|
|
4
4
|
from machineconfig.utils.io import read_ini
|
|
5
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
5
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
6
6
|
from machineconfig.utils.source_of_truth import LIBRARY_ROOT, DEFAULTS_PATH
|
|
7
7
|
from machineconfig.utils.code import print_code
|
|
8
8
|
from machineconfig.utils.options import choose_cloud_interactively, choose_from_options
|