mdbq 4.0.26__py3-none-any.whl → 4.0.27__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/__version__.py +1 -1
- mdbq/myconf/myconf.py +40 -22
- {mdbq-4.0.26.dist-info → mdbq-4.0.27.dist-info}/METADATA +1 -1
- {mdbq-4.0.26.dist-info → mdbq-4.0.27.dist-info}/RECORD +6 -6
- {mdbq-4.0.26.dist-info → mdbq-4.0.27.dist-info}/WHEEL +0 -0
- {mdbq-4.0.26.dist-info → mdbq-4.0.27.dist-info}/top_level.txt +0 -0
mdbq/__version__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = '4.0.
|
1
|
+
VERSION = '4.0.27'
|
mdbq/myconf/myconf.py
CHANGED
@@ -408,49 +408,63 @@ class ConfigParser:
|
|
408
408
|
if file_path is None:
|
409
409
|
self._ensure_file_open()
|
410
410
|
file_path = self._current_file
|
411
|
+
else:
|
412
|
+
file_path = Path(file_path)
|
413
|
+
|
411
414
|
if not self._validate_key(key):
|
412
415
|
raise ConfigException.invalid_key_error(key, file_path, section)
|
416
|
+
|
413
417
|
section = section or self.options.default_section
|
414
418
|
original_lines = []
|
415
|
-
|
416
|
-
with open(file_path, 'r', encoding=self.options.encoding) as file:
|
417
|
-
original_lines = file.readlines()
|
418
|
-
config = self.read(file_path)
|
419
|
-
if section not in config:
|
420
|
-
config[section] = {}
|
421
|
-
if value_type is not None:
|
422
|
-
try:
|
423
|
-
if value_type == bool:
|
424
|
-
if isinstance(value, str):
|
425
|
-
value = value.lower() in ('true', 'yes', '1', 'on')
|
426
|
-
else:
|
427
|
-
value = bool(value)
|
428
|
-
else:
|
429
|
-
value = value_type(value)
|
430
|
-
except (ValueError, TypeError) as e:
|
431
|
-
raise ConfigException.conversion_error(value, value_type, file_path, section=section, key=key)
|
432
|
-
if isinstance(value, bool):
|
433
|
-
value = str(value).lower()
|
434
|
-
else:
|
435
|
-
value = str(value)
|
436
|
-
config[section][key] = value
|
419
|
+
|
437
420
|
try:
|
421
|
+
if file_path.exists():
|
422
|
+
with open(file_path, 'r', encoding=self.options.encoding) as file:
|
423
|
+
original_lines = file.readlines()
|
424
|
+
|
425
|
+
config = self.read(file_path)
|
426
|
+
if section not in config:
|
427
|
+
config[section] = {}
|
428
|
+
|
429
|
+
if value_type is not None:
|
430
|
+
try:
|
431
|
+
if value_type == bool:
|
432
|
+
if isinstance(value, str):
|
433
|
+
value = value.lower() in ('true', 'yes', '1', 'on')
|
434
|
+
else:
|
435
|
+
value = bool(value)
|
436
|
+
else:
|
437
|
+
value = value_type(value)
|
438
|
+
except (ValueError, TypeError) as e:
|
439
|
+
raise ConfigException.conversion_error(value, value_type, file_path, section=section, key=key)
|
440
|
+
|
441
|
+
if isinstance(value, bool):
|
442
|
+
value = str(value).lower()
|
443
|
+
else:
|
444
|
+
value = str(value)
|
445
|
+
|
446
|
+
config[section][key] = value
|
447
|
+
|
438
448
|
file_path.parent.mkdir(parents=True, exist_ok=True)
|
439
449
|
with open(file_path, 'w', encoding=self.options.encoding) as file:
|
440
450
|
current_section = self.options.default_section
|
441
451
|
section_separators = {}
|
452
|
+
|
442
453
|
for line in original_lines:
|
443
454
|
stripped_line = line.strip()
|
444
455
|
if not stripped_line:
|
445
456
|
file.write(line)
|
446
457
|
continue
|
458
|
+
|
447
459
|
if stripped_line.startswith('[') and stripped_line.endswith(']'):
|
448
460
|
current_section = stripped_line[1:-1]
|
449
461
|
file.write(line)
|
450
462
|
continue
|
463
|
+
|
451
464
|
if self._is_comment_line(stripped_line):
|
452
465
|
file.write(line)
|
453
466
|
continue
|
467
|
+
|
454
468
|
key_value = self._split_key_value(stripped_line)
|
455
469
|
if key_value:
|
456
470
|
orig_key, orig_value = key_value
|
@@ -458,6 +472,7 @@ class ConfigParser:
|
|
458
472
|
if sep in line:
|
459
473
|
section_separators.setdefault(current_section, {})[orig_key] = sep
|
460
474
|
break
|
475
|
+
|
461
476
|
if current_section == section and orig_key == key:
|
462
477
|
separator = section_separators.get(current_section, {}).get(orig_key, self.options.separators[0])
|
463
478
|
comment = ''
|
@@ -471,10 +486,13 @@ class ConfigParser:
|
|
471
486
|
file.write(line)
|
472
487
|
else:
|
473
488
|
file.write(line)
|
489
|
+
|
474
490
|
if section not in [line.strip()[1:-1] for line in original_lines if line.strip().startswith('[') and line.strip().endswith(']')]:
|
475
491
|
file.write(f'\n[{section}]\n')
|
476
492
|
file.write(f'{key}={value}\n')
|
493
|
+
|
477
494
|
self._clear_cache(str(file_path))
|
495
|
+
|
478
496
|
except Exception as e:
|
479
497
|
raise ConfigException.write_error(file_path, e)
|
480
498
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
mdbq/__init__.py,sha256=Il5Q9ATdX8yXqVxtP_nYqUhExzxPC_qk_WXQ_4h0exg,16
|
2
|
-
mdbq/__version__.py,sha256=
|
2
|
+
mdbq/__version__.py,sha256=BLG9qI65B4G2SR9uwnNZDJXbyRfkGwa15Y-2HC-0wj4,18
|
3
3
|
mdbq/aggregation/__init__.py,sha256=EeDqX2Aml6SPx8363J-v1lz0EcZtgwIBYyCJV6CcEDU,40
|
4
4
|
mdbq/aggregation/query_data.py,sha256=3lvLLy1sEn5ctf4FRacFvWF-J3isK5siOSItGXmCCrg,166877
|
5
5
|
mdbq/log/__init__.py,sha256=Mpbrav0s0ifLL7lVDAuePEi1hJKiSHhxcv1byBKDl5E,15
|
6
6
|
mdbq/log/mylogger.py,sha256=9w_o5mYB3FooIxobq_lSa6oCYTKIhPxDFox-jeLtUHI,21714
|
7
7
|
mdbq/myconf/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
8
|
-
mdbq/myconf/myconf.py,sha256=
|
8
|
+
mdbq/myconf/myconf.py,sha256=GR250mf2KKImRUamPM2TEi9no_65tR4uKXn7eHNCAmg,31205
|
9
9
|
mdbq/myconf/myconf_bak.py,sha256=39tLUBVlWQZzQfrwk7YoLEfipo11fpwWjaLBHcUt2qM,33341
|
10
10
|
mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
|
11
11
|
mdbq/mysql/deduplicator.py,sha256=kAnkI_vnN8CchgDQAFzeh0M0vLXE2oWq9SfDPNZZ3v0,73215
|
@@ -25,7 +25,7 @@ mdbq/redis/__init__.py,sha256=YtgBlVSMDphtpwYX248wGge1x-Ex_mMufz4-8W0XRmA,12
|
|
25
25
|
mdbq/redis/getredis.py,sha256=vpBuNc22uj9Vr-_Dh25_wpwWM1e-072EAAIBdB_IpL0,23494
|
26
26
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
27
27
|
mdbq/spider/aikucun.py,sha256=juOqpr_dHeE1RyjCu67VcpzoJAWMO7FKv0i8KiH8WUo,21552
|
28
|
-
mdbq-4.0.
|
29
|
-
mdbq-4.0.
|
30
|
-
mdbq-4.0.
|
31
|
-
mdbq-4.0.
|
28
|
+
mdbq-4.0.27.dist-info/METADATA,sha256=ho97HRTp4AqSe_HLBpN_L7b6MkBHmrNOqdggrG8CRwg,364
|
29
|
+
mdbq-4.0.27.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
30
|
+
mdbq-4.0.27.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
31
|
+
mdbq-4.0.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|