re-common 10.0.39__py3-none-any.whl → 10.0.41__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 +235 -220
- re_common/v2/baselibrary/business_utils/baseencodeid.py +100 -100
- re_common/v2/baselibrary/business_utils/full_doi_path.py +116 -116
- re_common/v2/baselibrary/business_utils/rel_tools.py +6 -6
- re_common/v2/baselibrary/decorators/utils.py +59 -59
- re_common/v2/baselibrary/helpers/search_packge/NearestNeighbors_test.py +105 -105
- re_common/v2/baselibrary/helpers/search_packge/fit_text_match.py +253 -253
- re_common/v2/baselibrary/helpers/search_packge/scikit_learn_text_matcher.py +260 -260
- re_common/v2/baselibrary/helpers/search_packge/test.py +1 -1
- re_common/v2/baselibrary/s3object/baseboto3.py +230 -230
- re_common/v2/baselibrary/tools/WeChatRobot.py +95 -95
- re_common/v2/baselibrary/tools/ac_ahocorasick.py +75 -75
- re_common/v2/baselibrary/tools/concurrency.py +35 -35
- re_common/v2/baselibrary/tools/data_processer/base.py +53 -53
- re_common/v2/baselibrary/tools/data_processer/data_processer.py +497 -508
- re_common/v2/baselibrary/tools/data_processer/data_reader.py +187 -187
- re_common/v2/baselibrary/tools/data_processer/data_writer.py +38 -38
- re_common/v2/baselibrary/tools/dict_tools.py +44 -44
- re_common/v2/baselibrary/tools/dolphinscheduler.py +187 -187
- re_common/v2/baselibrary/tools/hdfs_base_processor.py +204 -204
- re_common/v2/baselibrary/tools/hdfs_bulk_processor.py +67 -67
- re_common/v2/baselibrary/tools/hdfs_data_processer.py +338 -338
- re_common/v2/baselibrary/tools/hdfs_line_processor.py +74 -74
- re_common/v2/baselibrary/tools/list_tools.py +69 -69
- re_common/v2/baselibrary/tools/resume_tracker.py +94 -94
- 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/tree_processor/__init__.py +0 -0
- re_common/v2/baselibrary/tools/tree_processor/builder.py +25 -0
- re_common/v2/baselibrary/tools/tree_processor/node.py +13 -0
- re_common/v2/baselibrary/tools/unionfind_tools.py +60 -60
- re_common/v2/baselibrary/utils/BusinessStringUtil.py +196 -196
- re_common/v2/baselibrary/utils/api_net_utils.py +270 -270
- re_common/v2/baselibrary/utils/author_smi.py +361 -361
- 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 +163 -163
- re_common/v2/baselibrary/utils/basepika.py +180 -180
- re_common/v2/baselibrary/utils/basetime.py +94 -77
- re_common/v2/baselibrary/utils/db.py +174 -156
- re_common/v2/baselibrary/utils/elasticsearch.py +46 -0
- 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 +187 -186
- re_common/v2/baselibrary/utils/string_clear.py +246 -246
- re_common/v2/baselibrary/utils/string_smi.py +18 -18
- re_common/v2/baselibrary/utils/stringutils.py +312 -271
- 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.39.dist-info → re_common-10.0.41.dist-info}/LICENSE +201 -201
- {re_common-10.0.39.dist-info → re_common-10.0.41.dist-info}/METADATA +16 -16
- re_common-10.0.41.dist-info/RECORD +252 -0
- {re_common-10.0.39.dist-info → re_common-10.0.41.dist-info}/WHEEL +1 -1
- re_common-10.0.39.dist-info/RECORD +0 -248
- {re_common-10.0.39.dist-info → re_common-10.0.41.dist-info}/top_level.txt +0 -0
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
import importlib
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def import_fun(obj, mod, m=[], modename=""):
|
|
7
|
-
"""
|
|
8
|
-
这个方法只能在类里面设置属性
|
|
9
|
-
:param obj:
|
|
10
|
-
:param mod:
|
|
11
|
-
:param m:
|
|
12
|
-
:return:
|
|
13
|
-
"""
|
|
14
|
-
if m:
|
|
15
|
-
for item in m:
|
|
16
|
-
module = getattr(mod, item)
|
|
17
|
-
setattr(obj, item, module)
|
|
18
|
-
elif modename:
|
|
19
|
-
setattr(obj, modename, mod)
|
|
20
|
-
else:
|
|
21
|
-
raise ValueError("m 和 modename必须存在一个")
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def import_to_val(mod, m=[], globals=None, locals=None):
|
|
25
|
-
"""
|
|
26
|
-
设置到变量,在你调用的文件中使用
|
|
27
|
-
:param mod: 一个模块对象
|
|
28
|
-
:param m: 一个列表 mod 里面的变量类和函数
|
|
29
|
-
:param globals: 传入 globals()
|
|
30
|
-
:param locals: 传入 locals()
|
|
31
|
-
:return:
|
|
32
|
-
"""
|
|
33
|
-
dicts = {}
|
|
34
|
-
for item in m:
|
|
35
|
-
# module = getattr(mod, item)
|
|
36
|
-
exec("{}=getattr(mod, '{}')".format(item, item))
|
|
37
|
-
dicts[item] = eval(item)
|
|
38
|
-
if globals:
|
|
39
|
-
globals.update({item: eval(item)})
|
|
40
|
-
if locals:
|
|
41
|
-
locals.update({item: eval(item)})
|
|
42
|
-
return dicts
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def import_model(name):
|
|
46
|
-
"""
|
|
47
|
-
import 模块
|
|
48
|
-
"""
|
|
49
|
-
return importlib.import_module(name)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def symbol_by_name(name, aliases=None, imp=None, package=None,
|
|
53
|
-
sep='.', default=None, **kwargs):
|
|
54
|
-
"""Get symbol by qualified name.
|
|
55
|
-
|
|
56
|
-
The name should be the full dot-separated path to the class::
|
|
57
|
-
|
|
58
|
-
modulename.ClassName
|
|
59
|
-
|
|
60
|
-
Example::
|
|
61
|
-
|
|
62
|
-
celery.concurrency.processes.TaskPool
|
|
63
|
-
^- class name
|
|
64
|
-
|
|
65
|
-
or using ':' to separate module and symbol::
|
|
66
|
-
|
|
67
|
-
celery.concurrency.processes:TaskPool
|
|
68
|
-
|
|
69
|
-
If `aliases` is provided, a dict containing short name/long name
|
|
70
|
-
mappings, the name is looked up in the aliases first.
|
|
71
|
-
|
|
72
|
-
Examples:
|
|
73
|
-
>>> symbol_by_name('celery.concurrency.processes.TaskPool')
|
|
74
|
-
<class 'celery.concurrency.processes.TaskPool'>
|
|
75
|
-
|
|
76
|
-
>>> symbol_by_name('default', {
|
|
77
|
-
... 'default': 'celery.concurrency.processes.TaskPool'})
|
|
78
|
-
<class 'celery.concurrency.processes.TaskPool'>
|
|
79
|
-
|
|
80
|
-
# Does not try to look up non-string names.
|
|
81
|
-
from celery.concurrency.processes import TaskPool
|
|
82
|
-
symbol_by_name(TaskPool) is TaskPool
|
|
83
|
-
True
|
|
84
|
-
"""
|
|
85
|
-
from re_common.baselibrary.utils.baseexcept import reraise
|
|
86
|
-
aliases = {} if not aliases else aliases
|
|
87
|
-
if imp is None:
|
|
88
|
-
imp = importlib.import_module
|
|
89
|
-
|
|
90
|
-
if not isinstance(name, str):
|
|
91
|
-
return name # already a class
|
|
92
|
-
|
|
93
|
-
name = aliases.get(name) or name
|
|
94
|
-
sep = ':' if ':' in name else sep
|
|
95
|
-
module_name, _, cls_name = name.rpartition(sep)
|
|
96
|
-
if not module_name:
|
|
97
|
-
cls_name, module_name = None, package if package else cls_name
|
|
98
|
-
try:
|
|
99
|
-
try:
|
|
100
|
-
# 这里的 **kwargs 是为了兼容 传入的 imp
|
|
101
|
-
module = imp(module_name, package=package, **kwargs)
|
|
102
|
-
except ValueError as exc:
|
|
103
|
-
reraise(ValueError,
|
|
104
|
-
ValueError(f"Couldn't import {name!r}: {exc}"),
|
|
105
|
-
sys.exc_info()[2])
|
|
106
|
-
return getattr(module, cls_name) if cls_name else module
|
|
107
|
-
except (ImportError, AttributeError):
|
|
108
|
-
if default is None:
|
|
109
|
-
raise
|
|
110
|
-
return default
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def set_topdir_to_path(file, top_name):
|
|
114
|
-
"""
|
|
115
|
-
|
|
116
|
-
:param file: 请传入 __file__
|
|
117
|
-
:param top_name: 顶层目录的名字如 本项目为re-common
|
|
118
|
-
:return:
|
|
119
|
-
"""
|
|
120
|
-
pathlist = os.path.dirname(os.path.abspath(file)).split(os.sep)
|
|
121
|
-
root_path = os.sep.join(pathlist[:pathlist.index(top_name) + 1])
|
|
122
|
-
sys.path.insert(0, root_path)
|
|
123
|
-
sys.path = list(set(sys.path))
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import importlib
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def import_fun(obj, mod, m=[], modename=""):
|
|
7
|
+
"""
|
|
8
|
+
这个方法只能在类里面设置属性
|
|
9
|
+
:param obj:
|
|
10
|
+
:param mod:
|
|
11
|
+
:param m:
|
|
12
|
+
:return:
|
|
13
|
+
"""
|
|
14
|
+
if m:
|
|
15
|
+
for item in m:
|
|
16
|
+
module = getattr(mod, item)
|
|
17
|
+
setattr(obj, item, module)
|
|
18
|
+
elif modename:
|
|
19
|
+
setattr(obj, modename, mod)
|
|
20
|
+
else:
|
|
21
|
+
raise ValueError("m 和 modename必须存在一个")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def import_to_val(mod, m=[], globals=None, locals=None):
|
|
25
|
+
"""
|
|
26
|
+
设置到变量,在你调用的文件中使用
|
|
27
|
+
:param mod: 一个模块对象
|
|
28
|
+
:param m: 一个列表 mod 里面的变量类和函数
|
|
29
|
+
:param globals: 传入 globals()
|
|
30
|
+
:param locals: 传入 locals()
|
|
31
|
+
:return:
|
|
32
|
+
"""
|
|
33
|
+
dicts = {}
|
|
34
|
+
for item in m:
|
|
35
|
+
# module = getattr(mod, item)
|
|
36
|
+
exec("{}=getattr(mod, '{}')".format(item, item))
|
|
37
|
+
dicts[item] = eval(item)
|
|
38
|
+
if globals:
|
|
39
|
+
globals.update({item: eval(item)})
|
|
40
|
+
if locals:
|
|
41
|
+
locals.update({item: eval(item)})
|
|
42
|
+
return dicts
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def import_model(name):
|
|
46
|
+
"""
|
|
47
|
+
import 模块
|
|
48
|
+
"""
|
|
49
|
+
return importlib.import_module(name)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def symbol_by_name(name, aliases=None, imp=None, package=None,
|
|
53
|
+
sep='.', default=None, **kwargs):
|
|
54
|
+
"""Get symbol by qualified name.
|
|
55
|
+
|
|
56
|
+
The name should be the full dot-separated path to the class::
|
|
57
|
+
|
|
58
|
+
modulename.ClassName
|
|
59
|
+
|
|
60
|
+
Example::
|
|
61
|
+
|
|
62
|
+
celery.concurrency.processes.TaskPool
|
|
63
|
+
^- class name
|
|
64
|
+
|
|
65
|
+
or using ':' to separate module and symbol::
|
|
66
|
+
|
|
67
|
+
celery.concurrency.processes:TaskPool
|
|
68
|
+
|
|
69
|
+
If `aliases` is provided, a dict containing short name/long name
|
|
70
|
+
mappings, the name is looked up in the aliases first.
|
|
71
|
+
|
|
72
|
+
Examples:
|
|
73
|
+
>>> symbol_by_name('celery.concurrency.processes.TaskPool')
|
|
74
|
+
<class 'celery.concurrency.processes.TaskPool'>
|
|
75
|
+
|
|
76
|
+
>>> symbol_by_name('default', {
|
|
77
|
+
... 'default': 'celery.concurrency.processes.TaskPool'})
|
|
78
|
+
<class 'celery.concurrency.processes.TaskPool'>
|
|
79
|
+
|
|
80
|
+
# Does not try to look up non-string names.
|
|
81
|
+
from celery.concurrency.processes import TaskPool
|
|
82
|
+
symbol_by_name(TaskPool) is TaskPool
|
|
83
|
+
True
|
|
84
|
+
"""
|
|
85
|
+
from re_common.baselibrary.utils.baseexcept import reraise
|
|
86
|
+
aliases = {} if not aliases else aliases
|
|
87
|
+
if imp is None:
|
|
88
|
+
imp = importlib.import_module
|
|
89
|
+
|
|
90
|
+
if not isinstance(name, str):
|
|
91
|
+
return name # already a class
|
|
92
|
+
|
|
93
|
+
name = aliases.get(name) or name
|
|
94
|
+
sep = ':' if ':' in name else sep
|
|
95
|
+
module_name, _, cls_name = name.rpartition(sep)
|
|
96
|
+
if not module_name:
|
|
97
|
+
cls_name, module_name = None, package if package else cls_name
|
|
98
|
+
try:
|
|
99
|
+
try:
|
|
100
|
+
# 这里的 **kwargs 是为了兼容 传入的 imp
|
|
101
|
+
module = imp(module_name, package=package, **kwargs)
|
|
102
|
+
except ValueError as exc:
|
|
103
|
+
reraise(ValueError,
|
|
104
|
+
ValueError(f"Couldn't import {name!r}: {exc}"),
|
|
105
|
+
sys.exc_info()[2])
|
|
106
|
+
return getattr(module, cls_name) if cls_name else module
|
|
107
|
+
except (ImportError, AttributeError):
|
|
108
|
+
if default is None:
|
|
109
|
+
raise
|
|
110
|
+
return default
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def set_topdir_to_path(file, top_name):
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
:param file: 请传入 __file__
|
|
117
|
+
:param top_name: 顶层目录的名字如 本项目为re-common
|
|
118
|
+
:return:
|
|
119
|
+
"""
|
|
120
|
+
pathlist = os.path.dirname(os.path.abspath(file)).split(os.sep)
|
|
121
|
+
root_path = os.sep.join(pathlist[:pathlist.index(top_name) + 1])
|
|
122
|
+
sys.path.insert(0, root_path)
|
|
123
|
+
sys.path = list(set(sys.path))
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import random
|
|
2
|
-
|
|
3
|
-
from faker import Faker
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# https://www.jianshu.com/p/20e41fc65dc8
|
|
7
|
-
|
|
8
|
-
class MFaker(Faker):
|
|
9
|
-
# 生成名字
|
|
10
|
-
m_name = "name"
|
|
11
|
-
# 生成地址
|
|
12
|
-
m_address = "address"
|
|
13
|
-
# 生成国家
|
|
14
|
-
m_country = "country"
|
|
15
|
-
# 生成省份
|
|
16
|
-
m_province = "province"
|
|
17
|
-
# 生成市 县
|
|
18
|
-
m_city_suffix = "city_suffix"
|
|
19
|
-
|
|
20
|
-
# 以下结构都可以用 py_para 结构的参数
|
|
21
|
-
# 生成dict
|
|
22
|
-
m_pydict = "pydict"
|
|
23
|
-
# 生成list
|
|
24
|
-
m_pylist = "pylist"
|
|
25
|
-
# 生成iterable
|
|
26
|
-
m_pyiterable = "pyiterable"
|
|
27
|
-
# 生成set
|
|
28
|
-
m_pyset = "pyset"
|
|
29
|
-
# 生成tuple
|
|
30
|
-
m_pytuple = "pytuple"
|
|
31
|
-
|
|
32
|
-
def create_data(self, types, **kwargs):
|
|
33
|
-
"""
|
|
34
|
-
:param types: 是上面的类型
|
|
35
|
-
:param kwargs: 类型的参数
|
|
36
|
-
:return:
|
|
37
|
-
"""
|
|
38
|
-
if kwargs:
|
|
39
|
-
print(kwargs)
|
|
40
|
-
return getattr(self, types)(**kwargs)
|
|
41
|
-
return getattr(self, types)()
|
|
42
|
-
|
|
43
|
-
def py_para(self, num=10):
|
|
44
|
-
"""
|
|
45
|
-
python 集合参数 适用于python 原生集合
|
|
46
|
-
pydict pylist 的参数
|
|
47
|
-
:return:
|
|
48
|
-
"""
|
|
49
|
-
return {"nb_elements": num, "variable_nb_elements": True}
|
|
50
|
-
|
|
51
|
-
def get_page(self):
|
|
52
|
-
return random.randint(1, 150)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import random
|
|
2
|
+
|
|
3
|
+
from faker import Faker
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# https://www.jianshu.com/p/20e41fc65dc8
|
|
7
|
+
|
|
8
|
+
class MFaker(Faker):
|
|
9
|
+
# 生成名字
|
|
10
|
+
m_name = "name"
|
|
11
|
+
# 生成地址
|
|
12
|
+
m_address = "address"
|
|
13
|
+
# 生成国家
|
|
14
|
+
m_country = "country"
|
|
15
|
+
# 生成省份
|
|
16
|
+
m_province = "province"
|
|
17
|
+
# 生成市 县
|
|
18
|
+
m_city_suffix = "city_suffix"
|
|
19
|
+
|
|
20
|
+
# 以下结构都可以用 py_para 结构的参数
|
|
21
|
+
# 生成dict
|
|
22
|
+
m_pydict = "pydict"
|
|
23
|
+
# 生成list
|
|
24
|
+
m_pylist = "pylist"
|
|
25
|
+
# 生成iterable
|
|
26
|
+
m_pyiterable = "pyiterable"
|
|
27
|
+
# 生成set
|
|
28
|
+
m_pyset = "pyset"
|
|
29
|
+
# 生成tuple
|
|
30
|
+
m_pytuple = "pytuple"
|
|
31
|
+
|
|
32
|
+
def create_data(self, types, **kwargs):
|
|
33
|
+
"""
|
|
34
|
+
:param types: 是上面的类型
|
|
35
|
+
:param kwargs: 类型的参数
|
|
36
|
+
:return:
|
|
37
|
+
"""
|
|
38
|
+
if kwargs:
|
|
39
|
+
print(kwargs)
|
|
40
|
+
return getattr(self, types)(**kwargs)
|
|
41
|
+
return getattr(self, types)()
|
|
42
|
+
|
|
43
|
+
def py_para(self, num=10):
|
|
44
|
+
"""
|
|
45
|
+
python 集合参数 适用于python 原生集合
|
|
46
|
+
pydict pylist 的参数
|
|
47
|
+
:return:
|
|
48
|
+
"""
|
|
49
|
+
return {"nb_elements": num, "variable_nb_elements": True}
|
|
50
|
+
|
|
51
|
+
def get_page(self):
|
|
52
|
+
return random.randint(1, 150)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# 该库来自于 my_abc 由于代码量太小 不想为此安装一个库,故将代码引入到基础库
|
|
2
|
-
# 如果该库后面有更新,可以选择继续引入或者直接使用第三方库
|
|
3
|
-
|
|
1
|
+
# 该库来自于 my_abc 由于代码量太小 不想为此安装一个库,故将代码引入到基础库
|
|
2
|
+
# 如果该库后面有更新,可以选择继续引入或者直接使用第三方库
|
|
3
|
+
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
from abc import ABCMeta as NativeABCMeta
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class DummyAttribute:
|
|
5
|
-
pass
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def abstract_attribute(obj=None):
|
|
9
|
-
if obj is None:
|
|
10
|
-
obj = DummyAttribute()
|
|
11
|
-
obj.__is_abstract_attribute__ = True
|
|
12
|
-
return obj
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class ABCMeta(NativeABCMeta):
|
|
16
|
-
|
|
17
|
-
def __call__(cls, *args, **kwargs):
|
|
18
|
-
instance = NativeABCMeta.__call__(cls, *args, **kwargs)
|
|
19
|
-
abstract_attributes = {
|
|
20
|
-
name
|
|
21
|
-
for name in dir(instance)
|
|
22
|
-
if getattr(getattr(instance, name), '__is_abstract_attribute__', False)
|
|
23
|
-
}
|
|
24
|
-
if abstract_attributes:
|
|
25
|
-
raise NotImplementedError(
|
|
26
|
-
"Can't instantiate abstract class {} with"
|
|
27
|
-
" abstract attributes: {}".format(
|
|
28
|
-
cls.__name__,
|
|
29
|
-
', '.join(abstract_attributes)
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
return instance
|
|
1
|
+
from abc import ABCMeta as NativeABCMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class DummyAttribute:
|
|
5
|
+
pass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def abstract_attribute(obj=None):
|
|
9
|
+
if obj is None:
|
|
10
|
+
obj = DummyAttribute()
|
|
11
|
+
obj.__is_abstract_attribute__ = True
|
|
12
|
+
return obj
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ABCMeta(NativeABCMeta):
|
|
16
|
+
|
|
17
|
+
def __call__(cls, *args, **kwargs):
|
|
18
|
+
instance = NativeABCMeta.__call__(cls, *args, **kwargs)
|
|
19
|
+
abstract_attributes = {
|
|
20
|
+
name
|
|
21
|
+
for name in dir(instance)
|
|
22
|
+
if getattr(getattr(instance, name), '__is_abstract_attribute__', False)
|
|
23
|
+
}
|
|
24
|
+
if abstract_attributes:
|
|
25
|
+
raise NotImplementedError(
|
|
26
|
+
"Can't instantiate abstract class {} with"
|
|
27
|
+
" abstract attributes: {}".format(
|
|
28
|
+
cls.__name__,
|
|
29
|
+
', '.join(abstract_attributes)
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
return instance
|