ilds 2.2.2__tar.gz → 2.2.4__tar.gz
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.
- {ilds-2.2.2 → ilds-2.2.4}/PKG-INFO +1 -1
- {ilds-2.2.2 → ilds-2.2.4}/ilds/django/util.py +15 -8
- {ilds-2.2.2 → ilds-2.2.4}/ilds/excel_xlsx.py +3 -1
- {ilds-2.2.2 → ilds-2.2.4}/ilds/file.py +12 -16
- {ilds-2.2.2 → ilds-2.2.4}/ilds/versions.py +1 -1
- {ilds-2.2.2 → ilds-2.2.4}/ilds.egg-info/PKG-INFO +1 -1
- {ilds-2.2.2 → ilds-2.2.4}/README.rst +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/__init__.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/cmd.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/django/__init__.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/django/admin.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/django/import_export.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/django/model.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/django/user.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/everything.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/excel_xlrd.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/lib/__init__.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/lib/browsercookie.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/lib/configobj/__init__.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/lib/configobj/_version.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/lib/configobj/validate.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/lib/hexdump.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/match_data.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/md.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/md5summer.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/mycsv.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/net.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/pd.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/spider.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/time.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds/util.py +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds.egg-info/SOURCES.txt +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds.egg-info/dependency_links.txt +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds.egg-info/requires.txt +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/ilds.egg-info/top_level.txt +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/setup.cfg +0 -0
- {ilds-2.2.2 → ilds-2.2.4}/setup.py +0 -0
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
#
|
|
3
3
|
# ---------------------------------------
|
|
4
4
|
# 程序:util.py
|
|
5
|
-
# 版本:0.
|
|
5
|
+
# 版本:0.4
|
|
6
6
|
# 作者:lds
|
|
7
|
-
# 日期:
|
|
7
|
+
# 日期:2024-09-18
|
|
8
8
|
# 语言:Python 3.X
|
|
9
9
|
# 说明:常用的函数集合
|
|
10
10
|
# ---------------------------------------
|
|
@@ -20,23 +20,30 @@ def django_setup(project_name=None, site_path=None):
|
|
|
20
20
|
"""
|
|
21
21
|
设置 Django 运行环境
|
|
22
22
|
|
|
23
|
+
用法示例:
|
|
23
24
|
from ilds.django.util import django_setup
|
|
24
25
|
django_setup(r'mysite', site_path=None)
|
|
25
26
|
"""
|
|
26
27
|
|
|
27
|
-
if site_path
|
|
28
|
+
if site_path:
|
|
28
29
|
sys.path.insert(0, site_path)
|
|
29
30
|
|
|
30
|
-
if project_name
|
|
31
|
-
project_name = os.path.
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if not project_name:
|
|
32
|
+
project_name = os.path.basename(os.path.dirname(__file__))
|
|
33
|
+
|
|
34
|
+
print(f'项目:{project_name}')
|
|
35
|
+
|
|
36
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"{project_name}.settings")
|
|
37
|
+
|
|
34
38
|
try:
|
|
35
39
|
import django
|
|
36
40
|
django.setup()
|
|
37
41
|
except ModuleNotFoundError as e:
|
|
38
42
|
print("注:如果找不到 Django,请安装它: pip install django\n错误提示:", e)
|
|
39
|
-
exit()
|
|
43
|
+
exit(1) # 使用非零退出代码表示程序异常退出
|
|
44
|
+
except Exception as e:
|
|
45
|
+
print("发生了意外错误:", e)
|
|
46
|
+
exit(1)
|
|
40
47
|
|
|
41
48
|
|
|
42
49
|
def random_key():
|
|
@@ -218,7 +218,9 @@ class ReadXlsx(object):
|
|
|
218
218
|
# bg_color = fill.end_color.rgb # end_color bgColor
|
|
219
219
|
# print(bg_color)
|
|
220
220
|
# print(c.data_type, c.number_format, is_date_format(c.number_format), c.value)
|
|
221
|
-
if c.
|
|
221
|
+
if c.hyperlink and c.hyperlink.target:
|
|
222
|
+
cell_value = c.hyperlink.target
|
|
223
|
+
elif c.value is None and self.none_to_null_characters:
|
|
222
224
|
cell_value = ''
|
|
223
225
|
elif c.data_type == "n":
|
|
224
226
|
if c.number_format != "General" and is_date_format(c.number_format):
|
|
@@ -791,31 +791,27 @@ def json_read(path):
|
|
|
791
791
|
读取 json 文件
|
|
792
792
|
"""
|
|
793
793
|
try:
|
|
794
|
-
if not os.path.exists(path):
|
|
795
|
-
return False
|
|
796
794
|
with open(path, 'r', encoding='utf-8') as f:
|
|
797
|
-
|
|
798
|
-
return obj
|
|
795
|
+
return json.load(f)
|
|
799
796
|
except Exception as e:
|
|
800
|
-
print('
|
|
801
|
-
return
|
|
797
|
+
print('Error reading JSON:', e)
|
|
798
|
+
return None
|
|
802
799
|
|
|
803
800
|
|
|
804
|
-
def json_save(obj, path):
|
|
801
|
+
def json_save(obj, path, indent=2):
|
|
805
802
|
"""
|
|
806
803
|
保存 json 文件
|
|
807
804
|
"""
|
|
808
|
-
|
|
809
805
|
if obj is None:
|
|
810
806
|
return False
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
807
|
+
|
|
808
|
+
try:
|
|
809
|
+
with open(path, 'w', encoding='utf-8') as f:
|
|
810
|
+
json.dump(obj, f, ensure_ascii=False, indent=indent)
|
|
811
|
+
return True
|
|
812
|
+
except Exception as e:
|
|
813
|
+
print('Error saving JSON:', e)
|
|
814
|
+
return False
|
|
819
815
|
|
|
820
816
|
|
|
821
817
|
def doc():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|