mdbq 3.3.4__py3-none-any.whl → 3.3.7__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.
- mdbq/aggregation/query_data.py +2 -2
- mdbq/mongo/mongo.py +24 -22
- mdbq/mysql/mysql.py +22 -22
- mdbq/mysql/recheck_mysql.py +1 -1
- mdbq/spider/aikucun.py +2 -24
- {mdbq-3.3.4.dist-info → mdbq-3.3.7.dist-info}/METADATA +1 -1
- {mdbq-3.3.4.dist-info → mdbq-3.3.7.dist-info}/RECORD +9 -20
- mdbq/aggregation/df_types.py +0 -188
- mdbq/aggregation/mysql_types.py +0 -240
- mdbq/clean/__init__.py +0 -4
- mdbq/clean/clean_upload.py +0 -1350
- mdbq/clean/data_clean.py +0 -1551
- mdbq/company/__init__.py +0 -4
- mdbq/company/copysh.py +0 -447
- mdbq/config/get_myconf.py +0 -131
- mdbq/config/update_conf.py +0 -102
- mdbq/req_post/__init__.py +0 -4
- mdbq/req_post/req_tb.py +0 -624
- {mdbq-3.3.4.dist-info → mdbq-3.3.7.dist-info}/WHEEL +0 -0
- {mdbq-3.3.4.dist-info → mdbq-3.3.7.dist-info}/top_level.txt +0 -0
mdbq/config/update_conf.py
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# -*- coding: UTF-8 –*-
|
2
|
-
import platform
|
3
|
-
import getpass
|
4
|
-
import configparser
|
5
|
-
import os
|
6
|
-
from urllib import parse
|
7
|
-
from mdbq.config import set_support
|
8
|
-
"""
|
9
|
-
文件被 copysh.py / all-datas.py 调用, update_config 函数
|
10
|
-
更新完成后修改 conf 中值为 True
|
11
|
-
"""
|
12
|
-
|
13
|
-
|
14
|
-
class UpdateConf:
|
15
|
-
"""
|
16
|
-
读取配置文件信息
|
17
|
-
"""
|
18
|
-
def __init__(self):
|
19
|
-
self.path = set_support.SetSupport(dirname='support').dirname
|
20
|
-
self.section = 'database' # 默认 文件头标记
|
21
|
-
self.filename = None
|
22
|
-
self.conf_file = None
|
23
|
-
self.config = None
|
24
|
-
|
25
|
-
def read_txt(self, filename, option=None):
|
26
|
-
self.filename = filename
|
27
|
-
self.conf_file = os.path.join(self.path, self.filename)
|
28
|
-
if not os.path.exists(self.conf_file):
|
29
|
-
print(f'缺少配置文件: {self.conf_file}')
|
30
|
-
return
|
31
|
-
with open(self.conf_file, 'r', encoding='utf-8') as f:
|
32
|
-
content = f.readlines()
|
33
|
-
content = [item.strip() for item in content if not item.strip().startswith('#') and not item.strip().startswith('[')]
|
34
|
-
pbix_list = [item for item in content if item]
|
35
|
-
return pbix_list # ['推广数据.pbix', '市场数据新.pbix']
|
36
|
-
|
37
|
-
def read_conf(self, filename, option=None):
|
38
|
-
self.filename = filename
|
39
|
-
self.conf_file = os.path.join(self.path, self.filename)
|
40
|
-
if not os.path.exists(self.conf_file):
|
41
|
-
print(f'缺少配置文件: {self.conf_file}')
|
42
|
-
return
|
43
|
-
self.config = configparser.ConfigParser()
|
44
|
-
self.config.read(self.conf_file, 'UTF-8')
|
45
|
-
if not option:
|
46
|
-
results = []
|
47
|
-
for option in self.config.options(self.section):
|
48
|
-
results.append({option: self.config.get(self.section, option)})
|
49
|
-
return results
|
50
|
-
else:
|
51
|
-
if option not in self.config.options(self.section):
|
52
|
-
print(f'不存在的配置项: {option},文件: {self.conf_file}')
|
53
|
-
else:
|
54
|
-
return self.config.get(self.section, option)
|
55
|
-
|
56
|
-
def update_config(self, filename, option, new_value):
|
57
|
-
"""
|
58
|
-
更新配置文件
|
59
|
-
copysh.py / all-datas.py 调用
|
60
|
-
"""
|
61
|
-
self.filename = filename
|
62
|
-
self.conf_file = os.path.join(self.path, self.filename)
|
63
|
-
with open(self.conf_file, 'r', encoding='utf-8') as file:
|
64
|
-
lines = file.readlines()
|
65
|
-
config = configparser.ConfigParser(allow_no_value=True) # 读取配置(不包括注释和空白行)
|
66
|
-
config.read_string(''.join(line for line in lines if not line.strip().startswith('#') and line.strip()))
|
67
|
-
in_section = False # 标记是否在当前section内
|
68
|
-
|
69
|
-
with open(self.conf_file, 'w', encoding='utf-8') as file: # 写入更新后的配置文件
|
70
|
-
for line in lines:
|
71
|
-
if line.strip().startswith('[') and line.strip().endswith(']'): # 检查是否是section的开始
|
72
|
-
section_name = line.strip()[1:-1]
|
73
|
-
if section_name == self.section:
|
74
|
-
in_section = True
|
75
|
-
file.write(line)
|
76
|
-
continue
|
77
|
-
if in_section and '=' in line: # 如果在section内,检查是否是配置项
|
78
|
-
option_name, _, _ = line.strip().partition('=')
|
79
|
-
if option_name.strip() == option:
|
80
|
-
file.write(f"{option} = {new_value}\n") # 更新配置项
|
81
|
-
continue
|
82
|
-
file.write(line) # 如果不是配置项或不在section内,则保留原样(包括注释和空白行)
|
83
|
-
|
84
|
-
if not config.has_option(self.section, option): # 如果配置项没有在当前section中找到,则添加它
|
85
|
-
for i, line in enumerate(lines): # 假设我们要在section的末尾添加配置项
|
86
|
-
if line.strip().startswith(f'[{self.section}]'):
|
87
|
-
file.write(f"{option} = {new_value}\n") # 写入配置项到section之后
|
88
|
-
break
|
89
|
-
else:
|
90
|
-
# 如果section不存在,则在文件末尾添加新的section和配置项
|
91
|
-
file.write(f"\n[{self.section}]\n{option} = {new_value}\n")
|
92
|
-
|
93
|
-
|
94
|
-
def main():
|
95
|
-
pass
|
96
|
-
|
97
|
-
|
98
|
-
if __name__ == '__main__':
|
99
|
-
w = UpdateConf()
|
100
|
-
# w.update_config(filename='.copysh_conf', option='ch_record', new_value='false')
|
101
|
-
res = w.read_txt(filename='tb_list.txt')
|
102
|
-
print(res)
|
mdbq/req_post/__init__.py
DELETED