ccfx 1.0.2__py3-none-any.whl → 1.0.4__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.
- ccfx/ccfx.py +69 -26
- {ccfx-1.0.2.dist-info → ccfx-1.0.4.dist-info}/METADATA +1 -1
- {ccfx-1.0.2.dist-info → ccfx-1.0.4.dist-info}/RECORD +6 -6
- {ccfx-1.0.2.dist-info → ccfx-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {ccfx-1.0.2.dist-info → ccfx-1.0.4.dist-info}/top_level.txt +0 -0
- {ccfx-1.0.2.dist-info → ccfx-1.0.4.dist-info}/WHEEL +0 -0
ccfx/ccfx.py
CHANGED
@@ -19,6 +19,7 @@ import numpy
|
|
19
19
|
from genericpath import exists
|
20
20
|
import shutil
|
21
21
|
import platform
|
22
|
+
import zipfile
|
22
23
|
import pickle
|
23
24
|
import time
|
24
25
|
from shapely.geometry import box, Point
|
@@ -238,7 +239,6 @@ def parseYoutubeChannelVideos(channelUrl: str, maxItems: Optional[int] = None) -
|
|
238
239
|
return [f"https://www.youtube.com/watch?v={e['id']}" for e in entries if e.get("id")]
|
239
240
|
|
240
241
|
|
241
|
-
|
242
242
|
def runSWATPlus(txtinoutDir: str, finalDir: str, executablePath: str = "swatplus", v: bool = True):
|
243
243
|
os.chdir(txtinoutDir)
|
244
244
|
|
@@ -267,6 +267,7 @@ def runSWATPlus(txtinoutDir: str, finalDir: str, executablePath: str = "swatplus
|
|
267
267
|
day_cycle = []
|
268
268
|
previous_time = None
|
269
269
|
|
270
|
+
counter = 0
|
270
271
|
while True:
|
271
272
|
line = process.stdout.readline()
|
272
273
|
line_parts = str(line).strip().split()
|
@@ -299,7 +300,7 @@ def runSWATPlus(txtinoutDir: str, finalDir: str, executablePath: str = "swatplus
|
|
299
300
|
else:
|
300
301
|
eta_str = ''
|
301
302
|
|
302
|
-
showProgress(current, number_of_days,
|
303
|
+
showProgress(current, number_of_days, barLength=20, message= f' >> current date: {day}/{month}/{year} - {yr_to} {eta_str}')
|
303
304
|
|
304
305
|
previous_time = datetime.now()
|
305
306
|
elif "ntdll.dll" in line_parts:
|
@@ -310,13 +311,12 @@ def runSWATPlus(txtinoutDir: str, finalDir: str, executablePath: str = "swatplus
|
|
310
311
|
|
311
312
|
if len(line_parts) < 2: break
|
312
313
|
|
313
|
-
showProgress(current, number_of_days,
|
314
|
+
showProgress(current, number_of_days, message = f' ')
|
314
315
|
print("\n")
|
315
316
|
|
316
317
|
os.chdir(finalDir)
|
317
318
|
|
318
319
|
|
319
|
-
|
320
320
|
def formatTimedelta(delta: timedelta) -> str:
|
321
321
|
"""Formats a timedelta duration to [N days] %H:%M:%S format"""
|
322
322
|
seconds = int(delta.total_seconds())
|
@@ -763,22 +763,35 @@ def readFrom(filename, decode_codec = None, v=False):
|
|
763
763
|
return file_text
|
764
764
|
|
765
765
|
|
766
|
-
def pointsToGeodataframe(
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
766
|
+
def pointsToGeodataframe(
|
767
|
+
rowList,
|
768
|
+
columnNames,
|
769
|
+
latIndex,
|
770
|
+
lonIndex,
|
771
|
+
auth = "EPSG",
|
772
|
+
code = "4326",
|
773
|
+
outShape = "",
|
774
|
+
format = "gpkg",
|
775
|
+
v = False,
|
776
|
+
includeLatLon = True ) -> geopandas.GeoDataFrame:
|
777
|
+
df = pandas.DataFrame(rowList, columns = columnNames)
|
778
|
+
geometry = [
|
779
|
+
Point(row[lonIndex], row[latIndex]) for row in rowList
|
780
|
+
]
|
781
|
+
|
782
|
+
if not includeLatLon:
|
783
|
+
colsToKeep = [col for i, col in enumerate(columnNames) if i not in (latIndex, lonIndex)]
|
784
|
+
df = df[colsToKeep]
|
785
|
+
|
786
|
+
gdf = geopandas.GeoDataFrame(df, geometry = geometry)
|
787
|
+
drivers = {"gpkg": "GPKG", "shp": "ESRI Shapefile"}
|
788
|
+
gdf = gdf.set_crs(f"{auth}:{code}")
|
789
|
+
|
790
|
+
if outShape != "":
|
791
|
+
if v:
|
792
|
+
print(f"creating shapefile {outShape}")
|
793
|
+
gdf.to_file(outShape, driver = drivers[format])
|
775
794
|
|
776
|
-
gdf = gdf.set_crs(f'{auth}:{code}')
|
777
|
-
|
778
|
-
if out_shape != '':
|
779
|
-
if v: print(f'creating shapefile {out_shape}')
|
780
|
-
gdf.to_file(out_shape, driver=drivers[format])
|
781
|
-
|
782
795
|
return gdf
|
783
796
|
|
784
797
|
|
@@ -895,16 +908,46 @@ def compressTo7z(input_dir: str, output_file: str, compressionLevel: int = 4, ex
|
|
895
908
|
|
896
909
|
def uncompress(inputFile: str, outputDir: str, v: bool = False) -> None:
|
897
910
|
"""
|
898
|
-
Extracts
|
911
|
+
Extracts .7z, .zip, .tar, .tar.gz, .tar.bz2, .xz, .tar.xz archives to outputDir.
|
899
912
|
inputFile: Path to the input archive file
|
900
913
|
outputDir: Directory where the contents will be extracted
|
901
914
|
v: Verbose flag to print extraction status (default is False)
|
902
915
|
"""
|
903
|
-
|
904
|
-
|
916
|
+
fileLower = inputFile.lower()
|
917
|
+
if not exists(outputDir):
|
918
|
+
createPath(outputDir)
|
919
|
+
|
920
|
+
if fileLower.endswith(".zip"):
|
921
|
+
with zipfile.ZipFile(inputFile, 'r') as archive:
|
922
|
+
archive.extractall(path=outputDir)
|
923
|
+
else:
|
924
|
+
with py7zr.SevenZipFile(inputFile, 'r') as archive:
|
925
|
+
archive.extractall(path=outputDir)
|
905
926
|
if v: print(f"extracted {inputFile} to {outputDir}.")
|
906
927
|
|
907
928
|
|
929
|
+
def uncompressFile(inputFile: str, outputDir: str, v: bool = False) -> None:
|
930
|
+
"""
|
931
|
+
This is an alias for uncompress
|
932
|
+
"""
|
933
|
+
uncompress(inputFile, outputDir, v)
|
934
|
+
|
935
|
+
def unzipFile(inputFile: str, outputDir: str, v: bool = False) -> None:
|
936
|
+
"""
|
937
|
+
this is an alias for uncompress
|
938
|
+
"""
|
939
|
+
uncompress(inputFile, outputDir, v)
|
940
|
+
|
941
|
+
def extractZip(inputFile: str, outputDir: str, v: bool = False) -> None:
|
942
|
+
"""this is an alias for uncompress"""
|
943
|
+
uncompress(inputFile, outputDir, v)
|
944
|
+
|
945
|
+
def extractCompressedFile(inputFile: str, outputDir: str, v: bool = False) -> None:
|
946
|
+
"""
|
947
|
+
this is an alias for uncompress
|
948
|
+
"""
|
949
|
+
uncompress(inputFile, outputDir, v)
|
950
|
+
|
908
951
|
def moveDirectory(srcDir:str, destDir:str, v:bool = False) -> bool:
|
909
952
|
'''
|
910
953
|
this function moves all files from srcDir to destDir
|
@@ -1417,14 +1460,14 @@ def copyDirectory(source:str, destination:str, recursive = True, v:bool = True,
|
|
1417
1460
|
copyFile(s, d, v = False)
|
1418
1461
|
if v: showProgress(counter, itemCount, f'copying {getFileBaseName(item)}\t\t', barLength=50)
|
1419
1462
|
counter += 1
|
1420
|
-
print()
|
1463
|
+
if v:print()
|
1421
1464
|
|
1422
1465
|
|
1423
1466
|
def copyFolder(source:str, destination:str, v:bool = True) -> None:
|
1424
1467
|
'''
|
1425
1468
|
this function is an alias for copyDirectory
|
1426
1469
|
'''
|
1427
|
-
copyDirectory(source, destination, v)
|
1470
|
+
copyDirectory(source, destination, v=v)
|
1428
1471
|
|
1429
1472
|
|
1430
1473
|
def convertCoordinates(lon, lat, srcEPSG, dstCRS) -> tuple:
|
@@ -1516,9 +1559,9 @@ def showProgress(count: int, end: int, message: str, barLength: int = 100) -> No
|
|
1516
1559
|
percentStr = f'{percent:03.1f}'
|
1517
1560
|
filled = int(barLength * count / end)
|
1518
1561
|
bar = '█' * filled + '░' * (barLength - filled)
|
1519
|
-
print(f'\r{bar}
|
1562
|
+
print(f'\r{bar} {percentStr}% [{count}/{end}] | {message} ', end='', flush=True)
|
1520
1563
|
if count == end:
|
1521
|
-
print(f'\r{bar}
|
1564
|
+
print(f'\r{bar} {percentStr}% [{count}/{end}] ', end='', flush=True)
|
1522
1565
|
print()
|
1523
1566
|
|
1524
1567
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
ccfx/__init__.py,sha256=UK62VcGS84SJyGVg1bK4FltZj7OkpdoyhoFWeXcKsX0,144
|
2
|
-
ccfx/ccfx.py,sha256=
|
2
|
+
ccfx/ccfx.py,sha256=CmFUpD93sMYNd7LzLGUa56a9Acz-m0LCcIVpZOYG-j8,73719
|
3
3
|
ccfx/excel.py,sha256=vm_cm4huKKx4_Nstr5neJzhBLmoZjg8qxjzz4hcF5hg,4754
|
4
4
|
ccfx/mssqlConnection.py,sha256=C3HxzgZHmHy_de9EbMaXzR8NrkJxwHc8a00qzxQu_gs,8984
|
5
5
|
ccfx/sqliteConnection.py,sha256=jEJ94D5ySt84N7AeDpa27Rclt1NaKhkX6nYzidwApIg,11104
|
6
6
|
ccfx/word.py,sha256=AGa64jX5Zl5qotZh5L0QmrsjTnktIBhmj_ByRKZ88vw,3061
|
7
|
-
ccfx-1.0.
|
8
|
-
ccfx-1.0.
|
9
|
-
ccfx-1.0.
|
10
|
-
ccfx-1.0.
|
11
|
-
ccfx-1.0.
|
7
|
+
ccfx-1.0.4.dist-info/licenses/LICENSE,sha256=EuxaawJg_OOCLfikkCGgfXPZmxR-x_5PH7_2e9M-3eA,1099
|
8
|
+
ccfx-1.0.4.dist-info/METADATA,sha256=cvUn0gfEDQveMIV1wVSjNG-RiFSxw3sc19K_ZuKTuwc,11260
|
9
|
+
ccfx-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
10
|
+
ccfx-1.0.4.dist-info/top_level.txt,sha256=_cSvSA1WX2K8TgoV3iBJUdUZZqMKJbOPLNnKLYSLHaw,5
|
11
|
+
ccfx-1.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|