pylhb 0.2.0__tar.gz → 0.2.1__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.
- {pylhb-0.2.0 → pylhb-0.2.1}/PKG-INFO +14 -1
- {pylhb-0.2.0 → pylhb-0.2.1}/README.md +13 -0
- {pylhb-0.2.0 → pylhb-0.2.1}/pyproject.toml +1 -1
- pylhb-0.2.1/src/pylhb/myconfig.py +37 -0
- {pylhb-0.2.0 → pylhb-0.2.1}/src/pylhb/myodbc.py +1 -1
- {pylhb-0.2.0 → pylhb-0.2.1}/LICENSE +0 -0
- {pylhb-0.2.0 → pylhb-0.2.1}/src/pylhb/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pylhb
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Mr.Lee's Helpers
|
|
5
5
|
License: Non-Commercial Use License
|
|
6
6
|
|
|
@@ -109,3 +109,16 @@ if __name__ == "__main__":
|
|
|
109
109
|
# 关闭
|
|
110
110
|
mssql.close()
|
|
111
111
|
```
|
|
112
|
+
|
|
113
|
+
## 🌺myconfig
|
|
114
|
+
|
|
115
|
+
通过configparser读取配置文件。
|
|
116
|
+
|
|
117
|
+
使用示例:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
config = MyConfig("config.ini")
|
|
122
|
+
config.set("main", "host", "127.0.0.1")
|
|
123
|
+
print(config.get("main", "host"))
|
|
124
|
+
```
|
|
@@ -76,3 +76,16 @@ if __name__ == "__main__":
|
|
|
76
76
|
# 关闭
|
|
77
77
|
mssql.close()
|
|
78
78
|
```
|
|
79
|
+
|
|
80
|
+
## 🌺myconfig
|
|
81
|
+
|
|
82
|
+
通过configparser读取配置文件。
|
|
83
|
+
|
|
84
|
+
使用示例:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
config = MyConfig("config.ini")
|
|
89
|
+
config.set("main", "host", "127.0.0.1")
|
|
90
|
+
print(config.get("main", "host"))
|
|
91
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
模块:myconfig
|
|
3
|
+
作者:李生
|
|
4
|
+
"""
|
|
5
|
+
import configparser
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
class MyConfig:
|
|
9
|
+
def __init__(self, configFile="config.ini"):
|
|
10
|
+
self.configFile = configFile
|
|
11
|
+
if not os.path.exists(self.configFile):
|
|
12
|
+
with open(self.configFile, 'w', encoding='gb2312') as f:
|
|
13
|
+
f.write("[main]\n")
|
|
14
|
+
self.cf = configparser.ConfigParser()
|
|
15
|
+
self.cf.read(self.configFile, encoding='gb2312')
|
|
16
|
+
|
|
17
|
+
# 获取节点值
|
|
18
|
+
def get(self, section, option,defaultValue=""):
|
|
19
|
+
if self.cf.has_section(section) and self.cf.has_option(section, option):
|
|
20
|
+
return self.cf.get(section, option)
|
|
21
|
+
return defaultValue
|
|
22
|
+
|
|
23
|
+
# 设置节点值
|
|
24
|
+
def set(self, section, option, value):
|
|
25
|
+
if self.cf.has_section(section) is False:
|
|
26
|
+
self.cf.add_section(section)
|
|
27
|
+
self.cf.set(section, option, value)
|
|
28
|
+
with open(self.configFile, 'w', encoding='gb2312') as f:
|
|
29
|
+
self.cf.write(f)
|
|
30
|
+
|
|
31
|
+
# 删除节点
|
|
32
|
+
def remove(self, section, option):
|
|
33
|
+
self.cf.remove_option(section, option)
|
|
34
|
+
with open(self.configFile, 'w', encoding='gb2312') as f:
|
|
35
|
+
self.cf.write(f)
|
|
36
|
+
|
|
37
|
+
|
|
File without changes
|
|
File without changes
|