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