ezKit 2.0.22__tar.gz → 2.0.23__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ezKit
3
- Version: 2.0.22
3
+ Version: 2.0.23
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -437,3 +437,46 @@ def check_file_type(file_object: str, file_type: str) -> bool:
437
437
  logger.error(e)
438
438
 
439
439
  return False
440
+
441
+
442
+ # --------------------------------------------------------------------------------------------------
443
+
444
+
445
+ def resolve_path(
446
+ path: str,
447
+ *,
448
+ parents: int = 0,
449
+ **kwargs,
450
+ ) -> str | None:
451
+ """
452
+ 获取路径的真实路径或其父目录
453
+
454
+ :param path: 原始路径
455
+ :param parents: 向上取多少层父目录
456
+ 0 = 当前路径
457
+ 1 = 所在目录
458
+ 2 = 父目录的父目录
459
+ """
460
+ try:
461
+
462
+ if not isTrue(path, str):
463
+ return None
464
+
465
+ p = Path(path, **kwargs)
466
+
467
+ for _ in range(parents):
468
+ p = p.parent
469
+
470
+ return str(p.resolve())
471
+
472
+ except Exception as e:
473
+
474
+ if DEBUG:
475
+ logger.exception(e)
476
+ else:
477
+ logger.error(e)
478
+
479
+ return None
480
+
481
+
482
+ # --------------------------------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ezKit
3
- Version: 2.0.22
3
+ Version: 2.0.23
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
4
4
 
5
5
  setup(
6
6
  name="ezKit",
7
- version="2.0.22",
7
+ version="2.0.23",
8
8
  author="septvean",
9
9
  author_email="septvean@gmail.com",
10
10
  description="Easy Kit",
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