PgsFile 0.5.8__py3-none-any.whl → 0.5.9__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 PgsFile might be problematic. Click here for more details.

PgsFile/PgsFile.py CHANGED
@@ -4408,4 +4408,49 @@ def get_data_csv(csv_path: str) -> list[dict]:
4408
4408
  """
4409
4409
  import pandas as pd
4410
4410
  df = pd.read_csv(csv_path)
4411
- return df.to_dict(orient="records")
4411
+ return df.to_dict(orient="records")
4412
+
4413
+ from ipaddress import ip_address, ip_network
4414
+ def check_ip_in_span(ip_to_check, cidr, additional_ips=None):
4415
+ """
4416
+ Check if the given IP address is within the specified CIDR subnet or in the list of additional allowed IPs.
4417
+
4418
+ Args:
4419
+ ip_to_check (str): The IP address to check.
4420
+ cidr (str): The CIDR notation of the subnet (e.g., "10.2.57.0/25").
4421
+ additional_ips (list): List of additional allowed IP addresses (e.g., ["10.1.143.40"]).
4422
+
4423
+ Returns:
4424
+ None: Prints a message indicating if the IP is allowed or not.
4425
+ """
4426
+ try:
4427
+ ip = ip_address(ip_to_check)
4428
+ network = ip_network(cidr, strict=False)
4429
+
4430
+ # Check if the IP is in the subnet or in the additional IPs list
4431
+ if ip in network or (additional_ips and ip_address(ip_to_check) in [ip_address(ip) for ip in additional_ips]):
4432
+ return 1
4433
+
4434
+ else:
4435
+ return 0
4436
+ except ValueError:
4437
+ return "Invalid IP address or CIDR format."
4438
+
4439
+
4440
+ import socket
4441
+ def get_local_ip():
4442
+ """
4443
+ Get the local IP address of the machine.
4444
+
4445
+ Returns:
4446
+ str: The local IP address, or "Unable to determine local IP" if not found.
4447
+ """
4448
+ try:
4449
+ # Create a socket connection to a public DNS server to determine the local IP
4450
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
4451
+ s.connect(("8.8.8.8", 80)) # Google's public DNS server
4452
+ local_ip = s.getsockname()[0]
4453
+ s.close()
4454
+ return local_ip
4455
+ except Exception as e:
4456
+ return f"Unable to determine local IP: {e}"
PgsFile/__init__.py CHANGED
@@ -2,6 +2,7 @@
2
2
  from .PgsFile import PGScraper
3
3
  from .PgsFile import audiovisual_downloader
4
4
  from .PgsFile import headers, encode_chinese_keyword_for_url
5
+ from .PgsFile import get_local_ip, check_ip_in_span
5
6
 
6
7
  # 2. Package/library management
7
8
  from .PgsFile import install_package, uninstall_package
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PgsFile
3
- Version: 0.5.8
3
+ Version: 0.5.9
4
4
  Summary: This module streamlines Python package management, script execution, file handling, web scraping, and multimedia downloads. It supports LLM-based NLP tasks like OCR, tokenization, lemmatization, POS tagging, NER, ATE, dependency parsing, MDD, WSD, LIWC, MIP analysis, text classification, and Chinese-English sentence alignment. Additionally, it generates word lists and data visualizations, making it a practical tool for data scraping and analysis—ideal for literary students and researchers.
5
5
  Home-page: https://github.com/Petercusin/PgsFile
6
6
  Author: Pan Guisheng
@@ -1,5 +1,5 @@
1
- PgsFile/PgsFile.py,sha256=BiXU3odbUt8m9nq8yCT662l8tzM3W--drzLcyYacjCc,180591
2
- PgsFile/__init__.py,sha256=4AMmYVzDAr2Zy1r8WuN32lqgCxPaERTu5g6lnax4B9o,3840
1
+ PgsFile/PgsFile.py,sha256=WQeBEmYxdn1lhfnHkVe9radlVfGk2rUjiRUb3COqblk,182186
2
+ PgsFile/__init__.py,sha256=Q3fkOLdYaf6bGHbVGNixzgrGjL4BtyXd5Pfw2P3KyBc,3893
3
3
  PgsFile/Corpora/Idioms/English_Idioms_8774.txt,sha256=qlsP0yI_XGECBRiPZuLkGZpdasc77sWSKexANu7v8_M,175905
4
4
  PgsFile/Corpora/Monolingual/Chinese/People's Daily 20130605/Raw/00000000.txt,sha256=SLGGSMSb7Ff1RoBstsTW3yX2wNZpqEUchFNpcI-mrR4,1513
5
5
  PgsFile/Corpora/Monolingual/Chinese/People's Daily 20130605/Raw/00000001.txt,sha256=imOa6UoCOIZoPXT4_HNHgCUJtd4FTIdk2FZNHNBgJyg,3372
@@ -2596,8 +2596,8 @@ PgsFile/models/prompts/6. ATE3 prompt.txt,sha256=xn5HRkzIkrbdUP2I-huTd0KpuiQdRYF
2596
2596
  PgsFile/models/prompts/7. SentAlign prompt.txt,sha256=hXpqqC-CAgo8EytkJ0MaLhevLefALazWriY-ew39jxs,1537
2597
2597
  PgsFile/models/prompts/8. TitleCase prompt.txt,sha256=4p-LfGy0xAj2uPi9amyMm41T6Z17VNpFFsGZOgWhROs,1136
2598
2598
  PgsFile/models/prompts/9. TextClassification prompt.txt,sha256=JhQJu3rQSstNtkIkxPR1K-QmH9sGBEhbVKHAi7ItMUA,1066
2599
- pgsfile-0.5.8.dist-info/licenses/LICENSE,sha256=cE5c-QToSkG1KTUsU8drQXz1vG0EbJWuU4ybHTRb5SE,1138
2600
- pgsfile-0.5.8.dist-info/METADATA,sha256=a3zd1hCPn2eQv49UsxmCPDpg6ADBVnl4sNCzfcd-Ba0,3399
2601
- pgsfile-0.5.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2602
- pgsfile-0.5.8.dist-info/top_level.txt,sha256=028hCfwhF3UpfD6X0rwtWpXI1RKSTeZ1ALwagWaSmX8,8
2603
- pgsfile-0.5.8.dist-info/RECORD,,
2599
+ pgsfile-0.5.9.dist-info/licenses/LICENSE,sha256=cE5c-QToSkG1KTUsU8drQXz1vG0EbJWuU4ybHTRb5SE,1138
2600
+ pgsfile-0.5.9.dist-info/METADATA,sha256=1TK1NwX3h378OTZFRFPMkWr_6MKE1q2saUVqiSf7y_8,3399
2601
+ pgsfile-0.5.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2602
+ pgsfile-0.5.9.dist-info/top_level.txt,sha256=028hCfwhF3UpfD6X0rwtWpXI1RKSTeZ1ALwagWaSmX8,8
2603
+ pgsfile-0.5.9.dist-info/RECORD,,