gomyck-tools 1.4.9__py3-none-any.whl → 1.5.1__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.
ctools/util/jb_cut.py CHANGED
@@ -4,6 +4,7 @@ __author__ = 'haoyang'
4
4
  __date__ = '2025/7/15 13:08'
5
5
 
6
6
  import sys
7
+ from collections import Counter
7
8
 
8
9
  import jieba
9
10
  from jieba import posseg as pseg
@@ -49,6 +50,9 @@ def get_declare_type_word(word: str, word_flag=(), use_paddle=False, exclude_fla
49
50
  # if platform.system() == 'Linux': jieba.enable_parallel(4)
50
51
  ret = []
51
52
  for w, flag in pseg.cut(word, use_paddle=use_paddle):
52
- if (flag in word_flag or len(word_flag) == 0) and flag not in exclude_flag and w not in exclude_word:
53
+ if (not word_flag or flag in word_flag) and flag not in exclude_flag and w not in exclude_word:
53
54
  ret.append((w, flag))
54
- return ret
55
+ # 按 (w, flag) 统计出现次数
56
+ counter = Counter(ret)
57
+ # 输出结果 [(w, flag, count), ...]
58
+ return [(w, flag, cnt) for (w, flag), cnt in counter.items()]
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import sys
3
3
  from socketserver import ThreadingMixIn
4
+ from urllib.parse import urljoin
4
5
  from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, make_server
5
6
 
6
7
  from bottle import ServerAdapter, Bottle, template, static_file, abort, redirect, response, request
@@ -129,6 +130,12 @@ class CBottle:
129
130
  if request.path.startswith('/api/'): return R.error(resp=R.Code.cus_code(404, "资源未找到: {}".format(error.body)))
130
131
  return static_file(filename=self.index_filename, root=self.index_root)
131
132
 
133
+ @self.bottle.error(401)
134
+ def unauthorized(error):
135
+ response.status=301
136
+ response.set_header('Location', urljoin(request.url, '/'))
137
+ return response
138
+
132
139
  def set_index(self, filename='index.html', root='./', is_tpl=False, redirect_url=None, spa=False, **kwargs):
133
140
  self.index_root = root
134
141
  self.index_filename = filename
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gomyck-tools
3
- Version: 1.4.9
3
+ Version: 1.5.1
4
4
  Summary: A tools collection for python development by hao474798383
5
5
  Author-email: gomyck <hao474798383@163.com>
6
6
  License-Expression: Apache-2.0
@@ -69,20 +69,20 @@ ctools/util/env_config.py,sha256=L98G9LPdpD7Yl5XbA_-KfkcA4mDunQoKiYtK5w7QR-s,179
69
69
  ctools/util/html_soup.py,sha256=rnr8M3gn3gQGo-wNaNFXDjdzp8AAkv9o4yqfIIfO-zw,1567
70
70
  ctools/util/http_util.py,sha256=cx0FRnPLFdJ0mF9UYphl40SZj68fqG30Q0udku9hZIE,769
71
71
  ctools/util/image_process.py,sha256=nqJOi2p8wLe8wRsfkH99MyEYSjE9i4fthxBJwrrZVB8,835
72
- ctools/util/jb_cut.py,sha256=h8Ey-LbpHtbAHskITn5GXEO7-DHJ_ZLODmE8Lc_dgSc,1664
72
+ ctools/util/jb_cut.py,sha256=2vs054_lM-0sxh70cUv7nHhLkWW1ioM3MQ5LF25sBl8,1844
73
73
  ctools/util/snow_id.py,sha256=KCuQ0zOTlmus8gZetmRA5y0jBSd8J0KXcJ33EzgCKjE,2225
74
74
  ctools/web/__init__.py,sha256=koSNYeKF5Z_xbp4Q2qbZ4ZP-3--1phbOYN9e4SJy_gk,98
75
75
  ctools/web/aio_web_server.py,sha256=p46BOU3_m4Jb57yAACeedKjhlFc1YC0QJSUe2selBgA,5693
76
76
  ctools/web/api_result.py,sha256=i1MjTnnlgkWl_q07xr-TLQeLYlXEh4DEclUFE414nSk,1568
77
77
  ctools/web/bottle_web_base.py,sha256=iQZJtRQH3HJ-P-48Gspvp1VEd6boAlZfiat3H8E5bBU,8763
78
- ctools/web/bottle_webserver.py,sha256=0xHLnuGIShxrEHc2mLnyx43NDVkCqM5QnlkY-Ndzrk4,6650
78
+ ctools/web/bottle_webserver.py,sha256=Gke_rjRrnUAl0rVe8rkTaq7SPrxb0cHKV_Ln6l7fqus,6854
79
79
  ctools/web/bottle_websocket.py,sha256=xsu9fAtTuR5DsSsQjiBfaYxLjOWFyfr1sYM6cktTovI,1957
80
80
  ctools/web/ctoken.py,sha256=WaB29kqGlKAh21aUw5avl2h8AgLD1aESw8KCpqaN5nM,2539
81
81
  ctools/web/download_util.py,sha256=v0JTXiED1bvoWFfwfd-LD5s7_aoRQ0lCkaGwSnSp7WI,1954
82
82
  ctools/web/params_util.py,sha256=eJDV3PSq-ZHb8UZf6xqs8kOhbyZzits1H9yPoUBIDXg,828
83
83
  ctools/web/upload_util.py,sha256=z1QQCi4SFx08jrAQH5-Y_ShiM4MghuD_5Qz6V9KK_4U,1076
84
- gomyck_tools-1.4.9.dist-info/licenses/LICENSE,sha256=X25ypfH9E6VTht2hcO8k7LCSdHUcoG_ALQt80jdYZfY,547
85
- gomyck_tools-1.4.9.dist-info/METADATA,sha256=iDKzJsPkM5FfvkJthHZDH-Q3Q41p8z5RbsJktW9n4pc,1826
86
- gomyck_tools-1.4.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
87
- gomyck_tools-1.4.9.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
88
- gomyck_tools-1.4.9.dist-info/RECORD,,
84
+ gomyck_tools-1.5.1.dist-info/licenses/LICENSE,sha256=X25ypfH9E6VTht2hcO8k7LCSdHUcoG_ALQt80jdYZfY,547
85
+ gomyck_tools-1.5.1.dist-info/METADATA,sha256=pblfOhcxA0hRXLOhZAJczlFu3Y9gfwaifo08RyxJJiA,1826
86
+ gomyck_tools-1.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
87
+ gomyck_tools-1.5.1.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
88
+ gomyck_tools-1.5.1.dist-info/RECORD,,