ccfx 1.0.3__tar.gz → 1.0.5__tar.gz
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-1.0.3 → ccfx-1.0.5}/LICENSE +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/MANIFEST.in +0 -0
- {ccfx-1.0.3/ccfx.egg-info → ccfx-1.0.5}/PKG-INFO +1 -1
- {ccfx-1.0.3 → ccfx-1.0.5}/README.md +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx/__init__.py +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx/ccfx.py +96 -24
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx/excel.py +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx/mssqlConnection.py +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx/sqliteConnection.py +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx/word.py +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5/ccfx.egg-info}/PKG-INFO +1 -1
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx.egg-info/SOURCES.txt +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx.egg-info/dependency_links.txt +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx.egg-info/requires.txt +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/ccfx.egg-info/top_level.txt +0 -0
- {ccfx-1.0.3 → ccfx-1.0.5}/pyproject.toml +1 -1
- {ccfx-1.0.3 → ccfx-1.0.5}/setup.cfg +0 -0
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -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)
|
@@ -432,6 +433,34 @@ def deleteFile(filePath:str, v:bool = False) -> bool:
|
|
432
433
|
|
433
434
|
return deleted
|
434
435
|
|
436
|
+
def removeImageColour(inPath:str, outPath:str, colour:tuple = (255, 255, 255), tolerance:int = 30):
|
437
|
+
'''
|
438
|
+
Remove a specific color from an image.
|
439
|
+
colour: RGB tuple, e.g., (255, 0, 0) for red
|
440
|
+
'''
|
441
|
+
img = Image.open(inPath)
|
442
|
+
img = img.convert("RGBA")
|
443
|
+
|
444
|
+
data = img.getdata()
|
445
|
+
|
446
|
+
new_data = []
|
447
|
+
for item in data:
|
448
|
+
# Change all pixels that match the color to transparent
|
449
|
+
if item[0] in range(colour[0]-tolerance, colour[0]+tolerance) and \
|
450
|
+
item[1] in range(colour[1]-tolerance, colour[1]+tolerance) and \
|
451
|
+
item[2] in range(colour[2]-tolerance, colour[2]+tolerance):
|
452
|
+
new_data.append((255, 255, 255, 0)) # Change to transparent
|
453
|
+
else:
|
454
|
+
new_data.append(item)
|
455
|
+
|
456
|
+
img.putdata(new_data)
|
457
|
+
img.save(outPath)
|
458
|
+
|
459
|
+
def makeTransparent(inPath:str, outPath:str, colour:tuple = (255, 255, 255), tolerance:int = 30):
|
460
|
+
'''
|
461
|
+
Make some pixels in an image transparent.
|
462
|
+
'''
|
463
|
+
removeImageColour(inPath, outPath, colour=colour, tolerance=tolerance)
|
435
464
|
|
436
465
|
def alert(message:str, server:str = "http://ntfy.sh", topic:str = "pythonAlerts", attachment:Optional[str] = None, messageTitle:str = "info", priority:int = None, tags:list = [], printIt:bool = True, v:bool = False) -> bool:
|
437
466
|
'''
|
@@ -762,22 +791,35 @@ def readFrom(filename, decode_codec = None, v=False):
|
|
762
791
|
return file_text
|
763
792
|
|
764
793
|
|
765
|
-
def pointsToGeodataframe(
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
794
|
+
def pointsToGeodataframe(
|
795
|
+
rowList,
|
796
|
+
columnNames,
|
797
|
+
latIndex,
|
798
|
+
lonIndex,
|
799
|
+
auth = "EPSG",
|
800
|
+
code = "4326",
|
801
|
+
outShape = "",
|
802
|
+
format = "gpkg",
|
803
|
+
v = False,
|
804
|
+
includeLatLon = True ) -> geopandas.GeoDataFrame:
|
805
|
+
df = pandas.DataFrame(rowList, columns = columnNames)
|
806
|
+
geometry = [
|
807
|
+
Point(row[lonIndex], row[latIndex]) for row in rowList
|
808
|
+
]
|
809
|
+
|
810
|
+
if not includeLatLon:
|
811
|
+
colsToKeep = [col for i, col in enumerate(columnNames) if i not in (latIndex, lonIndex)]
|
812
|
+
df = df[colsToKeep]
|
813
|
+
|
814
|
+
gdf = geopandas.GeoDataFrame(df, geometry = geometry)
|
815
|
+
drivers = {"gpkg": "GPKG", "shp": "ESRI Shapefile"}
|
816
|
+
gdf = gdf.set_crs(f"{auth}:{code}")
|
817
|
+
|
818
|
+
if outShape != "":
|
819
|
+
if v:
|
820
|
+
print(f"creating shapefile {outShape}")
|
821
|
+
gdf.to_file(outShape, driver = drivers[format])
|
774
822
|
|
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
823
|
return gdf
|
782
824
|
|
783
825
|
|
@@ -894,16 +936,46 @@ def compressTo7z(input_dir: str, output_file: str, compressionLevel: int = 4, ex
|
|
894
936
|
|
895
937
|
def uncompress(inputFile: str, outputDir: str, v: bool = False) -> None:
|
896
938
|
"""
|
897
|
-
Extracts
|
939
|
+
Extracts .7z, .zip, .tar, .tar.gz, .tar.bz2, .xz, .tar.xz archives to outputDir.
|
898
940
|
inputFile: Path to the input archive file
|
899
941
|
outputDir: Directory where the contents will be extracted
|
900
942
|
v: Verbose flag to print extraction status (default is False)
|
901
943
|
"""
|
902
|
-
|
903
|
-
|
944
|
+
fileLower = inputFile.lower()
|
945
|
+
if not exists(outputDir):
|
946
|
+
createPath(outputDir)
|
947
|
+
|
948
|
+
if fileLower.endswith(".zip"):
|
949
|
+
with zipfile.ZipFile(inputFile, 'r') as archive:
|
950
|
+
archive.extractall(path=outputDir)
|
951
|
+
else:
|
952
|
+
with py7zr.SevenZipFile(inputFile, 'r') as archive:
|
953
|
+
archive.extractall(path=outputDir)
|
904
954
|
if v: print(f"extracted {inputFile} to {outputDir}.")
|
905
955
|
|
906
956
|
|
957
|
+
def uncompressFile(inputFile: str, outputDir: str, v: bool = False) -> None:
|
958
|
+
"""
|
959
|
+
This is an alias for uncompress
|
960
|
+
"""
|
961
|
+
uncompress(inputFile, outputDir, v)
|
962
|
+
|
963
|
+
def unzipFile(inputFile: str, outputDir: str, v: bool = False) -> None:
|
964
|
+
"""
|
965
|
+
this is an alias for uncompress
|
966
|
+
"""
|
967
|
+
uncompress(inputFile, outputDir, v)
|
968
|
+
|
969
|
+
def extractZip(inputFile: str, outputDir: str, v: bool = False) -> None:
|
970
|
+
"""this is an alias for uncompress"""
|
971
|
+
uncompress(inputFile, outputDir, v)
|
972
|
+
|
973
|
+
def extractCompressedFile(inputFile: str, outputDir: str, v: bool = False) -> None:
|
974
|
+
"""
|
975
|
+
this is an alias for uncompress
|
976
|
+
"""
|
977
|
+
uncompress(inputFile, outputDir, v)
|
978
|
+
|
907
979
|
def moveDirectory(srcDir:str, destDir:str, v:bool = False) -> bool:
|
908
980
|
'''
|
909
981
|
this function moves all files from srcDir to destDir
|
@@ -1416,14 +1488,14 @@ def copyDirectory(source:str, destination:str, recursive = True, v:bool = True,
|
|
1416
1488
|
copyFile(s, d, v = False)
|
1417
1489
|
if v: showProgress(counter, itemCount, f'copying {getFileBaseName(item)}\t\t', barLength=50)
|
1418
1490
|
counter += 1
|
1419
|
-
print()
|
1491
|
+
if v:print()
|
1420
1492
|
|
1421
1493
|
|
1422
1494
|
def copyFolder(source:str, destination:str, v:bool = True) -> None:
|
1423
1495
|
'''
|
1424
1496
|
this function is an alias for copyDirectory
|
1425
1497
|
'''
|
1426
|
-
copyDirectory(source, destination, v)
|
1498
|
+
copyDirectory(source, destination, v=v)
|
1427
1499
|
|
1428
1500
|
|
1429
1501
|
def convertCoordinates(lon, lat, srcEPSG, dstCRS) -> tuple:
|
@@ -1515,9 +1587,9 @@ def showProgress(count: int, end: int, message: str, barLength: int = 100) -> No
|
|
1515
1587
|
percentStr = f'{percent:03.1f}'
|
1516
1588
|
filled = int(barLength * count / end)
|
1517
1589
|
bar = '█' * filled + '░' * (barLength - filled)
|
1518
|
-
print(f'\r{bar}
|
1590
|
+
print(f'\r{bar} {percentStr}% [{count}/{end}] | {message} ', end='', flush=True)
|
1519
1591
|
if count == end:
|
1520
|
-
print(f'\r{bar}
|
1592
|
+
print(f'\r{bar} {percentStr}% [{count}/{end}] ', end='', flush=True)
|
1521
1593
|
print()
|
1522
1594
|
|
1523
1595
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|