lazysdk 0.1.15__tar.gz → 0.1.17__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.
- {lazysdk-0.1.15 → lazysdk-0.1.17}/PKG-INFO +1 -1
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyfile.py +29 -27
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazym3u8.py +1 -1
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazypath.py +16 -1
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk.egg-info/PKG-INFO +1 -1
- {lazysdk-0.1.15 → lazysdk-0.1.17}/setup.py +1 -1
- {lazysdk-0.1.15 → lazysdk-0.1.17}/README.md +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/__init__.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyCrypto.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazybase64.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazydict.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyenv.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyexcel.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyflask.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyid.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyip.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazymd5.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyprocess.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyproxies.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyrandom.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyredis.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyrequests.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazytext.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazytime.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyua.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazyurl.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk/lazywebhook.py +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk.egg-info/SOURCES.txt +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk.egg-info/dependency_links.txt +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk.egg-info/requires.txt +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/lazysdk.egg-info/top_level.txt +0 -0
- {lazysdk-0.1.15 → lazysdk-0.1.17}/setup.cfg +0 -0
@@ -263,41 +263,43 @@ def safe_download(
|
|
263
263
|
|
264
264
|
|
265
265
|
def read(
|
266
|
-
|
267
|
-
postfix=
|
266
|
+
file,
|
267
|
+
postfix=None,
|
268
268
|
path=None,
|
269
|
-
silence=False
|
269
|
+
silence=False,
|
270
|
+
json_auto=True
|
270
271
|
):
|
272
|
+
"""
|
273
|
+
读取文件
|
274
|
+
json_auto:json格式自动转换
|
275
|
+
"""
|
276
|
+
if path:
|
277
|
+
# 如果指定了路径,就加上路径
|
278
|
+
file_dir = f'{path}{path_separator}{file}'
|
279
|
+
else:
|
280
|
+
# 如果没指定路径,就直接使用文件名
|
281
|
+
file_dir = file
|
282
|
+
|
283
|
+
if postfix:
|
284
|
+
# 如果指定了后缀名,就加上后缀名
|
285
|
+
file_dir = f'{file}.{postfix}'
|
286
|
+
else:
|
287
|
+
# 如果没指定后缀名,就忽略
|
288
|
+
pass
|
271
289
|
try:
|
272
|
-
if postfix == "
|
273
|
-
if path is None:
|
274
|
-
f = open("%s.%s" % (file_name, postfix), encoding='utf-8')
|
275
|
-
else:
|
276
|
-
f = open("%s/%s.%s" % (path, file_name, postfix), encoding='utf-8')
|
277
|
-
res = f.read()
|
278
|
-
return res
|
279
|
-
elif postfix == "json":
|
290
|
+
if postfix == "json" and json_auto:
|
280
291
|
content_list = list()
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
content_list.append(each_json)
|
287
|
-
else:
|
288
|
-
with open("./%s/%s.%s" % (path, file_name, postfix), 'r', encoding='utf-8') as f:
|
289
|
-
content = f.readlines()
|
290
|
-
for each in content:
|
291
|
-
each_json = json.loads(each)
|
292
|
-
content_list.append(each_json)
|
292
|
+
with open(file=file_dir, mode='r', encoding='utf-8') as f:
|
293
|
+
content = f.readlines()
|
294
|
+
for each in content:
|
295
|
+
each_json = json.loads(each)
|
296
|
+
content_list.append(each_json)
|
293
297
|
return content_list
|
294
298
|
else:
|
295
|
-
|
296
|
-
f = open("%s.%s" % (file_name, postfix), encoding='utf-8')
|
297
|
-
else:
|
298
|
-
f = open("%s/%s.%s" % (path, file_name, postfix), encoding='utf-8')
|
299
|
+
f = open(file=file_dir, mode='r', encoding='utf-8')
|
299
300
|
res = f.read()
|
300
301
|
return res
|
302
|
+
|
301
303
|
except Exception as e:
|
302
304
|
if silence is True:
|
303
305
|
pass
|
@@ -92,7 +92,7 @@ def project_path(
|
|
92
92
|
return _project_path
|
93
93
|
|
94
94
|
|
95
|
-
def file_path():
|
95
|
+
def file_path(__file__):
|
96
96
|
"""
|
97
97
|
os.path.dirname(os.path.abspath(__file__)) 单纯的文件地址
|
98
98
|
os.path.dirname(os.path.realpath(__file__)) 可能会存在的文件指向的真实地址
|
@@ -154,3 +154,18 @@ def open_path(path):
|
|
154
154
|
os.startfile(path) # Windows上打开文件
|
155
155
|
else:
|
156
156
|
subprocess.check_call(['open', path]) # 非Windows上打开文件
|
157
|
+
|
158
|
+
|
159
|
+
def path_clean(content):
|
160
|
+
"""
|
161
|
+
清除路径前后可能出现的引号
|
162
|
+
"""
|
163
|
+
if content[0] == '"' and content[-1] == '"':
|
164
|
+
content = content[1:-1]
|
165
|
+
elif content[0] == '“' and content[-1] == '”':
|
166
|
+
content = content[1:-1]
|
167
|
+
elif content[0] == "'" and content[-1] == "'":
|
168
|
+
content = content[1:-1]
|
169
|
+
else:
|
170
|
+
pass
|
171
|
+
return content
|
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
|