dazzle-filekit 0.1.0__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.
@@ -0,0 +1,164 @@
1
+ """
2
+ dazzle_filekit - A general-purpose file manipulation library.
3
+
4
+ This package provides utilities for file operations, path handling, and verification
5
+ across different platforms, with a focus on preserving file metadata.
6
+ """
7
+
8
+ import os
9
+ import sys
10
+ import logging
11
+ from pathlib import Path
12
+
13
+ # Setup package-level logging
14
+ logger = logging.getLogger(__name__)
15
+ logger.setLevel(logging.INFO)
16
+
17
+ # Create console handler if not already present
18
+ if not logger.handlers:
19
+ console_handler = logging.StreamHandler()
20
+ console_handler.setFormatter(
21
+ logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
22
+ )
23
+ logger.addHandler(console_handler)
24
+
25
+ # Import core functionality
26
+ from .paths import (
27
+ normalize_path,
28
+ is_same_file,
29
+ split_drive_letter,
30
+ is_unc_path,
31
+ get_relative_path,
32
+ create_dest_path,
33
+ find_files,
34
+ find_regex_files,
35
+ collect_files_from_include_file,
36
+ create_parent_dirs,
37
+ ensure_unique_path,
38
+ get_path_type
39
+ )
40
+
41
+ from .operations import (
42
+ copy_file,
43
+ move_file,
44
+ collect_file_metadata,
45
+ apply_file_metadata,
46
+ copy_files_with_path,
47
+ move_files_with_path,
48
+ create_directory_structure,
49
+ remove_file,
50
+ remove_directory
51
+ )
52
+
53
+ from .verification import (
54
+ calculate_file_hash,
55
+ verify_file_hash,
56
+ verify_files_with_manifest,
57
+ calculate_directory_hashes,
58
+ save_hashes_to_file,
59
+ load_hashes_from_file,
60
+ compare_directories,
61
+ verify_copied_files
62
+ )
63
+
64
+ __version__ = '0.1.0'
65
+
66
+ def configure_logging(level=logging.INFO, log_file=None):
67
+ """
68
+ Configure logging for dazzle_filekit.
69
+
70
+ Args:
71
+ level: Logging level
72
+ log_file: Optional path to log file
73
+ """
74
+ logger.setLevel(level)
75
+
76
+ # Clear existing handlers
77
+ for handler in logger.handlers[:]:
78
+ logger.removeHandler(handler)
79
+
80
+ # Add console handler
81
+ console_handler = logging.StreamHandler()
82
+ console_handler.setFormatter(
83
+ logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
84
+ )
85
+ logger.addHandler(console_handler)
86
+
87
+ # Add file handler if specified
88
+ if log_file:
89
+ file_handler = logging.FileHandler(log_file)
90
+ file_handler.setFormatter(
91
+ logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
92
+ )
93
+ logger.addHandler(file_handler)
94
+
95
+ logger.debug(f"Logging configured with level {level}")
96
+
97
+ def enable_verbose_logging():
98
+ """Enable verbose (debug) logging."""
99
+ configure_logging(logging.DEBUG)
100
+
101
+ # Platform-specific functions can be imported conditionally
102
+ if sys.platform == 'win32':
103
+ pass
104
+ # Windows-specific functions
105
+ # try:
106
+ # from .platform.windows import (
107
+ # Import Windows-specific functions when implemented
108
+ # )
109
+ # except ImportError:
110
+ # logger.debug("Windows-specific functions not available")
111
+ else:
112
+ pass
113
+ # Unix-specific functions
114
+ # try:
115
+ # from .platform.unix import (
116
+ # Import Unix-specific functions when implemented
117
+ # )
118
+ # except ImportError:
119
+ # logger.debug("Unix-specific functions not available")
120
+
121
+ # __all__ defines the public API
122
+ __all__ = [
123
+ # Version
124
+ '__version__',
125
+
126
+ # Logging functions
127
+ 'configure_logging',
128
+ 'enable_verbose_logging',
129
+
130
+ # Path functions
131
+ 'normalize_path',
132
+ 'is_same_file',
133
+ 'split_drive_letter',
134
+ 'is_unc_path',
135
+ 'get_relative_path',
136
+ 'create_dest_path',
137
+ 'find_files',
138
+ 'find_regex_files',
139
+ 'collect_files_from_include_file',
140
+ 'create_parent_dirs',
141
+ 'ensure_unique_path',
142
+ 'get_path_type',
143
+
144
+ # Operation functions
145
+ 'copy_file',
146
+ 'move_file',
147
+ 'collect_file_metadata',
148
+ 'apply_file_metadata',
149
+ 'copy_files_with_path',
150
+ 'move_files_with_path',
151
+ 'create_directory_structure',
152
+ 'remove_file',
153
+ 'remove_directory',
154
+
155
+ # Verification functions
156
+ 'calculate_file_hash',
157
+ 'verify_file_hash',
158
+ 'verify_files_with_manifest',
159
+ 'calculate_directory_hashes',
160
+ 'save_hashes_to_file',
161
+ 'load_hashes_from_file',
162
+ 'compare_directories',
163
+ 'verify_copied_files'
164
+ ]