From 8bcd59732179e920733dee79fc917aa513f6a37c Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期四, 17 九月 2026 16:42:07 +0800
Subject: [PATCH] chore(git): 根目录临时文件归档至 _tmp/ 并加固 .gitignore(防真实数据误提交),工作日结补记
---
docs/投资/工具/隐藏项探测.py | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 162 insertions(+), 0 deletions(-)
diff --git "a/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\351\232\220\350\227\217\351\241\271\346\216\242\346\265\213.py" "b/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\351\232\220\350\227\217\351\241\271\346\216\242\346\265\213.py"
new file mode 100644
index 0000000..ef011c8
--- /dev/null
+++ "b/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\351\232\220\350\227\217\351\241\271\346\216\242\346\265\213.py"
@@ -0,0 +1,162 @@
+# -*- coding: utf-8 -*-
+"""闅愯棌椤规帰娴�.py 鈥斺�� 鎶曡祫鏈堟姤婧愭枃浠躲�岄殣钘忓伐浣滆〃 / 闅愯棌琛� / 闅愯棌鍒椼�嶅彧璇绘帰娴�
+
+鐢ㄦ硶锛�
+ python docs\鎶曡祫\宸ュ叿\闅愯棌椤规帰娴�.py --month 2026-07
+杈撳嚭锛�
+ <out>\闅愯棌椤规帰娴媉<YYYY-MM>.md
+ <out>\闅愯棌椤规帰娴媉<YYYY-MM>.txt
+鍘熷垯锛氬彧璇伙紝涓嶄慨鏀逛换浣曟簮鏂囦欢锛涗笉鍒ゅ畾涓氬姟鍙e緞銆�
+"""
+import sys, os, io, argparse, datetime as _dt, glob
+
+_here = os.path.dirname(os.path.abspath(__file__))
+_root = os.path.abspath(os.path.join(_here, '..', '..', '..'))
+for _base in (_here, _root, os.getcwd()):
+ for _sub in ('_pylibs',):
+ _lib = os.path.abspath(os.path.join(_base, _sub))
+ if os.path.isdir(_lib) and _lib not in sys.path:
+ sys.path.insert(0, _lib)
+
+try:
+ import xlrd
+except ImportError:
+ xlrd = None
+try:
+ import openpyxl
+except ImportError:
+ openpyxl = None
+
+VIS = {0: '鍙', 1: '闅愯棌', 2: '娣卞害闅愯棌'}
+
+
+def rngs(rows):
+ rows = sorted(rows)
+ out = []
+ for r in rows:
+ if out and r == out[-1][1] + 1:
+ out[-1][1] = r
+ else:
+ out.append([r, r])
+ return ['R%d' % a if a == b else 'R%d-R%d' % (a, b) for a, b in out]
+
+
+def cell(v):
+ s = str(v).strip() if v is not None else ''
+ s = s.replace('\n', ' ').replace('|', '/')
+ return s[:24]
+
+
+def scan_xls(path):
+ bk = xlrd.open_workbook(path, formatting_info=True) # 鍙湁 True 鎵嶆湁 rowinfo_map/colinfo_map锛堥殣钘忚/鍒楋級
+ res = []
+ for sh in bk.sheets():
+ hid = sh.rowinfo_map and [r + 1 for r, ri in sh.rowinfo_map.items() if ri.hidden] or []
+ res.append({
+ 'name': sh.name, 'vis': VIS.get(sh.visibility, str(sh.visibility)),
+ 'nrows': sh.nrows, 'ncols': sh.ncols,
+ 'hidden_rows': sorted(hid),
+ 'head': [[cell(sh.cell_value(r, c)) for c in range(min(sh.ncols, 8))] for r in range(min(sh.nrows, 6))],
+ 'hidden_head': [[r + 1] + [cell(sh.cell_value(r, c)) for c in range(min(sh.ncols, 8))]
+ for r in hid[:6]],
+ 'hidden_tail': [[r + 1] + [cell(sh.cell_value(r, c)) for c in range(min(sh.ncols, 8))]
+ for r in hid[-2:]],
+ })
+ bk.release_resources()
+ return res
+
+
+def scan_xlsx(path):
+ wb = openpyxl.load_workbook(path, data_only=True)
+ res = []
+ for ws in wb.worksheets:
+ hid = [r for r, d in ws.row_dimensions.items() if d.hidden]
+ hidden_cols = [c for c, d in ws.column_dimensions.items() if d.hidden]
+ state = ws.sheet_state
+ vis = {'visible': '鍙', 'hidden': '闅愯棌', 'veryHidden': '娣卞害闅愯棌'}.get(state, state)
+ head = []
+ for r in range(1, min(ws.max_row, 6) + 1):
+ head.append([cell(ws.cell(r, c).value) for c in range(1, min(ws.max_column, 8) + 1)])
+ hh = []
+ for r in sorted(hid)[:6]:
+ hh.append([r] + [cell(ws.cell(r, c).value) for c in range(1, min(ws.max_column, 8) + 1)])
+ res.append({'name': ws.title, 'vis': vis, 'nrows': ws.max_row, 'ncols': ws.max_column,
+ 'hidden_rows': sorted(hid), 'hidden_cols': hidden_cols,
+ 'head': head, 'hidden_head': hh})
+ wb.close()
+ return res
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('--month', default='2026-07')
+ ap.add_argument('--inroot', default=None)
+ a = ap.parse_args()
+ root = a.inroot or os.path.join(_root, 'docs', '鎶曡祫', '杈撳叆')
+ ym = a.month.replace('-', '')
+ mm = a.month.split('-')[1].lstrip('0')
+ outdir = os.path.join(_root, 'docs', '鎶曡祫', '杈撳嚭')
+ os.makedirs(outdir, exist_ok=True)
+
+ L = []
+ L.append('# 闅愯棌椤规帰娴嬶紙鍙锛� 鈥� %s' % a.month)
+ L.append('')
+ L.append('鐢熸垚鏃堕棿锛�%s' % _dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
+ L.append('璇存槑锛氬彧璇绘壂鎻忥紝涓嶆敼浠讳綍婧愭枃浠躲�傘�岄殣钘忋��= Excel 閲岄粯璁ょ湅涓嶅埌锛屼絾绋嬪簭璇诲崟鍏冩牸鑳借鍒般��')
+ L.append('')
+
+ targets = [('瀹㈣繍锛堝杩愮珯锛�', os.path.join(root, '瀹㈣繍锛堝杩愮珯锛�', '%s鏈�' % mm)),
+ ('鐗╂祦锛堢墿娴佸洯鍖猴級', os.path.join(root, '鐗╂祦锛堢墿娴佸洯鍖猴級', '%s鏈�' % mm))]
+
+ for body, d in targets:
+ L.append('## %s 锛堢洰褰曪細%s锛�' % (body, d))
+ L.append('')
+ if not os.path.isdir(d):
+ L.append('鐩綍涓嶅瓨鍦ㄣ��')
+ L.append('')
+ continue
+ files = sorted([f for f in os.listdir(d) if not f.startswith('~$')])
+ for fn in files:
+ fp = os.path.join(d, fn)
+ ext = os.path.splitext(fn)[1].lower()
+ L.append('### %s' % fn)
+ L.append('')
+ try:
+ # 娉ㄦ剰锛�.et锛圵PS锛夊疄涓� OLE2/BIFF8 澶嶅悎鏂囨。锛寈lrd 鍙互鐩存帴璇伙紱鍙湁 .xlsx 璧� openpyxl
+ info = scan_xlsx(fp) if ext == '.xlsx' else scan_xls(fp)
+ except Exception as e:
+ L.append('- 璇诲彇澶辫触锛�%s' % e)
+ L.append('')
+ continue
+ alln = len(info)
+ vis = [s for s in info if s['vis'] == '鍙']
+ hid = [s for s in info if s['vis'] != '鍙']
+ L.append('- 宸ヤ綔琛ㄦ�绘暟 %d 锛氬彲瑙� %d锛岄殣钘� %d' % (alln, len(vis), len(hid)))
+ if hid:
+ L.append('- 闅愯棌宸ヤ綔琛細%s' % '銆�'.join('%s(%s)' % (s['name'], s['vis']) for s in hid[:8])
+ + (' 鈥﹀叡%d寮�' % len(hid) if len(hid) > 8 else ''))
+ for s in info:
+ tag = [] if s['vis'] == '鍙' else ['锛�%s锛�' % s['vis']]
+ L.append(' - 琛� `%s`%s 灏哄 %d琛屆�%d鍒�' % (s['name'], ''.join(tag), s['nrows'], s['ncols']))
+ hr = s['hidden_rows']
+ if hr:
+ L.append(' - **闅愯棌琛� %d 琛岋細%s**' % (len(hr), '銆�'.join(rngs(hr))))
+ for row in s['hidden_head']:
+ L.append(' - %s' % ' | '.join(['R%d' % row[0]] + row[1:]))
+ if len(hr) > 6 and s.get('hidden_tail'):
+ for row in s['hidden_tail']:
+ L.append(' - %s' % ' | '.join(['R%d' % row[0]] + row[1:]))
+ if s.get('hidden_cols'):
+ L.append(' - 闅愯棌鍒楋細%s' % '銆�'.join(s['hidden_cols']))
+ L.append('')
+
+ txt = '\n'.join(L)
+ p_md = os.path.join(outdir, '闅愯棌椤规帰娴媉%s.md' % a.month)
+ p_txt = os.path.join(outdir, '闅愯棌椤规帰娴媉%s.txt' % a.month)
+ io.open(p_md, 'w', encoding='utf-8').write(txt + '\n')
+ io.open(p_txt, 'w', encoding='utf-8').write(txt + '\n')
+ print('OK -> %s' % p_md)
+
+
+if __name__ == '__main__':
+ main()
--
Gitblit v1.9.1