lyrpy 1.0.0__py3-none-any.whl → 2024.0.2__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.
Potentially problematic release.
This version of lyrpy might be problematic. Click here for more details.
- {SRC/LIB/lyrpy → lyr}/LUConsole.py +1 -1
- lyr/LUConst.py +45 -0
- {SRC/LIB/lyrpy → lyr}/LUDateTime.py +4 -2
- {SRC/LIB/lyrpy → lyr}/LUDecotators.py +3 -2
- {SRC/LIB/lyrpy → lyr}/LUDict.py +1 -0
- {SRC/LIB/lyrpy → lyr}/LUDoc.py +4 -5
- {SRC/LIB/lyrpy → lyr}/LUErrors.py +1 -0
- {SRC/LIB/lyrpy → lyr}/LUFile.py +66 -120
- {SRC/LIB/lyrpy → lyr}/LUFileUtils.py +45 -60
- {SRC/LIB/lyrpy → lyr}/LULog.py +232 -307
- {SRC/LIB/lyrpy → lyr}/LUObjects.py +4 -4
- {SRC/LIB/lyrpy → lyr}/LUObjectsYT.py +22 -39
- {SRC/LIB/lyrpy → lyr}/LUParserARG.py +3 -2
- {SRC/LIB/lyrpy → lyr}/LUParserINI.py +9 -14
- {SRC/LIB/lyrpy → lyr}/LUParserREG.py +1 -5
- {SRC/LIB/lyrpy → lyr}/LUQThread.py +4 -6
- {SRC/LIB/lyrpy → lyr}/LUQTimer.py +5 -5
- {SRC/LIB/lyrpy → lyr}/LUSheduler.py +23 -24
- {SRC/LIB/lyrpy → lyr}/LUThread.py +6 -7
- {SRC/LIB/lyrpy → lyr}/LUTimer.py +3 -5
- {SRC/LIB/lyrpy → lyr}/LUVersion.py +1 -4
- {SRC/LIB/lyrpy → lyr}/LUYouTube.py +7 -6
- {SRC/LIB/lyrpy → lyr}/LUos.py +5 -15
- {SRC/LIB/lyrpy → lyr}/__init__.py +2 -2
- {SRC/LIB/lyrpy → lyr}/__main__.py +19 -20
- lyrpy-2024.0.2.data/data/data/text.txt +1 -0
- lyrpy-2024.0.2.dist-info/METADATA +44 -0
- lyrpy-2024.0.2.dist-info/RECORD +38 -0
- {lyrpy-1.0.0.dist-info → lyrpy-2024.0.2.dist-info}/WHEEL +1 -1
- lyrpy-2024.0.2.dist-info/top_level.txt +1 -0
- SRC/LIB/__init__.py +0 -0
- SRC/LIB/lyrpy/LUConst.py +0 -358
- SRC/LIB/lyrpy/LUTelegram.py +0 -428
- SRC/__init__.py +0 -0
- TESTS/__init__.py +0 -0
- TESTS/test_main.py +0 -10
- lyrpy-1.0.0.dist-info/METADATA +0 -24
- lyrpy-1.0.0.dist-info/RECORD +0 -42
- lyrpy-1.0.0.dist-info/top_level.txt +0 -2
- {SRC/LIB/lyrpy → lyr}/LUNetwork.py +0 -0
- {SRC/LIB/lyrpy → lyr}/LUNumUtils.py +0 -0
- {SRC/LIB/lyrpy → lyr}/LUProc.py +0 -0
- {SRC/LIB/lyrpy → lyr}/LUStrDecode.py +0 -0
- {SRC/LIB/lyrpy → lyr}/LUStrUtils.py +0 -0
- {SRC/LIB/lyrpy → lyr}/LUSupport.py +0 -0
- {SRC/LIB/lyrpy → lyr}/LUsys.py +0 -0
- {lyrpy-1.0.0.dist-info/licenses → lyrpy-2024.0.2.dist-info}/LICENSE +0 -0
|
@@ -28,7 +28,7 @@ from colorama import Fore, Back, Style
|
|
|
28
28
|
#------------------------------------------
|
|
29
29
|
# БИБЛИОТЕКИ LU
|
|
30
30
|
#------------------------------------------
|
|
31
|
-
import
|
|
31
|
+
import lyr.LUSupport as LUSupport
|
|
32
32
|
|
|
33
33
|
#------------------------------------------
|
|
34
34
|
# CONST
|
lyr/LUConst.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""LUConst.py"""
|
|
2
|
+
# -*- coding: UTF-8 -*-
|
|
3
|
+
__annotations__ = """
|
|
4
|
+
=======================================================
|
|
5
|
+
Copyright (c) 2023-2024
|
|
6
|
+
Author:
|
|
7
|
+
Lisitsin Y.R.
|
|
8
|
+
Project:
|
|
9
|
+
LU_PY
|
|
10
|
+
Python (LU)
|
|
11
|
+
Module:
|
|
12
|
+
LUConst.py
|
|
13
|
+
|
|
14
|
+
=======================================================
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
#------------------------------------------
|
|
18
|
+
# БИБЛИОТЕКИ python
|
|
19
|
+
#------------------------------------------
|
|
20
|
+
|
|
21
|
+
#------------------------------------------
|
|
22
|
+
# БИБЛИОТЕКИ сторонние
|
|
23
|
+
#------------------------------------------
|
|
24
|
+
|
|
25
|
+
#------------------------------------------
|
|
26
|
+
# БИБЛИОТЕКИ LU
|
|
27
|
+
#------------------------------------------
|
|
28
|
+
|
|
29
|
+
#-------------------------------------------------------------------------------
|
|
30
|
+
#
|
|
31
|
+
#-------------------------------------------------------------------------------
|
|
32
|
+
def main ():
|
|
33
|
+
#beginfunction
|
|
34
|
+
print('main LUConst.py ...')
|
|
35
|
+
#endfunction
|
|
36
|
+
|
|
37
|
+
#------------------------------------------
|
|
38
|
+
#
|
|
39
|
+
#------------------------------------------
|
|
40
|
+
#beginmodule
|
|
41
|
+
if __name__ == "__main__":
|
|
42
|
+
main()
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#endmodule
|
|
@@ -18,7 +18,9 @@ __annotations__ = """
|
|
|
18
18
|
# БИБЛИОТЕКИ python
|
|
19
19
|
#------------------------------------------
|
|
20
20
|
import datetime
|
|
21
|
+
import time
|
|
21
22
|
import calendar
|
|
23
|
+
import logging
|
|
22
24
|
import platform
|
|
23
25
|
|
|
24
26
|
#------------------------------------------
|
|
@@ -28,7 +30,7 @@ import platform
|
|
|
28
30
|
#------------------------------------------
|
|
29
31
|
# БИБЛИОТЕКИ LU
|
|
30
32
|
#------------------------------------------
|
|
31
|
-
import
|
|
33
|
+
import lyr.LUSupport as LUSupport
|
|
32
34
|
|
|
33
35
|
#------------------------------------------
|
|
34
36
|
# CONST
|
|
@@ -150,7 +152,7 @@ def DayOfWeek (ADateTime: datetime.date):
|
|
|
150
152
|
def DaysInMonth (AYear: int, AMonth: int):
|
|
151
153
|
"""DaysInMonth"""
|
|
152
154
|
#beginfunction
|
|
153
|
-
return
|
|
155
|
+
return monthrange (AYear, AMonth) [1]
|
|
154
156
|
#endfunction
|
|
155
157
|
|
|
156
158
|
#---------------------------------------------------------------
|
|
@@ -18,6 +18,7 @@ __annotations__ = """
|
|
|
18
18
|
# БИБЛИОТЕКИ python
|
|
19
19
|
#------------------------------------------
|
|
20
20
|
import time
|
|
21
|
+
import logging
|
|
21
22
|
from functools import wraps
|
|
22
23
|
import smtplib
|
|
23
24
|
import traceback
|
|
@@ -30,7 +31,7 @@ from email.mime.text import MIMEText
|
|
|
30
31
|
#------------------------------------------
|
|
31
32
|
# БИБЛИОТЕКИ LU
|
|
32
33
|
#------------------------------------------
|
|
33
|
-
import
|
|
34
|
+
import lyr.LULog as LULog
|
|
34
35
|
|
|
35
36
|
#---------------------------------------------------------------
|
|
36
37
|
# TIMING
|
|
@@ -44,7 +45,7 @@ def TIMING(func):
|
|
|
44
45
|
result = func(*args, **kwargs)
|
|
45
46
|
end_time = time.time()
|
|
46
47
|
s = f"Функция {func.__name__} работала {end_time - start_time} секунд..."
|
|
47
|
-
LULog.
|
|
48
|
+
LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
48
49
|
return result
|
|
49
50
|
#endfunction
|
|
50
51
|
|
{SRC/LIB/lyrpy → lyr}/LUDict.py
RENAMED
{SRC/LIB/lyrpy → lyr}/LUDoc.py
RENAMED
|
@@ -17,7 +17,7 @@ __annotations__ = """
|
|
|
17
17
|
#------------------------------------------
|
|
18
18
|
# БИБЛИОТЕКИ python
|
|
19
19
|
#------------------------------------------
|
|
20
|
-
|
|
20
|
+
import sys
|
|
21
21
|
|
|
22
22
|
#------------------------------------------
|
|
23
23
|
# БИБЛИОТЕКИ сторонние
|
|
@@ -26,7 +26,7 @@ __annotations__ = """
|
|
|
26
26
|
#------------------------------------------
|
|
27
27
|
# БИБЛИОТЕКИ LU
|
|
28
28
|
#------------------------------------------
|
|
29
|
-
import
|
|
29
|
+
import lyr.LULog as LULog
|
|
30
30
|
|
|
31
31
|
#---------------------------------------------------------------
|
|
32
32
|
# PrintInfoObject
|
|
@@ -38,8 +38,8 @@ def PrintInfoObject (AObject):
|
|
|
38
38
|
# print (inspect.stack () [0] [3], '...')
|
|
39
39
|
# print (traceback.extract_stack () [-1].name, '...')
|
|
40
40
|
s = f'{AObject}'
|
|
41
|
-
#
|
|
42
|
-
|
|
41
|
+
#LULog_LoggerTOOLS_log(LULog.DEBUGTEXT, s)
|
|
42
|
+
LULog.LoggerTOOLS_AddLevel(LULog.DEBUGTEXT, s)
|
|
43
43
|
#endfunction
|
|
44
44
|
|
|
45
45
|
#---------------------------------------------------------------
|
|
@@ -48,7 +48,6 @@ def PrintInfoObject (AObject):
|
|
|
48
48
|
def main ():
|
|
49
49
|
#beginfunction
|
|
50
50
|
print('main LUDoc.py...')
|
|
51
|
-
...
|
|
52
51
|
#endfunction
|
|
53
52
|
|
|
54
53
|
#------------------------------------------
|
{SRC/LIB/lyrpy → lyr}/LUFile.py
RENAMED
|
@@ -14,7 +14,6 @@ __annotations__ = """
|
|
|
14
14
|
=======================================================
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
-
import errno
|
|
18
17
|
#------------------------------------------
|
|
19
18
|
# БИБЛИОТЕКИ python
|
|
20
19
|
#------------------------------------------
|
|
@@ -47,12 +46,11 @@ import chardet
|
|
|
47
46
|
#------------------------------------------
|
|
48
47
|
# БИБЛИОТЕКА LU
|
|
49
48
|
#------------------------------------------
|
|
50
|
-
import
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
# import lyrpy.LUFile as LUFile
|
|
49
|
+
import lyr.LUErrors as LUErrors
|
|
50
|
+
import lyr.LUStrDecode as LUStrDecode
|
|
51
|
+
import lyr.LUDateTime as LUDateTime
|
|
52
|
+
import lyr.LUos as LUos
|
|
53
|
+
import lyr.LULog as LULog
|
|
56
54
|
|
|
57
55
|
"""
|
|
58
56
|
#--------------------------------------------------------------------------------
|
|
@@ -80,8 +78,7 @@ ab+ Откроет для добавления нового содержимог
|
|
|
80
78
|
#--------------------------------------------------------------------------------
|
|
81
79
|
"""
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
cDefaultEncoding = 'utf-8'
|
|
81
|
+
cDefaultEncoding = 'cp1251'
|
|
85
82
|
|
|
86
83
|
#--------------------------------------------------------------------------------
|
|
87
84
|
# DirectoryExists
|
|
@@ -102,8 +99,7 @@ def ForceDirectories (ADir: str) -> bool:
|
|
|
102
99
|
os.makedirs (ADir, exist_ok = True)
|
|
103
100
|
except:
|
|
104
101
|
s = f'Unable to create directory {ADir:s} ...'
|
|
105
|
-
|
|
106
|
-
LULog.LoggerAdd(LULog.LoggerTOOLS, logging.error, s)
|
|
102
|
+
LULog.LoggerTOOLS_AddLevel(logging.error, s)
|
|
107
103
|
#endtry
|
|
108
104
|
LResult = DirectoryExists (ADir)
|
|
109
105
|
return LResult
|
|
@@ -138,9 +134,8 @@ def DeleteDirectoryTree (ADir: str) -> bool:
|
|
|
138
134
|
def remove_readonly (func, path, _):
|
|
139
135
|
"""remove_readonly"""
|
|
140
136
|
#beginfunction
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
LULog.LoggerAdd(LULog.LoggerTOOLS, logging.DEBUG, Ls)
|
|
137
|
+
s = f'Clear the readonly bit and reattempt the removal {path:s} ...'
|
|
138
|
+
LULog.LoggerTOOLS_AddLevel(logging.DEBUG, s)
|
|
144
139
|
os.chmod (path, stat.S_IWRITE)
|
|
145
140
|
func (path)
|
|
146
141
|
#endfunction
|
|
@@ -161,19 +156,16 @@ def DeleteDirectoryTree (ADir: str) -> bool:
|
|
|
161
156
|
#endfunction
|
|
162
157
|
|
|
163
158
|
#beginfunction
|
|
164
|
-
LResult = True
|
|
165
159
|
if DirectoryExists (ADir):
|
|
166
160
|
s = f'DeleteDirectoryTree {ADir:s} ...'
|
|
167
|
-
|
|
168
|
-
LULog.LoggerAdd(LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
161
|
+
LULog.LoggerTOOLS_AddLevel(logging.DEBUG, s)
|
|
169
162
|
try:
|
|
170
163
|
# shutil.rmtree (ADirectoryName, ignore_errors = True, onexc = None)
|
|
171
164
|
shutil.rmtree (ADir, ignore_errors = False, onerror = remove_readonly)
|
|
172
165
|
LResult = True
|
|
173
166
|
except:
|
|
174
167
|
s = f'Unable delete directory {ADir:s} ...'
|
|
175
|
-
|
|
176
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.error, s)
|
|
168
|
+
LULog.LoggerTOOLS_AddLevel (logging.error, s)
|
|
177
169
|
LResult = False
|
|
178
170
|
#endtry
|
|
179
171
|
#endif
|
|
@@ -197,8 +189,8 @@ def DirectoryClear (ADir: str) -> bool:
|
|
|
197
189
|
for file in files:
|
|
198
190
|
os.remove (os.path.join (root, file))
|
|
199
191
|
#endfor
|
|
200
|
-
for
|
|
201
|
-
os.rmdir (os.path.join (root,
|
|
192
|
+
for dir in dirs:
|
|
193
|
+
os.rmdir (os.path.join (root, dir))
|
|
202
194
|
#endfor
|
|
203
195
|
#endfor
|
|
204
196
|
LResult = True
|
|
@@ -498,7 +490,6 @@ def GetTempDir () -> str:
|
|
|
498
490
|
#beginfunction
|
|
499
491
|
# LResult = win32api.GetTempPath()
|
|
500
492
|
LResult = tempfile.gettempdir ()
|
|
501
|
-
print('TEMP:',LResult)
|
|
502
493
|
return LResult
|
|
503
494
|
#endfunction
|
|
504
495
|
|
|
@@ -696,9 +687,7 @@ def GetFileAttr (AFileName: str) -> int:
|
|
|
696
687
|
"""GetFileAttr"""
|
|
697
688
|
#beginfunction
|
|
698
689
|
s = f'GetFileAttr: {AFileName:s}'
|
|
699
|
-
|
|
700
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
701
|
-
|
|
690
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
702
691
|
LResult = 0
|
|
703
692
|
|
|
704
693
|
if FileExists (AFileName) or DirectoryExists (AFileName):
|
|
@@ -709,26 +698,22 @@ def GetFileAttr (AFileName: str) -> int:
|
|
|
709
698
|
case 'Windows':
|
|
710
699
|
Lmode = LStat.st_mode
|
|
711
700
|
s = f'Lmode: {Lmode:d} {hex (Lmode):s} {bin (Lmode):s} {stat.filemode (Lmode):s}'
|
|
712
|
-
|
|
713
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
701
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
714
702
|
Lattr = LStat.st_file_attributes
|
|
715
703
|
|
|
716
704
|
# Lattr = win32api.GetFileAttributes (AFileName)
|
|
717
705
|
|
|
718
706
|
s = f'Lattr:{Lattr:d} {hex (Lattr):s} {bin (Lattr):s} {GetFileAttrStr (Lattr):s}'
|
|
719
|
-
|
|
720
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
707
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
721
708
|
LResult = Lattr
|
|
722
709
|
case 'Linux':
|
|
723
710
|
Lmode = LStat.st_mode
|
|
724
711
|
s = f'Lmode:{Lmode:d} {hex (Lmode):s} {bin (Lmode):s} {GetFileModeStrUnix (Lmode):s}'
|
|
725
|
-
|
|
726
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
712
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
727
713
|
LResult = Lmode
|
|
728
714
|
case _:
|
|
729
715
|
s = f'Неизвестная система ...'
|
|
730
|
-
|
|
731
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
716
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
732
717
|
LResult = 0
|
|
733
718
|
#endmatch
|
|
734
719
|
#endif
|
|
@@ -742,27 +727,23 @@ def SetFileAttr (AFileName: str, Aattr: int, AClear: bool):
|
|
|
742
727
|
"""SetFileAttr"""
|
|
743
728
|
#beginfunction
|
|
744
729
|
s = f'SetFileAttr: {Aattr:d} {hex (Aattr):s} {bin (Aattr):s}'
|
|
745
|
-
|
|
746
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
730
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
747
731
|
|
|
748
732
|
LOSInfo = LUos.TOSInfo ()
|
|
749
733
|
match LOSInfo.system:
|
|
750
734
|
case 'Windows':
|
|
751
735
|
Lattr = GetFileAttr(AFileName)
|
|
752
736
|
s = f'Lattr - current: {Lattr:d} {hex (Lattr):s} {bin (Lattr):s}'
|
|
753
|
-
|
|
754
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
737
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
755
738
|
|
|
756
739
|
if AClear:
|
|
757
740
|
LattrNew = Lattr & ~Aattr
|
|
758
741
|
s = f'[clear]: {bin (LattrNew):s} {LattrNew:d} {hex (LattrNew):s} {bin (LattrNew):s}'
|
|
759
|
-
|
|
760
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
742
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
761
743
|
else:
|
|
762
|
-
LattrNew = Lattr |
|
|
744
|
+
LattrNew = Lattr | Aflags
|
|
763
745
|
s = f'[set]: {bin (LattrNew):s} {LattrNew:d} {hex (LattrNew):s} {bin (LattrNew):s}'
|
|
764
|
-
|
|
765
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
746
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
766
747
|
#endif
|
|
767
748
|
|
|
768
749
|
# if os.path.isdir (AFileName):
|
|
@@ -776,22 +757,18 @@ def SetFileAttr (AFileName: str, Aattr: int, AClear: bool):
|
|
|
776
757
|
raise NotImplementedError('SetFileAttr Linux not implemented ...')
|
|
777
758
|
case _:
|
|
778
759
|
s = f'Неизвестная система ...'
|
|
779
|
-
|
|
780
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
760
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
781
761
|
#endmatch
|
|
782
762
|
#endfunction
|
|
783
763
|
|
|
784
764
|
#-------------------------------------------------------------------------------
|
|
785
765
|
# SetFileMode
|
|
786
766
|
#-------------------------------------------------------------------------------
|
|
787
|
-
def SetFileMode (AFileName: str, Amode: int
|
|
767
|
+
def SetFileMode (AFileName: str, Amode: int):
|
|
788
768
|
"""SetFileMode"""
|
|
789
769
|
#beginfunction
|
|
790
770
|
s = f'SetFileMode: {Amode:d} {hex (Amode):s} {bin (Amode):s}'
|
|
791
|
-
|
|
792
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
793
|
-
|
|
794
|
-
Lattr = 0
|
|
771
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
795
772
|
|
|
796
773
|
LOSInfo = LUos.TOSInfo ()
|
|
797
774
|
match LOSInfo.system:
|
|
@@ -806,33 +783,29 @@ def SetFileMode (AFileName: str, Amode: int, AClear: bool, Aflags: int):
|
|
|
806
783
|
if AClear:
|
|
807
784
|
LattrNew = Lattr & ~Aflags
|
|
808
785
|
s = f'SetFileAttr [clear]: {bin (Aflags):s} {LattrNew:d} {hex (LattrNew):s} {bin (LattrNew):s}'
|
|
809
|
-
|
|
810
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
786
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
811
787
|
else:
|
|
812
788
|
LattrNew = Lattr | Aflags
|
|
813
789
|
s = f'SetFileAttr [set]: {bin (Aflags):s}{LattrNew:d} {hex (LattrNew):s} {bin (LattrNew):s}'
|
|
814
|
-
|
|
815
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
790
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
816
791
|
#endif
|
|
817
792
|
os.chflags (AFileName, Aflags)
|
|
818
793
|
case _:
|
|
819
794
|
s = f'Неизвестная система ...'
|
|
820
|
-
|
|
821
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
795
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
822
796
|
#endmatch
|
|
823
797
|
#endfunction
|
|
824
798
|
|
|
825
799
|
#-------------------------------------------------------------------------------
|
|
826
800
|
# SetFileFlags
|
|
827
801
|
#-------------------------------------------------------------------------------
|
|
828
|
-
def SetFileFlags (AFileName: str, Aflags: int
|
|
802
|
+
def SetFileFlags (AFileName: str, Aflags: int):
|
|
829
803
|
"""SetFileMode"""
|
|
830
804
|
#beginfunction
|
|
831
805
|
s = f'SetFileMode: {Aflags:d} {hex (Aflags):s} {bin (Aflags):s}'
|
|
832
|
-
|
|
833
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
806
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
834
807
|
|
|
835
|
-
LOSInfo = LUos.TOSInfo ()
|
|
808
|
+
LOSInfo = lyr.LUos.TOSInfo ()
|
|
836
809
|
match LOSInfo.system:
|
|
837
810
|
case 'Windows':
|
|
838
811
|
raise NotImplementedError('SetFileAttr Windows not implemented...')
|
|
@@ -846,19 +819,16 @@ def SetFileFlags (AFileName: str, Aflags: int, AClear: bool):
|
|
|
846
819
|
if AClear:
|
|
847
820
|
LflagsNew = Lattr & ~Aflags
|
|
848
821
|
s = f'[clear]: {bin (LflagsNew):s} {LflagsNew:d} {hex (LflagsNew):s} {bin (LflagsNew):s}'
|
|
849
|
-
|
|
850
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
822
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
851
823
|
else:
|
|
852
|
-
LflagsNew =
|
|
824
|
+
LflagsNew = Lflags | Aflags
|
|
853
825
|
s = f'[set]: {bin (LflagsNew):s} {LflagsNew:d} {hex (LflagsNew):s} {bin (LflagsNew):s}'
|
|
854
|
-
|
|
855
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
826
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
856
827
|
#endif
|
|
857
828
|
os.chflags (AFileName, LflagsNew)
|
|
858
829
|
case _:
|
|
859
830
|
s = f'Неизвестная система ...'
|
|
860
|
-
|
|
861
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
831
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
862
832
|
#endmatch
|
|
863
833
|
#endfunction
|
|
864
834
|
|
|
@@ -869,12 +839,7 @@ def FileDelete (AFileName: str) -> bool:
|
|
|
869
839
|
"""FileDelete"""
|
|
870
840
|
#beginfunction
|
|
871
841
|
s = f'FileDelete: {AFileName:s}'
|
|
872
|
-
|
|
873
|
-
# LULog.LoggerTOOLS_setLevel(logging.INFO)
|
|
874
|
-
# LULog.LoggerTOOLS_setLevel(logging.DEBUG)
|
|
875
|
-
|
|
876
|
-
# LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
877
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
842
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
878
843
|
LResult = True
|
|
879
844
|
|
|
880
845
|
if FileExists (AFileName):
|
|
@@ -885,9 +850,8 @@ def FileDelete (AFileName: str) -> bool:
|
|
|
885
850
|
Lattr = GetFileAttr (AFileName)
|
|
886
851
|
if Lattr & stat.FILE_ATTRIBUTE_READONLY:
|
|
887
852
|
s = f'Clear ReadOnly ...'
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
SetFileAttr (AFileName, stat.FILE_ATTRIBUTE_READONLY, True)
|
|
853
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
854
|
+
LUFile.SetFileAttr (AFileName, stat.FILE_ATTRIBUTE_READONLY, True)
|
|
891
855
|
|
|
892
856
|
# FileSetAttr (FileName, FileGetAttr(FileName) and (faReadOnly xor $FF));
|
|
893
857
|
# Change the file's permissions to writable
|
|
@@ -898,16 +862,14 @@ def FileDelete (AFileName: str) -> bool:
|
|
|
898
862
|
LResult = True
|
|
899
863
|
except:
|
|
900
864
|
s = f'ERROR: FileDelete ...'
|
|
901
|
-
|
|
902
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
865
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
903
866
|
LResult = False
|
|
904
867
|
#endtry
|
|
905
868
|
case 'Linux':
|
|
906
869
|
raise NotImplementedError('FileDelete Linux not implemented...')
|
|
907
870
|
case _:
|
|
908
871
|
s = f'Неизвестная система ...'
|
|
909
|
-
|
|
910
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
872
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
911
873
|
#endmatch
|
|
912
874
|
#endif
|
|
913
875
|
return LResult
|
|
@@ -920,10 +882,7 @@ def FileCopy (AFileNameSource: str, AFileNameDest: str, Overwrite: bool) -> bool
|
|
|
920
882
|
"""FileCopy"""
|
|
921
883
|
#beginfunction
|
|
922
884
|
s = f'FileCopy: {AFileNameSource:s} -> {AFileNameDest:s}'
|
|
923
|
-
|
|
924
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
925
|
-
|
|
926
|
-
LResult = True
|
|
885
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
927
886
|
|
|
928
887
|
if FileExists (AFileNameSource):
|
|
929
888
|
|
|
@@ -932,7 +891,7 @@ def FileCopy (AFileNameSource: str, AFileNameDest: str, Overwrite: bool) -> bool
|
|
|
932
891
|
ForceDirectories (LDestPath)
|
|
933
892
|
#endif
|
|
934
893
|
|
|
935
|
-
LOSInfo = LUos.TOSInfo ()
|
|
894
|
+
LOSInfo = lyr.LUos.TOSInfo ()
|
|
936
895
|
match LOSInfo.system:
|
|
937
896
|
case 'Windows':
|
|
938
897
|
try:
|
|
@@ -942,28 +901,26 @@ def FileCopy (AFileNameSource: str, AFileNameDest: str, Overwrite: bool) -> bool
|
|
|
942
901
|
|
|
943
902
|
# LResult = shutil.copy (AFileNameSource, AFileNameDest) != ''
|
|
944
903
|
|
|
945
|
-
# LResult = True
|
|
946
904
|
LResult = shutil.copy2 (AFileNameSource, AFileNameDest) != ''
|
|
947
905
|
# LResult = shutil.copy2 (AFileNameSource, LDestPath) != ''
|
|
948
906
|
# shutil.copystat (AFileNameSource, AFileNameDest)
|
|
949
907
|
|
|
908
|
+
LResult = True
|
|
950
909
|
except:
|
|
951
910
|
s = f'ERROR: FileCopy ...'
|
|
952
|
-
|
|
953
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
911
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
954
912
|
LResult = False
|
|
955
913
|
#endtry
|
|
956
914
|
case 'Linux':
|
|
957
915
|
# unix
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
916
|
+
LFileNameSource_stat = os.stat (AFileNameSource)
|
|
917
|
+
Lowner = LFileNameSource_stat [stat.ST_UID]
|
|
918
|
+
Lgroup = LFileNameSource_stat [stat.ST_GID]
|
|
961
919
|
# os.chown (AFileNameDest, Lowner, Lgroup)
|
|
962
920
|
raise NotImplementedError('FileCopy Linux not implemented...')
|
|
963
921
|
case _:
|
|
964
922
|
s = f'Неизвестная система ...'
|
|
965
|
-
|
|
966
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
923
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
967
924
|
#endmatch
|
|
968
925
|
#endif
|
|
969
926
|
return LResult
|
|
@@ -976,14 +933,13 @@ def FileMove (AFileNameSource: str, APathNameDest: str) -> bool:
|
|
|
976
933
|
"""FileMove"""
|
|
977
934
|
#beginfunction
|
|
978
935
|
s = f'FileMove: {AFileNameSource:s} -> {APathNameDest:s}'
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
ForceDirectories(APathNameDest)
|
|
936
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
937
|
+
LResult = True
|
|
938
|
+
if not LUFile.DirectoryExists(APathNameDest):
|
|
939
|
+
LUFile.ForceDirectories(APathNameDest)
|
|
984
940
|
#endif
|
|
985
|
-
|
|
986
|
-
|
|
941
|
+
LFileNameSource = ExtractFileName (AFileNameSource)
|
|
942
|
+
LFileNameDest = os.path.join (APathNameDest, LFileNameSource)
|
|
987
943
|
LResult = shutil.move(AFileNameSource, APathNameDest, copy_function=shutil.copy2())
|
|
988
944
|
return LResult
|
|
989
945
|
#endfunction
|
|
@@ -1002,19 +958,15 @@ def CheckFileNameMask (AFileName: str, AMask: str) -> bool:
|
|
|
1002
958
|
# LMask = '^[\\S ]*.py$' # *.py - все символы включая пробелы
|
|
1003
959
|
# LMask = '^[a-zA-Z0-9]*.py$' # *.py - только латинские буквы и цифры
|
|
1004
960
|
LMask = AMask
|
|
1005
|
-
|
|
961
|
+
|
|
1006
962
|
#-------------------------------------------------------------------------------
|
|
1007
963
|
# regex = re.compile (LMask)
|
|
1008
964
|
# Lresult = regex.match(LFileName)
|
|
1009
965
|
#-------------------------------------------------------------------------------
|
|
1010
966
|
# эквивалентно
|
|
1011
967
|
#-------------------------------------------------------------------------------
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
# Lresult = re.search (LMask, LFileName)
|
|
1015
|
-
except Exception as e:
|
|
1016
|
-
Lresult = False
|
|
1017
|
-
#endtry
|
|
968
|
+
Lresult = re.match (LMask, LFileName)
|
|
969
|
+
# Lresult = re.search (LMask, LFileName)
|
|
1018
970
|
#-------------------------------------------------------------------------------
|
|
1019
971
|
else:
|
|
1020
972
|
Lresult = False
|
|
@@ -1029,8 +981,7 @@ def CreateTextFile(AFileName: str, AText: str, AEncoding: str):
|
|
|
1029
981
|
"""CreateTextFile"""
|
|
1030
982
|
#beginfunction
|
|
1031
983
|
s = f'CreateTextFile: {AFileName:s} ...'
|
|
1032
|
-
|
|
1033
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
984
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
1034
985
|
|
|
1035
986
|
LEncoding = AEncoding
|
|
1036
987
|
if AEncoding == '':
|
|
@@ -1053,24 +1004,21 @@ def CreateTextFile(AFileName: str, AText: str, AEncoding: str):
|
|
|
1053
1004
|
#--------------------------------------------------------------------------------
|
|
1054
1005
|
# WriteStrToFile
|
|
1055
1006
|
#--------------------------------------------------------------------------------
|
|
1056
|
-
def WriteStrToFile (AFileName: str, AStr: str
|
|
1007
|
+
def WriteStrToFile (AFileName: str, AStr: str):
|
|
1057
1008
|
"""WriteStrToFile"""
|
|
1058
1009
|
#beginfunction
|
|
1059
1010
|
s = f'WriteStrToFile: {AFileName:s} ...'
|
|
1060
|
-
|
|
1061
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
1011
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
1062
1012
|
|
|
1063
1013
|
# Откроет для добавления нового содержимого.
|
|
1064
1014
|
# Создаст новый файл для чтения записи, если не найдет с указанным именем.
|
|
1065
1015
|
LEncoding = GetFileEncoding (AFileName)
|
|
1066
|
-
if
|
|
1067
|
-
LEncoding = LUStrDecode.cCP1251
|
|
1016
|
+
if LEncoding == '':
|
|
1017
|
+
# LEncoding = LUStrDecode.cCP1251
|
|
1068
1018
|
LEncoding = cDefaultEncoding
|
|
1069
|
-
else:
|
|
1070
|
-
LEncoding = AEncoding
|
|
1071
1019
|
#endif
|
|
1072
1020
|
|
|
1073
|
-
if len(AStr)
|
|
1021
|
+
if len(AStr) > 0:
|
|
1074
1022
|
LHandle = open (AFileName, 'a+', encoding = LEncoding)
|
|
1075
1023
|
LHandle.write (AStr + '\n')
|
|
1076
1024
|
LHandle.flush ()
|
|
@@ -1085,8 +1033,7 @@ def OpenTextFile(AFileName: str, AEncoding: str) -> int:
|
|
|
1085
1033
|
"""OpenTextFile"""
|
|
1086
1034
|
#beginfunction
|
|
1087
1035
|
s = f'OpenTextFile: {AFileName:s} ...'
|
|
1088
|
-
|
|
1089
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
1036
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
1090
1037
|
|
|
1091
1038
|
LEncoding = AEncoding
|
|
1092
1039
|
if AEncoding == '':
|
|
@@ -1114,8 +1061,7 @@ def CloseTextFile (AHandle):
|
|
|
1114
1061
|
"""CloseTextFile"""
|
|
1115
1062
|
#beginfunction
|
|
1116
1063
|
s = f'CloseTextFile ...'
|
|
1117
|
-
|
|
1118
|
-
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
1064
|
+
LULog.LoggerTOOLS_AddLevel (logging.DEBUG, s)
|
|
1119
1065
|
|
|
1120
1066
|
AHandle.flush ()
|
|
1121
1067
|
AHandle.close ()
|