iup 0.1__py3-none-any.whl → 0.3__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.
iup/__init__.py CHANGED
@@ -0,0 +1,5 @@
1
+ import importlib_metadata
2
+
3
+ metadata = importlib_metadata.metadata("iup")
4
+
5
+ __version__ = metadata['version']
iup/config.py CHANGED
@@ -36,13 +36,12 @@ class Config:
36
36
  if k.startswith('cm'):
37
37
  pass
38
38
  else:
39
- parser['common'].update({k: str(v)})
39
+ parser[SECTION_COMMON].update({k: str(v)})
40
40
  return parser
41
41
 
42
- @staticmethod
43
- def write_config(config: configparser.ConfigParser, path):
42
+ def save_to(self, path):
44
43
  with open(path, 'w', encoding='utf-8') as f:
45
- config.write(f)
44
+ self.parser.write(f)
46
45
 
47
46
  def __update(self, path):
48
47
  variables = vars(self)
iup/main.py CHANGED
@@ -4,6 +4,7 @@ import argparse
4
4
  from os import path
5
5
  import re
6
6
  import paramiko
7
+ import iup
7
8
  from iup.config import Config
8
9
  import ipaddress
9
10
 
@@ -20,14 +21,14 @@ def is_domain_name(string: str):
20
21
  return True
21
22
  else:
22
23
  return False
23
-
24
+
24
25
  def is_ip_address(ip_str: str):
25
26
  try:
26
27
  ip = ipaddress.ip_address(ip_str)
27
28
  return ip is not None
28
29
  except ValueError:
29
30
  return False
30
-
31
+
31
32
  def parse_host_name(hostname_str: str):
32
33
  if is_domain_name(hostname_str) or is_ip_address(hostname_str):
33
34
  return hostname_str
@@ -64,6 +65,11 @@ def load_and_overlay_config() -> Config:
64
65
  parser = argparse.ArgumentParser(description='参数说明')
65
66
  parser.add_argument("-nr", "--no_refresh", action='store_true', default=False, help="是否刷新")
66
67
  parser.add_argument("sources", nargs='+', help='域名或者域名文件路径')
68
+ parser.add_argument(
69
+ "--version",
70
+ action="version",
71
+ version=f"%(prog)s version {iup.__version__} installed in {path.dirname(__file__)}",
72
+ )
67
73
  args = parser.parse_args()
68
74
  config_path = path.join(path.dirname(__file__), 'config.ini')
69
75
  if not path.exists(config_path):
@@ -151,7 +157,7 @@ def gen_config():
151
157
  config = Config()
152
158
  config.update(host, port, username, password, refresh)
153
159
  config_path = path.join(path.dirname(__file__), 'config.ini')
154
- Config.write_config(config.parser, config_path)
160
+ config.save_to(config_path)
155
161
  print('已生成配置文件写入到{}'.format(config_path))
156
162
 
157
163
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iup
3
- Version: 0.1
3
+ Version: 0.3
4
4
  Summary: ipset updater for openwrt
5
5
  Author: nobitaqaq
6
6
  Author-email: xiaoleigs@gmail.com
@@ -0,0 +1,9 @@
1
+ iup/__init__.py,sha256=WXPOI9BwESIVzJ-XhG7bIFhsRg98u_v5gp16nY0bcbI,108
2
+ iup/config.py,sha256=Ecg9m83D_Cp_inYrltt--oPcupVvCw9oo8m5ukKyWLA,2862
3
+ iup/default_config.py,sha256=JsNdlf_Imsa8KYlrI7A38fgBCDvn9zTZMotMK2kd0CQ,433
4
+ iup/main.py,sha256=j7-6cFrI6_RFkWR-Y4_LChs3fBVb1JGKQ8aW_w_9kMk,5508
5
+ iup-0.3.dist-info/METADATA,sha256=C50LOOcCcyhAeTMUSei_oImuxkL2h5yCvz2jLV2ScSs,204
6
+ iup-0.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
7
+ iup-0.3.dist-info/entry_points.txt,sha256=ER1eUBmB6bXwudHBT51NoOtDSlnUgBi4T6J9_kA4pwc,68
8
+ iup-0.3.dist-info/top_level.txt,sha256=abec3YOzJRti4IxzOLIn-uDOPTtYUE-Uv65cAv1v8JY,4
9
+ iup-0.3.dist-info/RECORD,,
@@ -1,3 +1,3 @@
1
1
  [console_scripts]
2
2
  iup = iup.main:main
3
- iup-gen = iup.main:gen_config
3
+ iup-cfg = iup.main:gen_config
iup-0.1.dist-info/RECORD DELETED
@@ -1,9 +0,0 @@
1
- iup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- iup/config.py,sha256=iBD6DQakavEYpGRWsRW0YSWxq0HTYMH8j1EwqneMCcc,2903
3
- iup/default_config.py,sha256=JsNdlf_Imsa8KYlrI7A38fgBCDvn9zTZMotMK2kd0CQ,433
4
- iup/main.py,sha256=UwOA1ohFaEJDEXrpQp4yf4AjdlD-YrTq6LxCl3dN8_0,5354
5
- iup-0.1.dist-info/METADATA,sha256=BYXIC9Nr6cwlVQN-j3_vuERNK2Rx44bDkVhUGovWCuU,204
6
- iup-0.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
7
- iup-0.1.dist-info/entry_points.txt,sha256=iFwUViv-61zd2U9zbkFf7StoZhmZ7SdY4mHAN8PNJT0,68
8
- iup-0.1.dist-info/top_level.txt,sha256=abec3YOzJRti4IxzOLIn-uDOPTtYUE-Uv65cAv1v8JY,4
9
- iup-0.1.dist-info/RECORD,,
File without changes
File without changes