ccfx 1.0.3__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 +68 -24
- {ccfx-1.0.3.dist-info → ccfx-1.0.4.dist-info}/METADATA +1 -1
- {ccfx-1.0.3.dist-info → ccfx-1.0.4.dist-info}/RECORD +6 -6
- {ccfx-1.0.3.dist-info → ccfx-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {ccfx-1.0.3.dist-info → ccfx-1.0.4.dist-info}/top_level.txt +0 -0
- {ccfx-1.0.3.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
|
@@ -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, barLength=20, message= f' >> current date: {day}/{month}/{year} -
|
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,7 +311,7 @@ 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)
|
@@ -762,22 +763,35 @@ def readFrom(filename, decode_codec = None, v=False):
|
|
762
763
|
return file_text
|
763
764
|
|
764
765
|
|
765
|
-
def pointsToGeodataframe(
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
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])
|
774
794
|
|
775
|
-
gdf = gdf.set_crs(f'{auth}:{code}')
|
776
|
-
|
777
|
-
if out_shape != '':
|
778
|
-
if v: print(f'creating shapefile {out_shape}')
|
779
|
-
gdf.to_file(out_shape, driver=drivers[format])
|
780
|
-
|
781
795
|
return gdf
|
782
796
|
|
783
797
|
|
@@ -894,16 +908,46 @@ def compressTo7z(input_dir: str, output_file: str, compressionLevel: int = 4, ex
|
|
894
908
|
|
895
909
|
def uncompress(inputFile: str, outputDir: str, v: bool = False) -> None:
|
896
910
|
"""
|
897
|
-
Extracts
|
911
|
+
Extracts .7z, .zip, .tar, .tar.gz, .tar.bz2, .xz, .tar.xz archives to outputDir.
|
898
912
|
inputFile: Path to the input archive file
|
899
913
|
outputDir: Directory where the contents will be extracted
|
900
914
|
v: Verbose flag to print extraction status (default is False)
|
901
915
|
"""
|
902
|
-
|
903
|
-
|
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)
|
904
926
|
if v: print(f"extracted {inputFile} to {outputDir}.")
|
905
927
|
|
906
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
|
+
|
907
951
|
def moveDirectory(srcDir:str, destDir:str, v:bool = False) -> bool:
|
908
952
|
'''
|
909
953
|
this function moves all files from srcDir to destDir
|
@@ -1416,14 +1460,14 @@ def copyDirectory(source:str, destination:str, recursive = True, v:bool = True,
|
|
1416
1460
|
copyFile(s, d, v = False)
|
1417
1461
|
if v: showProgress(counter, itemCount, f'copying {getFileBaseName(item)}\t\t', barLength=50)
|
1418
1462
|
counter += 1
|
1419
|
-
print()
|
1463
|
+
if v:print()
|
1420
1464
|
|
1421
1465
|
|
1422
1466
|
def copyFolder(source:str, destination:str, v:bool = True) -> None:
|
1423
1467
|
'''
|
1424
1468
|
this function is an alias for copyDirectory
|
1425
1469
|
'''
|
1426
|
-
copyDirectory(source, destination, v)
|
1470
|
+
copyDirectory(source, destination, v=v)
|
1427
1471
|
|
1428
1472
|
|
1429
1473
|
def convertCoordinates(lon, lat, srcEPSG, dstCRS) -> tuple:
|
@@ -1515,9 +1559,9 @@ def showProgress(count: int, end: int, message: str, barLength: int = 100) -> No
|
|
1515
1559
|
percentStr = f'{percent:03.1f}'
|
1516
1560
|
filled = int(barLength * count / end)
|
1517
1561
|
bar = '█' * filled + '░' * (barLength - filled)
|
1518
|
-
print(f'\r{bar}
|
1562
|
+
print(f'\r{bar} {percentStr}% [{count}/{end}] | {message} ', end='', flush=True)
|
1519
1563
|
if count == end:
|
1520
|
-
print(f'\r{bar}
|
1564
|
+
print(f'\r{bar} {percentStr}% [{count}/{end}] ', end='', flush=True)
|
1521
1565
|
print()
|
1522
1566
|
|
1523
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
|