PgsFile 0.5.4__py3-none-any.whl → 0.5.6__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 +53 -6
- PgsFile/__init__.py +2 -2
- PgsFile/models/dics/LIWC2015-Chinese.json +1 -0
- PgsFile/models/dics/LIWC2015-English.dic +6625 -0
- {pgsfile-0.5.4.dist-info → pgsfile-0.5.6.dist-info}/METADATA +15 -26
- {pgsfile-0.5.4.dist-info → pgsfile-0.5.6.dist-info}/RECORD +9 -7
- {pgsfile-0.5.4.dist-info → pgsfile-0.5.6.dist-info}/WHEEL +0 -0
- {pgsfile-0.5.4.dist-info → pgsfile-0.5.6.dist-info}/licenses/LICENSE +0 -0
- {pgsfile-0.5.4.dist-info → pgsfile-0.5.6.dist-info}/top_level.txt +0 -0
PgsFile/PgsFile.py
CHANGED
|
@@ -3364,7 +3364,7 @@ def get_all_env_variables():
|
|
|
3364
3364
|
return dict(env_vars)
|
|
3365
3365
|
|
|
3366
3366
|
import subprocess
|
|
3367
|
-
def
|
|
3367
|
+
def set_permanent_env_var_win(variable_name, variable_value, system_wide=False):
|
|
3368
3368
|
"""
|
|
3369
3369
|
Sets a permanent environment variable on Windows using the `setx` command.
|
|
3370
3370
|
|
|
@@ -3390,7 +3390,7 @@ def set_permanent_environment_variable(variable_name, variable_value, system_wid
|
|
|
3390
3390
|
except Exception as e:
|
|
3391
3391
|
print(f'An error occurred: {e}')
|
|
3392
3392
|
|
|
3393
|
-
def
|
|
3393
|
+
def delete_permanent_env_var_win(variable_name, system_wide=False):
|
|
3394
3394
|
"""
|
|
3395
3395
|
Deletes a permanent environment variable on Windows using the `reg` command.
|
|
3396
3396
|
|
|
@@ -3421,6 +3421,53 @@ def delete_permanent_environment_variable(variable_name, system_wide=False):
|
|
|
3421
3421
|
print(f'An error occurred: {e}')
|
|
3422
3422
|
|
|
3423
3423
|
|
|
3424
|
+
def set_permanent_env_var_mac(var_name: str, var_value: str, shell_config: str = "~/.zshrc") -> None:
|
|
3425
|
+
"""
|
|
3426
|
+
Sets a permanent environment variable by appending it to the specified shell configuration file.
|
|
3427
|
+
|
|
3428
|
+
Args:
|
|
3429
|
+
var_name (str): Name of the environment variable.
|
|
3430
|
+
var_value (str): Value of the environment variable.
|
|
3431
|
+
shell_config (str): Path to the shell configuration file (e.g., "~/.zshrc", "~/.bashrc").
|
|
3432
|
+
Defaults to "~/.zshrc".
|
|
3433
|
+
"""
|
|
3434
|
+
shell_config = os.path.expanduser(shell_config)
|
|
3435
|
+
|
|
3436
|
+
# Append the export line to the shell config file
|
|
3437
|
+
with open(shell_config, "a") as f:
|
|
3438
|
+
f.write(f'\nexport {var_name}="{var_value}"\n')
|
|
3439
|
+
|
|
3440
|
+
print(f'Added {var_name} to {shell_config}.')
|
|
3441
|
+
print(f'Restart your shell or run: source {shell_config}')
|
|
3442
|
+
|
|
3443
|
+
|
|
3444
|
+
def delete_permanent_env_var_mac(var_name: str, shell_config: str = "~/.zshrc") -> None:
|
|
3445
|
+
"""
|
|
3446
|
+
Deletes a permanent environment variable from the specified shell configuration file.
|
|
3447
|
+
|
|
3448
|
+
Args:
|
|
3449
|
+
var_name (str): Name of the environment variable to delete.
|
|
3450
|
+
shell_config (str): Path to the shell configuration file (e.g., "~/.zshrc", "~/.bashrc").
|
|
3451
|
+
Defaults to "~/.zshrc".
|
|
3452
|
+
"""
|
|
3453
|
+
shell_config = os.path.expanduser(shell_config)
|
|
3454
|
+
|
|
3455
|
+
# Read the file and remove the line containing the export statement
|
|
3456
|
+
with open(shell_config, "r") as f:
|
|
3457
|
+
lines = f.readlines()
|
|
3458
|
+
|
|
3459
|
+
# Use regex to find and remove the line
|
|
3460
|
+
pattern = re.compile(rf'^\s*export\s+{var_name}=.*$\n?', re.MULTILINE)
|
|
3461
|
+
new_lines = [line for line in lines if not pattern.match(line)]
|
|
3462
|
+
|
|
3463
|
+
# Write the updated content back to the file
|
|
3464
|
+
with open(shell_config, "w") as f:
|
|
3465
|
+
f.writelines(new_lines)
|
|
3466
|
+
|
|
3467
|
+
print(f'Removed {var_name} from {shell_config}.')
|
|
3468
|
+
print(f'Restart your shell or run: source {shell_config}')
|
|
3469
|
+
|
|
3470
|
+
|
|
3424
3471
|
def calculate_mean_dependency_distance(spacy_doc):
|
|
3425
3472
|
"""
|
|
3426
3473
|
Calculate the mean dependency distance for tokens in a spaCy Doc object.
|
|
@@ -3800,17 +3847,16 @@ def file_to_list_of_dicts(input_path, output_path):
|
|
|
3800
3847
|
|
|
3801
3848
|
import liwc
|
|
3802
3849
|
import json
|
|
3803
|
-
def perform_liwc_en(
|
|
3850
|
+
def perform_liwc_en(file_path, output_excel_path):
|
|
3804
3851
|
'''
|
|
3805
3852
|
Parameters
|
|
3806
3853
|
----------
|
|
3807
|
-
dic_path : str
|
|
3808
|
-
Path to the LIWC dictionary file.
|
|
3809
3854
|
file_path : str
|
|
3810
3855
|
Path to the raw text file.
|
|
3811
3856
|
output_excel_path : str
|
|
3812
3857
|
Path to the output Excel file.
|
|
3813
3858
|
'''
|
|
3859
|
+
dic_path = get_library_location("PgsFile")+"/PgsFile/models/dics/LIWC2015-English.dic"
|
|
3814
3860
|
parse, category_names = liwc.load_token_parser(dic_path)
|
|
3815
3861
|
test = get_data_text(file_path)
|
|
3816
3862
|
test_tokens = [w.lower() for w in word_tokenize2(test)]
|
|
@@ -3850,7 +3896,7 @@ def perform_liwc_en(dic_path, file_path, output_excel_path):
|
|
|
3850
3896
|
df.to_excel(output_excel_path, 'sheet1', index=False)
|
|
3851
3897
|
|
|
3852
3898
|
|
|
3853
|
-
def perform_liwc_zh(
|
|
3899
|
+
def perform_liwc_zh(file_path, output_excel_path):
|
|
3854
3900
|
'''
|
|
3855
3901
|
Parameters
|
|
3856
3902
|
----------
|
|
@@ -3861,6 +3907,7 @@ def perform_liwc_zh(dic_path, file_path, output_excel_path):
|
|
|
3861
3907
|
output_excel_path : str
|
|
3862
3908
|
Path to the output Excel file.
|
|
3863
3909
|
'''
|
|
3910
|
+
dic_path = get_library_location("PgsFile")+"/PgsFile/models/dics/LIWC2015-Chinese.json"
|
|
3864
3911
|
|
|
3865
3912
|
f=open(dic_path,"r")
|
|
3866
3913
|
dicx=json.load(f)
|
PgsFile/__init__.py
CHANGED
|
@@ -29,8 +29,8 @@ from .PgsFile import source_path, next_folder_names, get_directory_tree_with_met
|
|
|
29
29
|
from .PgsFile import remove_empty_folders, remove_empty_txts, remove_empty_lines, remove_empty_last_line
|
|
30
30
|
from .PgsFile import move_file, copy_file, remove_file
|
|
31
31
|
from .PgsFile import concatenate_excel_files
|
|
32
|
-
from .PgsFile import
|
|
33
|
-
from .PgsFile import
|
|
32
|
+
from .PgsFile import set_permanent_env_var_win, set_permanent_env_var_mac
|
|
33
|
+
from .PgsFile import delete_permanent_env_var_win, delete_permanent_env_var_mac
|
|
34
34
|
from .PgsFile import get_env_variable, get_all_env_variables
|
|
35
35
|
from .PgsFile import get_system_info
|
|
36
36
|
from .PgsFile import csv_to_json_append
|