ccfx 1.0.3__tar.gz → 1.0.4__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.
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ccfx
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: This package simplifies regular common actions for quick prototyping in a user friendly way
5
5
  Author-email: Celray James CHAWANDA <celray@chawanda.com>
6
6
  License-Expression: MIT
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} - f{yr_to} {eta_str}')
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, string_after= f' ')
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(point_pairs_list, columns = ['latitude', 'longitude'], auth = "EPSG", code = '4326', out_shape = '', format = 'gpkg', v = False, get_geometry_only = False):
766
- df = pandas.DataFrame(point_pairs_list, columns = columns)
767
- geometry = [Point(xy) for xy in zip(df['latitude'], df['longitude'])]
768
-
769
- if get_geometry_only:
770
- return geometry[0]
771
-
772
- gdf = geopandas.GeoDataFrame(point_pairs_list, columns = columns, geometry=geometry)
773
- drivers = {'gpkg': 'GPKG', 'shp': 'ESRI Shapefile'}
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 an archive supported by py7zr (.7z, .zip, .tar, .tar.gz, .tar.bz2, .xz, .tar.xz) to outputDir.
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
- if not exists(outputDir): createPath(outputDir)
903
- with py7zr.SevenZipFile(inputFile, 'r') as archive: archive.extractall(path=outputDir)
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}| {percentStr}% [{count}/{end}] | {message} ', end='', flush=True)
1562
+ print(f'\r{bar} {percentStr}% [{count}/{end}] | {message} ', end='', flush=True)
1519
1563
  if count == end:
1520
- print(f'\r{bar}| {percentStr}% [{count}/{end}] ', end='', flush=True)
1564
+ print(f'\r{bar} {percentStr}% [{count}/{end}] ', end='', flush=True)
1521
1565
  print()
1522
1566
 
1523
1567
 
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ccfx
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: This package simplifies regular common actions for quick prototyping in a user friendly way
5
5
  Author-email: Celray James CHAWANDA <celray@chawanda.com>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ccfx"
7
- version = "1.0.3"
7
+ version = "1.0.4"
8
8
  description = "This package simplifies regular common actions for quick prototyping in a user friendly way"
9
9
  readme = "README.md"
10
10
  license = "MIT"
File without changes