re-common 10.0.22__py3-none-any.whl → 10.0.24__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.
- re_common/baselibrary/__init__.py +4 -4
- re_common/baselibrary/baseabs/__init__.py +6 -6
- re_common/baselibrary/baseabs/baseabs.py +26 -26
- re_common/baselibrary/database/mbuilder.py +132 -132
- re_common/baselibrary/database/moudle.py +93 -93
- re_common/baselibrary/database/msqlite3.py +194 -194
- re_common/baselibrary/database/mysql.py +169 -169
- re_common/baselibrary/database/sql_factory.py +26 -26
- re_common/baselibrary/mthread/MThreadingRun.py +486 -486
- re_common/baselibrary/mthread/MThreadingRunEvent.py +349 -349
- re_common/baselibrary/mthread/__init__.py +2 -2
- re_common/baselibrary/mthread/mythreading.py +695 -695
- re_common/baselibrary/pakge_other/socks.py +404 -404
- re_common/baselibrary/readconfig/config_factory.py +18 -18
- re_common/baselibrary/readconfig/ini_config.py +317 -317
- re_common/baselibrary/readconfig/toml_config.py +49 -49
- re_common/baselibrary/temporary/envdata.py +36 -36
- re_common/baselibrary/tools/all_requests/aiohttp_request.py +118 -118
- re_common/baselibrary/tools/all_requests/httpx_requet.py +102 -102
- re_common/baselibrary/tools/all_requests/mrequest.py +412 -412
- re_common/baselibrary/tools/all_requests/requests_request.py +81 -81
- re_common/baselibrary/tools/batch_compre/bijiao_batch.py +31 -31
- re_common/baselibrary/tools/contrast_db3.py +123 -123
- re_common/baselibrary/tools/copy_file.py +39 -39
- re_common/baselibrary/tools/db3_2_sizedb3.py +102 -102
- re_common/baselibrary/tools/foreachgz.py +39 -39
- re_common/baselibrary/tools/get_attr.py +10 -10
- re_common/baselibrary/tools/image_to_pdf.py +61 -61
- re_common/baselibrary/tools/java_code_deal.py +139 -139
- re_common/baselibrary/tools/javacode.py +79 -79
- re_common/baselibrary/tools/mdb_db3.py +48 -48
- re_common/baselibrary/tools/merge_file.py +171 -171
- re_common/baselibrary/tools/merge_gz_file.py +165 -165
- re_common/baselibrary/tools/mhdfstools/down_hdfs_files.py +42 -42
- re_common/baselibrary/tools/mhdfstools/hdfst.py +42 -42
- re_common/baselibrary/tools/mhdfstools/up_hdfs_files.py +38 -38
- re_common/baselibrary/tools/mongo_tools.py +50 -50
- re_common/baselibrary/tools/move_file.py +170 -170
- re_common/baselibrary/tools/move_mongo/mongo_table_to_file.py +63 -63
- re_common/baselibrary/tools/move_mongo/move_mongo_table.py +354 -354
- re_common/baselibrary/tools/move_mongo/use_mttf.py +18 -18
- re_common/baselibrary/tools/move_mongo/use_mv.py +93 -93
- re_common/baselibrary/tools/mpandas/mpandasreadexcel.py +125 -125
- re_common/baselibrary/tools/mpandas/pandas_visualization.py +7 -7
- re_common/baselibrary/tools/myparsel.py +104 -104
- re_common/baselibrary/tools/rename_dir_file.py +37 -37
- re_common/baselibrary/tools/sequoiadb_utils.py +398 -398
- re_common/baselibrary/tools/split_line_to_many.py +25 -25
- re_common/baselibrary/tools/stringtodicts.py +33 -33
- re_common/baselibrary/tools/workwechant_bot.py +84 -84
- re_common/baselibrary/utils/baseaiohttp.py +296 -296
- re_common/baselibrary/utils/baseaiomysql.py +87 -87
- re_common/baselibrary/utils/baseallstep.py +191 -191
- re_common/baselibrary/utils/baseavro.py +19 -19
- re_common/baselibrary/utils/baseboto3.py +291 -291
- re_common/baselibrary/utils/basecsv.py +32 -32
- re_common/baselibrary/utils/basedict.py +133 -133
- re_common/baselibrary/utils/basedir.py +241 -241
- re_common/baselibrary/utils/baseencode.py +351 -351
- re_common/baselibrary/utils/baseencoding.py +28 -28
- re_common/baselibrary/utils/baseesdsl.py +86 -86
- re_common/baselibrary/utils/baseexcel.py +264 -264
- re_common/baselibrary/utils/baseexcept.py +109 -109
- re_common/baselibrary/utils/basefile.py +654 -654
- re_common/baselibrary/utils/baseftp.py +214 -214
- re_common/baselibrary/utils/basegzip.py +60 -60
- re_common/baselibrary/utils/basehdfs.py +135 -135
- re_common/baselibrary/utils/basehttpx.py +268 -268
- re_common/baselibrary/utils/baseip.py +87 -87
- re_common/baselibrary/utils/basejson.py +2 -2
- re_common/baselibrary/utils/baselist.py +32 -32
- re_common/baselibrary/utils/basemotor.py +190 -190
- re_common/baselibrary/utils/basemssql.py +98 -98
- re_common/baselibrary/utils/baseodbc.py +113 -113
- re_common/baselibrary/utils/basepandas.py +302 -302
- re_common/baselibrary/utils/basepeewee.py +11 -11
- re_common/baselibrary/utils/basepika.py +180 -180
- re_common/baselibrary/utils/basepydash.py +143 -143
- re_common/baselibrary/utils/basepymongo.py +230 -230
- re_common/baselibrary/utils/basequeue.py +22 -22
- re_common/baselibrary/utils/baserar.py +57 -57
- re_common/baselibrary/utils/baserequest.py +279 -279
- re_common/baselibrary/utils/baseset.py +8 -8
- re_common/baselibrary/utils/basesmb.py +403 -403
- re_common/baselibrary/utils/basestring.py +382 -382
- re_common/baselibrary/utils/basetime.py +320 -320
- re_common/baselibrary/utils/baseurl.py +121 -121
- re_common/baselibrary/utils/basezip.py +57 -57
- re_common/baselibrary/utils/core/__init__.py +7 -7
- re_common/baselibrary/utils/core/bottomutils.py +18 -18
- re_common/baselibrary/utils/core/mdeprecated.py +327 -327
- re_common/baselibrary/utils/core/mlamada.py +16 -16
- re_common/baselibrary/utils/core/msginfo.py +25 -25
- re_common/baselibrary/utils/core/requests_core.py +103 -103
- re_common/baselibrary/utils/fateadm.py +429 -429
- re_common/baselibrary/utils/importfun.py +123 -123
- re_common/baselibrary/utils/mfaker.py +57 -57
- re_common/baselibrary/utils/my_abc/__init__.py +3 -3
- re_common/baselibrary/utils/my_abc/better_abc.py +32 -32
- re_common/baselibrary/utils/mylogger.py +414 -414
- re_common/baselibrary/utils/myredisclient.py +861 -861
- re_common/baselibrary/utils/pipupgrade.py +21 -21
- re_common/baselibrary/utils/ringlist.py +85 -85
- re_common/baselibrary/utils/version_compare.py +36 -36
- re_common/baselibrary/utils/ydmhttp.py +126 -126
- re_common/facade/lazy_import.py +11 -11
- re_common/facade/loggerfacade.py +25 -25
- re_common/facade/mysqlfacade.py +467 -467
- re_common/facade/now.py +31 -31
- re_common/facade/sqlite3facade.py +257 -257
- re_common/facade/use/mq_use_facade.py +83 -83
- re_common/facade/use/proxy_use_facade.py +19 -19
- re_common/libtest/base_dict_test.py +19 -19
- re_common/libtest/baseavro_test.py +13 -13
- re_common/libtest/basefile_test.py +14 -14
- re_common/libtest/basemssql_test.py +77 -77
- re_common/libtest/baseodbc_test.py +7 -7
- re_common/libtest/basepandas_test.py +38 -38
- re_common/libtest/get_attr_test/get_attr_test_settings.py +14 -14
- re_common/libtest/get_attr_test/settings.py +54 -54
- re_common/libtest/idencode_test.py +53 -53
- re_common/libtest/iniconfig_test.py +35 -35
- re_common/libtest/ip_test.py +34 -34
- re_common/libtest/merge_file_test.py +20 -20
- re_common/libtest/mfaker_test.py +8 -8
- re_common/libtest/mm3_test.py +31 -31
- re_common/libtest/mylogger_test.py +88 -88
- re_common/libtest/myparsel_test.py +27 -27
- re_common/libtest/mysql_test.py +151 -151
- re_common/libtest/pymongo_test.py +21 -21
- re_common/libtest/split_test.py +11 -11
- re_common/libtest/sqlite3_merge_test.py +5 -5
- re_common/libtest/sqlite3_test.py +34 -34
- re_common/libtest/tomlconfig_test.py +30 -30
- re_common/libtest/use_tools_test/__init__.py +2 -2
- re_common/libtest/user/__init__.py +4 -4
- re_common/studio/__init__.py +4 -4
- re_common/studio/assignment_expressions.py +36 -36
- re_common/studio/mydash/test1.py +18 -18
- re_common/studio/pydashstudio/first.py +9 -9
- re_common/studio/streamlitstudio/first_app.py +65 -65
- re_common/studio/streamlitstudio/uber_pickups.py +23 -23
- re_common/studio/test.py +18 -18
- re_common/v2/baselibrary/business_utils/BusinessStringUtil.py +195 -0
- re_common/v2/baselibrary/business_utils/__init__.py +0 -0
- re_common/v2/baselibrary/business_utils/rel_tools.py +6 -0
- re_common/v2/baselibrary/decorators/utils.py +59 -59
- re_common/v2/baselibrary/s3object/baseboto3.py +230 -230
- re_common/v2/baselibrary/tools/WeChatRobot.py +95 -79
- re_common/v2/baselibrary/tools/ac_ahocorasick.py +75 -75
- re_common/v2/baselibrary/tools/dict_tools.py +37 -37
- re_common/v2/baselibrary/tools/dolphinscheduler.py +187 -187
- re_common/v2/baselibrary/tools/hdfs_data_processer.py +338 -338
- re_common/v2/baselibrary/tools/list_tools.py +65 -65
- re_common/v2/baselibrary/tools/search_hash_tools.py +54 -54
- re_common/v2/baselibrary/tools/text_matcher.py +326 -326
- re_common/v2/baselibrary/tools/unionfind_tools.py +60 -60
- re_common/v2/baselibrary/utils/BusinessStringUtil.py +196 -196
- re_common/v2/baselibrary/utils/author_smi.py +360 -360
- re_common/v2/baselibrary/utils/base_string_similarity.py +158 -158
- re_common/v2/baselibrary/utils/basedict.py +37 -37
- re_common/v2/baselibrary/utils/basehdfs.py +161 -161
- re_common/v2/baselibrary/utils/basepika.py +180 -180
- re_common/v2/baselibrary/utils/basetime.py +77 -77
- re_common/v2/baselibrary/utils/db.py +38 -38
- re_common/v2/baselibrary/utils/json_cls.py +16 -16
- re_common/v2/baselibrary/utils/mq.py +83 -83
- re_common/v2/baselibrary/utils/n_ary_expression_tree.py +243 -243
- re_common/v2/baselibrary/utils/string_bool.py +186 -149
- re_common/v2/baselibrary/utils/string_clear.py +227 -204
- re_common/v2/baselibrary/utils/string_smi.py +18 -18
- re_common/v2/baselibrary/utils/stringutils.py +213 -213
- re_common/vip/base_step_process.py +11 -11
- re_common/vip/baseencodeid.py +90 -90
- re_common/vip/changetaskname.py +28 -28
- re_common/vip/core_var.py +24 -24
- re_common/vip/mmh3Hash.py +89 -89
- re_common/vip/proxy/allproxys.py +127 -127
- re_common/vip/proxy/allproxys_thread.py +159 -159
- re_common/vip/proxy/cnki_proxy.py +153 -153
- re_common/vip/proxy/kuaidaili.py +87 -87
- re_common/vip/proxy/proxy_all.py +113 -113
- re_common/vip/proxy/update_kuaidaili_0.py +42 -42
- re_common/vip/proxy/wanfang_proxy.py +152 -152
- re_common/vip/proxy/wp_proxy_all.py +181 -181
- re_common/vip/read_rawid_to_txt.py +91 -91
- re_common/vip/title/__init__.py +5 -5
- re_common/vip/title/transform/TransformBookTitleToZt.py +125 -125
- re_common/vip/title/transform/TransformConferenceTitleToZt.py +139 -139
- re_common/vip/title/transform/TransformCstadTitleToZt.py +195 -195
- re_common/vip/title/transform/TransformJournalTitleToZt.py +203 -203
- re_common/vip/title/transform/TransformPatentTitleToZt.py +132 -132
- re_common/vip/title/transform/TransformRegulationTitleToZt.py +114 -114
- re_common/vip/title/transform/TransformStandardTitleToZt.py +135 -135
- re_common/vip/title/transform/TransformThesisTitleToZt.py +135 -135
- re_common/vip/title/transform/__init__.py +10 -10
- {re_common-10.0.22.dist-info → re_common-10.0.24.dist-info}/LICENSE +201 -201
- {re_common-10.0.22.dist-info → re_common-10.0.24.dist-info}/METADATA +16 -16
- re_common-10.0.24.dist-info/RECORD +230 -0
- {re_common-10.0.22.dist-info → re_common-10.0.24.dist-info}/WHEEL +1 -1
- re_common-10.0.22.dist-info/RECORD +0 -227
- {re_common-10.0.22.dist-info → re_common-10.0.24.dist-info}/top_level.txt +0 -0
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"""
|
|
2
|
-
来自于 PEP572
|
|
3
|
-
|
|
4
|
-
在 python 3.8 中获取正式支持
|
|
5
|
-
|
|
6
|
-
https://docs.python.org/3/whatsnew/3.8.html
|
|
7
|
-
|
|
8
|
-
:= (由于它与海象的眼睛和象牙很像,因此被亲切地称为“海象操作员” )
|
|
9
|
-
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
# 在此示例中,赋值表达式有助于避免调用 len()两次:
|
|
13
|
-
import re
|
|
14
|
-
import string
|
|
15
|
-
|
|
16
|
-
a = "adahfhoifoigoiwfhoiwg"
|
|
17
|
-
if (n := len(a)) > 10:
|
|
18
|
-
print(f"List is too long ({n} elements, expected <= 10)")
|
|
19
|
-
|
|
20
|
-
# 在正则表达式匹配期间会产生类似的好处,其中需要两次匹配对象,一次是测试是否发生匹配,另一次是提取子组:
|
|
21
|
-
discount = 0.0
|
|
22
|
-
advertisement = "a 50% discount"
|
|
23
|
-
if mo := re.search(r'(\d+)% discount', advertisement):
|
|
24
|
-
discount = float(mo.group(1)) / 100.0
|
|
25
|
-
print(discount)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# 该运算符还对while循环有用,该循环计算一个值来测试循环终止,然后在循环主体中再次需要相同的值:
|
|
29
|
-
# Loop over fixed length blocks
|
|
30
|
-
f = open("./__init__.py", 'rb')
|
|
31
|
-
while len(block := f.read(256)) != 0:
|
|
32
|
-
print(len(block))
|
|
33
|
-
|
|
34
|
-
# 另一个具有启发性的用例出现在列表理解中,其中表达式主体中还需要在过滤条件下计算出的值:
|
|
35
|
-
allowed_names = list(string.ascii_letters)
|
|
36
|
-
names = list(string.ascii_letters)
|
|
1
|
+
"""
|
|
2
|
+
来自于 PEP572
|
|
3
|
+
|
|
4
|
+
在 python 3.8 中获取正式支持
|
|
5
|
+
|
|
6
|
+
https://docs.python.org/3/whatsnew/3.8.html
|
|
7
|
+
|
|
8
|
+
:= (由于它与海象的眼睛和象牙很像,因此被亲切地称为“海象操作员” )
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# 在此示例中,赋值表达式有助于避免调用 len()两次:
|
|
13
|
+
import re
|
|
14
|
+
import string
|
|
15
|
+
|
|
16
|
+
a = "adahfhoifoigoiwfhoiwg"
|
|
17
|
+
if (n := len(a)) > 10:
|
|
18
|
+
print(f"List is too long ({n} elements, expected <= 10)")
|
|
19
|
+
|
|
20
|
+
# 在正则表达式匹配期间会产生类似的好处,其中需要两次匹配对象,一次是测试是否发生匹配,另一次是提取子组:
|
|
21
|
+
discount = 0.0
|
|
22
|
+
advertisement = "a 50% discount"
|
|
23
|
+
if mo := re.search(r'(\d+)% discount', advertisement):
|
|
24
|
+
discount = float(mo.group(1)) / 100.0
|
|
25
|
+
print(discount)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# 该运算符还对while循环有用,该循环计算一个值来测试循环终止,然后在循环主体中再次需要相同的值:
|
|
29
|
+
# Loop over fixed length blocks
|
|
30
|
+
f = open("./__init__.py", 'rb')
|
|
31
|
+
while len(block := f.read(256)) != 0:
|
|
32
|
+
print(len(block))
|
|
33
|
+
|
|
34
|
+
# 另一个具有启发性的用例出现在列表理解中,其中表达式主体中还需要在过滤条件下计算出的值:
|
|
35
|
+
allowed_names = list(string.ascii_letters)
|
|
36
|
+
names = list(string.ascii_letters)
|
|
37
37
|
print([clean_name for name in names if (clean_name := name) in allowed_names])
|
re_common/studio/mydash/test1.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import dash
|
|
2
|
-
import dash_table
|
|
3
|
-
import pandas as pd
|
|
4
|
-
import dash_design_kit as ddk
|
|
5
|
-
|
|
6
|
-
df = pd.read_csv("test.csv")
|
|
7
|
-
app = dash.Dash(__name__)
|
|
8
|
-
|
|
9
|
-
app.layout = ddk.App(show_editor=True, children=[
|
|
10
|
-
ddk.DataTable(
|
|
11
|
-
id='table',
|
|
12
|
-
columns=[{"name": i, "id": i} for i in df.columns],
|
|
13
|
-
data=df.to_dict('records'),
|
|
14
|
-
editable=True
|
|
15
|
-
)
|
|
16
|
-
])
|
|
17
|
-
|
|
18
|
-
if __name__ == '__main__':
|
|
1
|
+
import dash
|
|
2
|
+
import dash_table
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import dash_design_kit as ddk
|
|
5
|
+
|
|
6
|
+
df = pd.read_csv("test.csv")
|
|
7
|
+
app = dash.Dash(__name__)
|
|
8
|
+
|
|
9
|
+
app.layout = ddk.App(show_editor=True, children=[
|
|
10
|
+
ddk.DataTable(
|
|
11
|
+
id='table',
|
|
12
|
+
columns=[{"name": i, "id": i} for i in df.columns],
|
|
13
|
+
data=df.to_dict('records'),
|
|
14
|
+
editable=True
|
|
15
|
+
)
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
if __name__ == '__main__':
|
|
19
19
|
app.run_server(debug=True)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import pydash
|
|
2
|
-
|
|
3
|
-
users = [
|
|
4
|
-
{'name': 'Michelangelo', 'active': False},
|
|
5
|
-
{'name': 'Donatello', 'active': False},
|
|
6
|
-
{'name': 'Leonardo', 'active': True}
|
|
7
|
-
]
|
|
8
|
-
callback = lambda item: item["name"] == "Donatello"
|
|
9
|
-
pydash.find_index(users, callback)
|
|
1
|
+
import pydash
|
|
2
|
+
|
|
3
|
+
users = [
|
|
4
|
+
{'name': 'Michelangelo', 'active': False},
|
|
5
|
+
{'name': 'Donatello', 'active': False},
|
|
6
|
+
{'name': 'Leonardo', 'active': True}
|
|
7
|
+
]
|
|
8
|
+
callback = lambda item: item["name"] == "Donatello"
|
|
9
|
+
pydash.find_index(users, callback)
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
import streamlit as st
|
|
4
|
-
# To make things easier later, we're also importing numpy and pandas for
|
|
5
|
-
# working with sample data.
|
|
6
|
-
import numpy as np
|
|
7
|
-
import pandas as pd
|
|
8
|
-
|
|
9
|
-
st.title('My first app')
|
|
10
|
-
st.write("Here's our first attempt at using data to create a table:")
|
|
11
|
-
st.write(pd.DataFrame({
|
|
12
|
-
'first column': [1, 2, 3, 4],
|
|
13
|
-
'second column': [10, 20, 30, 40]
|
|
14
|
-
}))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
chart_data = pd.DataFrame(
|
|
18
|
-
np.random.randn(20, 3),
|
|
19
|
-
columns=['a', 'b', 'c'])
|
|
20
|
-
|
|
21
|
-
st.line_chart(chart_data)
|
|
22
|
-
|
|
23
|
-
# map_data = pd.DataFrame(
|
|
24
|
-
# np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
|
25
|
-
# columns=['lat', 'lon'])
|
|
26
|
-
#
|
|
27
|
-
# st.map(map_data)
|
|
28
|
-
|
|
29
|
-
if st.checkbox('Show dataframe'):
|
|
30
|
-
chart_data = pd.DataFrame(
|
|
31
|
-
np.random.randn(20, 3),
|
|
32
|
-
columns=['a', 'b', 'c'])
|
|
33
|
-
chart_data
|
|
34
|
-
|
|
35
|
-
df = pd.DataFrame({
|
|
36
|
-
'first column': [1, 2, 3, 4],
|
|
37
|
-
'second column': [10, 20, 30, 40]
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
df
|
|
41
|
-
|
|
42
|
-
option = st.selectbox(
|
|
43
|
-
'Which number do you like best?',
|
|
44
|
-
df['first column'])
|
|
45
|
-
|
|
46
|
-
'You selected: ', option
|
|
47
|
-
|
|
48
|
-
option2 = st.sidebar.selectbox(
|
|
49
|
-
'Which number do you like best??',
|
|
50
|
-
df['first column'])
|
|
51
|
-
|
|
52
|
-
'You selected:', option2
|
|
53
|
-
|
|
54
|
-
'Starting a long computation...'
|
|
55
|
-
|
|
56
|
-
# Add a placeholder
|
|
57
|
-
latest_iteration = st.empty()
|
|
58
|
-
bar = st.progress(0)
|
|
59
|
-
|
|
60
|
-
for i in range(100):
|
|
61
|
-
# Update the progress bar with each iteration.
|
|
62
|
-
latest_iteration.text(f'Iteration {i+1}')
|
|
63
|
-
bar.progress(i + 1)
|
|
64
|
-
time.sleep(0.1)
|
|
65
|
-
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
import streamlit as st
|
|
4
|
+
# To make things easier later, we're also importing numpy and pandas for
|
|
5
|
+
# working with sample data.
|
|
6
|
+
import numpy as np
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
st.title('My first app')
|
|
10
|
+
st.write("Here's our first attempt at using data to create a table:")
|
|
11
|
+
st.write(pd.DataFrame({
|
|
12
|
+
'first column': [1, 2, 3, 4],
|
|
13
|
+
'second column': [10, 20, 30, 40]
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
chart_data = pd.DataFrame(
|
|
18
|
+
np.random.randn(20, 3),
|
|
19
|
+
columns=['a', 'b', 'c'])
|
|
20
|
+
|
|
21
|
+
st.line_chart(chart_data)
|
|
22
|
+
|
|
23
|
+
# map_data = pd.DataFrame(
|
|
24
|
+
# np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
|
25
|
+
# columns=['lat', 'lon'])
|
|
26
|
+
#
|
|
27
|
+
# st.map(map_data)
|
|
28
|
+
|
|
29
|
+
if st.checkbox('Show dataframe'):
|
|
30
|
+
chart_data = pd.DataFrame(
|
|
31
|
+
np.random.randn(20, 3),
|
|
32
|
+
columns=['a', 'b', 'c'])
|
|
33
|
+
chart_data
|
|
34
|
+
|
|
35
|
+
df = pd.DataFrame({
|
|
36
|
+
'first column': [1, 2, 3, 4],
|
|
37
|
+
'second column': [10, 20, 30, 40]
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
df
|
|
41
|
+
|
|
42
|
+
option = st.selectbox(
|
|
43
|
+
'Which number do you like best?',
|
|
44
|
+
df['first column'])
|
|
45
|
+
|
|
46
|
+
'You selected: ', option
|
|
47
|
+
|
|
48
|
+
option2 = st.sidebar.selectbox(
|
|
49
|
+
'Which number do you like best??',
|
|
50
|
+
df['first column'])
|
|
51
|
+
|
|
52
|
+
'You selected:', option2
|
|
53
|
+
|
|
54
|
+
'Starting a long computation...'
|
|
55
|
+
|
|
56
|
+
# Add a placeholder
|
|
57
|
+
latest_iteration = st.empty()
|
|
58
|
+
bar = st.progress(0)
|
|
59
|
+
|
|
60
|
+
for i in range(100):
|
|
61
|
+
# Update the progress bar with each iteration.
|
|
62
|
+
latest_iteration.text(f'Iteration {i+1}')
|
|
63
|
+
bar.progress(i + 1)
|
|
64
|
+
time.sleep(0.1)
|
|
65
|
+
|
|
66
66
|
'...and now we\'re done!'
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import streamlit as st
|
|
2
|
-
import pandas as pd
|
|
3
|
-
import numpy as np
|
|
4
|
-
|
|
5
|
-
st.title('Uber pickups in NYC')
|
|
6
|
-
|
|
7
|
-
DATE_COLUMN = 'date/time'
|
|
8
|
-
DATA_URL = ('https://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz')
|
|
9
|
-
|
|
10
|
-
@st.cache
|
|
11
|
-
def load_data(nrows):
|
|
12
|
-
data = pd.read_csv(DATA_URL, nrows=nrows)
|
|
13
|
-
lowercase = lambda x: str(x).lower()
|
|
14
|
-
data.rename(lowercase, axis='columns', inplace=True)
|
|
15
|
-
data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
|
|
16
|
-
return data
|
|
17
|
-
|
|
18
|
-
# Create a text element and let the reader know the data is loading.
|
|
19
|
-
data_load_state.text("Done! (using st.cache)")
|
|
20
|
-
|
|
21
|
-
# Load 10,000 rows of data into the dataframe.
|
|
22
|
-
data = load_data(10000)
|
|
23
|
-
# Notify the reader that the data was successfully loaded.
|
|
1
|
+
import streamlit as st
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
st.title('Uber pickups in NYC')
|
|
6
|
+
|
|
7
|
+
DATE_COLUMN = 'date/time'
|
|
8
|
+
DATA_URL = ('https://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz')
|
|
9
|
+
|
|
10
|
+
@st.cache
|
|
11
|
+
def load_data(nrows):
|
|
12
|
+
data = pd.read_csv(DATA_URL, nrows=nrows)
|
|
13
|
+
lowercase = lambda x: str(x).lower()
|
|
14
|
+
data.rename(lowercase, axis='columns', inplace=True)
|
|
15
|
+
data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
|
|
16
|
+
return data
|
|
17
|
+
|
|
18
|
+
# Create a text element and let the reader know the data is loading.
|
|
19
|
+
data_load_state.text("Done! (using st.cache)")
|
|
20
|
+
|
|
21
|
+
# Load 10,000 rows of data into the dataframe.
|
|
22
|
+
data = load_data(10000)
|
|
23
|
+
# Notify the reader that the data was successfully loaded.
|
|
24
24
|
data_load_state.text('Loading data...done!')
|
re_common/studio/test.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
def test_sq():
|
|
2
|
-
from re_common.baselibrary.utils.basepymongo import BasePyMongo
|
|
3
|
-
# basemongo = BasePyMongo("mongodb://sdbadmin:sdbadmin@192.168.72.86:11817/test2?authMechanism=SCRAM-SHA-1")
|
|
4
|
-
# basemongo = BasePyMongo(
|
|
5
|
-
# "mongodb://sdbadmin:sdbadmin@192.168.72.86:11817/dataware_house.base_obj_meta_a")
|
|
6
|
-
basemongo = BasePyMongo(
|
|
7
|
-
"mongodb://sdbadmin:sdbadmin@192.168.72.86:11817/test2.test?authMechanism=SCRAM-SHA-1")
|
|
8
|
-
|
|
9
|
-
basemongo.use_db("test2")
|
|
10
|
-
# basemongo.auth("sdbadmin", "sdbadmin", "SCRAM-SHA-1")
|
|
11
|
-
basemongo.create_col("test")
|
|
12
|
-
# for items in basemongo.find({}):
|
|
13
|
-
# print(items["user"])
|
|
14
|
-
items = basemongo.find()
|
|
15
|
-
for item in items:
|
|
16
|
-
ids = item["id"]
|
|
17
|
-
print(ids)
|
|
18
|
-
|
|
1
|
+
def test_sq():
|
|
2
|
+
from re_common.baselibrary.utils.basepymongo import BasePyMongo
|
|
3
|
+
# basemongo = BasePyMongo("mongodb://sdbadmin:sdbadmin@192.168.72.86:11817/test2?authMechanism=SCRAM-SHA-1")
|
|
4
|
+
# basemongo = BasePyMongo(
|
|
5
|
+
# "mongodb://sdbadmin:sdbadmin@192.168.72.86:11817/dataware_house.base_obj_meta_a")
|
|
6
|
+
basemongo = BasePyMongo(
|
|
7
|
+
"mongodb://sdbadmin:sdbadmin@192.168.72.86:11817/test2.test?authMechanism=SCRAM-SHA-1")
|
|
8
|
+
|
|
9
|
+
basemongo.use_db("test2")
|
|
10
|
+
# basemongo.auth("sdbadmin", "sdbadmin", "SCRAM-SHA-1")
|
|
11
|
+
basemongo.create_col("test")
|
|
12
|
+
# for items in basemongo.find({}):
|
|
13
|
+
# print(items["user"])
|
|
14
|
+
items = basemongo.find()
|
|
15
|
+
for item in items:
|
|
16
|
+
ids = item["id"]
|
|
17
|
+
print(ids)
|
|
18
|
+
|
|
19
19
|
test_sq()
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# 某些业务中的字符串处理 算是特定场景的工具 不算通用工具
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
from re_common.v2.baselibrary.utils.string_bool import is_all_symbols
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def clean_organ_postcode(organ):
|
|
8
|
+
"""
|
|
9
|
+
格式化组织名称字符串,移除括号内容并删除独立的6位数字(邮政编码),然后清理标点。
|
|
10
|
+
|
|
11
|
+
备注: 该方法替换java 里面的 formatOrgan
|
|
12
|
+
|
|
13
|
+
参数:
|
|
14
|
+
organ (str): 输入的组织名称字符串,可能包含括号、分号和邮政编码。
|
|
15
|
+
|
|
16
|
+
返回:
|
|
17
|
+
str: 格式化并清理后的组织名称字符串(无独立6位数字)。
|
|
18
|
+
"""
|
|
19
|
+
# 如果输入为空,设为空字符串以避免后续操作报错
|
|
20
|
+
if not organ:
|
|
21
|
+
organ = ""
|
|
22
|
+
|
|
23
|
+
# 删除方括号和圆括号中的内容(包括括号本身)
|
|
24
|
+
organ = re.sub(r"\[.*?\]", "", organ) # 非贪婪匹配方括号内容
|
|
25
|
+
organ = re.sub(r"\(.*?\)", "", organ) # 非贪婪匹配圆括号内容
|
|
26
|
+
|
|
27
|
+
# 定义正则表达式,匹配独立的6位数字
|
|
28
|
+
# \b 表示单词边界,确保6位数字是独立的(前后不是字母、数字或下划线)
|
|
29
|
+
organ = re.sub(r"\b[0-9]{6}\b", "", organ)
|
|
30
|
+
|
|
31
|
+
# 初始化结果列表,用于存储处理后的组织名称部分
|
|
32
|
+
format_organ = []
|
|
33
|
+
# 按分号分割字符串,生成组织名称的各个部分
|
|
34
|
+
organ_parts = organ.split(";")
|
|
35
|
+
|
|
36
|
+
# 遍历每个部分,追加到结果列表
|
|
37
|
+
for temp_organ in organ_parts:
|
|
38
|
+
# 去除首尾多余空格后追加(避免因移除邮编导致的空字符串)
|
|
39
|
+
cleaned_part = temp_organ.strip()
|
|
40
|
+
# 如果首尾是标点符号,则移除
|
|
41
|
+
# 定义标点符号的正则表达式(这里包括常见标点)
|
|
42
|
+
punctuation = r"^[!,.?;:#$%^&*+-]+|[!,.?;:#$%^&*+-]+$"
|
|
43
|
+
cleaned_part = re.sub(punctuation, "", cleaned_part)
|
|
44
|
+
if cleaned_part: # 只追加非空部分
|
|
45
|
+
format_organ.append(cleaned_part)
|
|
46
|
+
|
|
47
|
+
# 用分号连接结果,转换为大写并清理标点
|
|
48
|
+
format_organ = ";".join(format_organ)
|
|
49
|
+
|
|
50
|
+
# 返回最终结果并去除首尾空格
|
|
51
|
+
return format_organ.strip()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def get_first_organ(organ):
|
|
55
|
+
if not organ:
|
|
56
|
+
return ""
|
|
57
|
+
organ_list = organ.strip().split(";")
|
|
58
|
+
for organ_one in organ_list:
|
|
59
|
+
# 清理邮政编码
|
|
60
|
+
organ_one = clean_organ_postcode(organ_one)
|
|
61
|
+
if organ_one.strip():
|
|
62
|
+
return organ_one
|
|
63
|
+
|
|
64
|
+
return ""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def get_first_author(author: str) -> str:
|
|
68
|
+
if not author:
|
|
69
|
+
return ""
|
|
70
|
+
au_list = author.strip().split(";")
|
|
71
|
+
for au in au_list:
|
|
72
|
+
au = re.sub("\\[.*?]", "", au)
|
|
73
|
+
au = re.sub("\\(.*?\\)", "", au)
|
|
74
|
+
if au.strip():
|
|
75
|
+
return au
|
|
76
|
+
return ""
|
|
77
|
+
|
|
78
|
+
def get_author_list(author: str):
|
|
79
|
+
lists = []
|
|
80
|
+
if not author:
|
|
81
|
+
return []
|
|
82
|
+
au_list = author.strip().split(";")
|
|
83
|
+
for au in au_list:
|
|
84
|
+
au = re.sub("\\[.*?]", "", au)
|
|
85
|
+
au = re.sub("\\(.*?\\)", "", au)
|
|
86
|
+
if au.strip():
|
|
87
|
+
lists.append(au.strip())
|
|
88
|
+
return lists
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def get_scopus_author_abbr(author_row: str):
|
|
92
|
+
if not author_row:
|
|
93
|
+
return ""
|
|
94
|
+
author_list = author_row.split("&&")
|
|
95
|
+
if len(author_list) != 3:
|
|
96
|
+
raise Exception("错误的数据个数 可能来自其他数据源")
|
|
97
|
+
|
|
98
|
+
abbr_list = author_list[0].strip().split(";")
|
|
99
|
+
abbr_list = [author.strip() for author in abbr_list if
|
|
100
|
+
author.strip() and author.strip().lower() not in ("*", "and")]
|
|
101
|
+
return ";".join(abbr_list)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def get_wos_author_abbr(author_row: str):
|
|
105
|
+
if not author_row:
|
|
106
|
+
return ""
|
|
107
|
+
author_list = author_row.split("&&")
|
|
108
|
+
if len(author_list) != 4:
|
|
109
|
+
raise Exception("错误的数据个数 可能来自其他数据源")
|
|
110
|
+
abbr_list = []
|
|
111
|
+
abbr_list_au = author_list[0].strip().split(";")
|
|
112
|
+
abbr_list_ba = author_list[2].strip().split(";")
|
|
113
|
+
abbr_list.extend(abbr_list_au)
|
|
114
|
+
abbr_list.extend(abbr_list_ba)
|
|
115
|
+
abbr_list = [author.strip() for author in abbr_list if
|
|
116
|
+
author.strip() and author.strip().lower() not in ("*", "and")]
|
|
117
|
+
return ";".join(abbr_list)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def deal_rel_vol(vol_str: str):
|
|
121
|
+
"""
|
|
122
|
+
处理 期刊融合时的卷处理逻辑
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
# 如果卷是全符号 清理掉
|
|
126
|
+
if is_all_symbols(vol_str):
|
|
127
|
+
vol_str = ""
|
|
128
|
+
|
|
129
|
+
if vol_str.replace(".", "").isdigit():
|
|
130
|
+
try:
|
|
131
|
+
float_num = float(vol_str)
|
|
132
|
+
if int(float_num) == float_num:
|
|
133
|
+
return str(int(float_num))
|
|
134
|
+
except:
|
|
135
|
+
pass
|
|
136
|
+
|
|
137
|
+
if vol_str.lower().startswith("v "):
|
|
138
|
+
vol_str = vol_str.lower().replace("v ", "").strip()
|
|
139
|
+
return vol_str
|
|
140
|
+
if vol_str.lower().startswith("volume "):
|
|
141
|
+
vol_str = vol_str.lower().replace("volume ", "").strip()
|
|
142
|
+
return vol_str
|
|
143
|
+
if vol_str.lower().startswith("vol. "):
|
|
144
|
+
vol_str = vol_str.lower().replace("vol. ", "").strip()
|
|
145
|
+
return vol_str
|
|
146
|
+
if vol_str.lower().startswith("vol "):
|
|
147
|
+
vol_str = vol_str.lower().replace("vol ", "").strip()
|
|
148
|
+
return vol_str
|
|
149
|
+
return vol_str
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def deal_num_strs(input_str):
|
|
153
|
+
"""
|
|
154
|
+
int后在str 防止有浮点型的表达方式
|
|
155
|
+
"""
|
|
156
|
+
number_list = re.findall(r'\d+', input_str)
|
|
157
|
+
transformed_numbers = [str(int(num)) for num in number_list]
|
|
158
|
+
|
|
159
|
+
# 替换原字符串中的数字为转换后的数字
|
|
160
|
+
for num, transformed_num in zip(number_list, transformed_numbers):
|
|
161
|
+
input_str = input_str.replace(num, transformed_num)
|
|
162
|
+
return input_str
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def deal_num(num_str):
|
|
166
|
+
"""
|
|
167
|
+
将 期格式化 方便 group尤其是有横杆的数据
|
|
168
|
+
该方法 为融合二次分割时使用,如果场景合适也可以用于其他地方
|
|
169
|
+
:param strs:
|
|
170
|
+
:return:
|
|
171
|
+
"""
|
|
172
|
+
# 如果期是全符号清理掉
|
|
173
|
+
if is_all_symbols(num_str):
|
|
174
|
+
num_str = ""
|
|
175
|
+
|
|
176
|
+
if num_str.lower().startswith("n "):
|
|
177
|
+
num_str = num_str.lower().replace("n ", "").strip()
|
|
178
|
+
|
|
179
|
+
num_str = num_str.lower().replace("special_issue_", '').replace("_special_issue", '').replace("issue", "")
|
|
180
|
+
num_str = num_str.replace("spec.", "").replace("iss.", "").replace("spl.", "").replace("special.", "").replace(
|
|
181
|
+
"specialissue.", "")
|
|
182
|
+
num_str = num_str.replace("spec", "").replace("iss", "").replace("spl", "").replace("special", "").replace(
|
|
183
|
+
"specialissue", '')
|
|
184
|
+
|
|
185
|
+
num_str = num_str.replace("-", "_").replace(".", "_").upper()
|
|
186
|
+
num_str = num_str.lstrip("_").rstrip("_")
|
|
187
|
+
if num_str.find("_") > -1:
|
|
188
|
+
start, end = num_str.split("_")
|
|
189
|
+
start = deal_num_strs(start)
|
|
190
|
+
end = deal_num_strs(end)
|
|
191
|
+
num_str = start + "_" + end
|
|
192
|
+
else:
|
|
193
|
+
num_str = deal_num_strs(num_str)
|
|
194
|
+
|
|
195
|
+
return num_str.lower().strip()
|
|
File without changes
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
import functools
|
|
3
|
-
|
|
4
|
-
# 全局集合,用于记录已警告的函数或类
|
|
5
|
-
_warned_once = set()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def deprecated(message=None):
|
|
9
|
-
"""
|
|
10
|
-
装饰器:标记函数或类为已废弃,整个进程只发出一次警告。
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
message (str): 自定义警告信息,默认为 None。
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
def decorator(obj):
|
|
17
|
-
# 如果是函数
|
|
18
|
-
if isinstance(obj, type(lambda: None)):
|
|
19
|
-
@functools.wraps(obj)
|
|
20
|
-
def wrapper(*args, **kwargs):
|
|
21
|
-
obj_id = id(obj) # 使用对象的内存地址作为唯一标识
|
|
22
|
-
if obj_id not in _warned_once:
|
|
23
|
-
default_msg = f"函数 {obj.__name__} 已不建议使用。"
|
|
24
|
-
warn_msg = f"{default_msg} {message}" if message else default_msg
|
|
25
|
-
warnings.warn(
|
|
26
|
-
warn_msg,
|
|
27
|
-
category=DeprecationWarning,
|
|
28
|
-
stacklevel=2
|
|
29
|
-
)
|
|
30
|
-
_warned_once.add(obj_id) # 记录已警告
|
|
31
|
-
return obj(*args, **kwargs)
|
|
32
|
-
|
|
33
|
-
return wrapper
|
|
34
|
-
|
|
35
|
-
# 如果是类
|
|
36
|
-
elif isinstance(obj, type):
|
|
37
|
-
orig_init = obj.__init__
|
|
38
|
-
|
|
39
|
-
@functools.wraps(orig_init)
|
|
40
|
-
def new_init(self, *args, **kwargs):
|
|
41
|
-
obj_id = id(obj)
|
|
42
|
-
if obj_id not in _warned_once:
|
|
43
|
-
default_msg = f"类 {obj.__name__} 已不建议使用。"
|
|
44
|
-
warn_msg = f"{default_msg} {message}" if message else default_msg
|
|
45
|
-
warnings.warn(
|
|
46
|
-
warn_msg,
|
|
47
|
-
category=DeprecationWarning,
|
|
48
|
-
stacklevel=2
|
|
49
|
-
)
|
|
50
|
-
_warned_once.add(obj_id) # 记录已警告
|
|
51
|
-
orig_init(self, *args, **kwargs)
|
|
52
|
-
|
|
53
|
-
obj.__init__ = new_init
|
|
54
|
-
return obj
|
|
55
|
-
|
|
56
|
-
else:
|
|
57
|
-
raise TypeError("此装饰器仅适用于函数和类")
|
|
58
|
-
|
|
59
|
-
return decorator
|
|
1
|
+
import warnings
|
|
2
|
+
import functools
|
|
3
|
+
|
|
4
|
+
# 全局集合,用于记录已警告的函数或类
|
|
5
|
+
_warned_once = set()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def deprecated(message=None):
|
|
9
|
+
"""
|
|
10
|
+
装饰器:标记函数或类为已废弃,整个进程只发出一次警告。
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
message (str): 自定义警告信息,默认为 None。
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def decorator(obj):
|
|
17
|
+
# 如果是函数
|
|
18
|
+
if isinstance(obj, type(lambda: None)):
|
|
19
|
+
@functools.wraps(obj)
|
|
20
|
+
def wrapper(*args, **kwargs):
|
|
21
|
+
obj_id = id(obj) # 使用对象的内存地址作为唯一标识
|
|
22
|
+
if obj_id not in _warned_once:
|
|
23
|
+
default_msg = f"函数 {obj.__name__} 已不建议使用。"
|
|
24
|
+
warn_msg = f"{default_msg} {message}" if message else default_msg
|
|
25
|
+
warnings.warn(
|
|
26
|
+
warn_msg,
|
|
27
|
+
category=DeprecationWarning,
|
|
28
|
+
stacklevel=2
|
|
29
|
+
)
|
|
30
|
+
_warned_once.add(obj_id) # 记录已警告
|
|
31
|
+
return obj(*args, **kwargs)
|
|
32
|
+
|
|
33
|
+
return wrapper
|
|
34
|
+
|
|
35
|
+
# 如果是类
|
|
36
|
+
elif isinstance(obj, type):
|
|
37
|
+
orig_init = obj.__init__
|
|
38
|
+
|
|
39
|
+
@functools.wraps(orig_init)
|
|
40
|
+
def new_init(self, *args, **kwargs):
|
|
41
|
+
obj_id = id(obj)
|
|
42
|
+
if obj_id not in _warned_once:
|
|
43
|
+
default_msg = f"类 {obj.__name__} 已不建议使用。"
|
|
44
|
+
warn_msg = f"{default_msg} {message}" if message else default_msg
|
|
45
|
+
warnings.warn(
|
|
46
|
+
warn_msg,
|
|
47
|
+
category=DeprecationWarning,
|
|
48
|
+
stacklevel=2
|
|
49
|
+
)
|
|
50
|
+
_warned_once.add(obj_id) # 记录已警告
|
|
51
|
+
orig_init(self, *args, **kwargs)
|
|
52
|
+
|
|
53
|
+
obj.__init__ = new_init
|
|
54
|
+
return obj
|
|
55
|
+
|
|
56
|
+
else:
|
|
57
|
+
raise TypeError("此装饰器仅适用于函数和类")
|
|
58
|
+
|
|
59
|
+
return decorator
|