Added comments to every function

Former-commit-id: 6b8f15be379d51af5ced2449b1db7749d528dcf4 [formerly 87ae61ae30]
Former-commit-id: f5919588095deb509e899cff4e024dd76affbbce
This commit is contained in:
rwinkhart
2022-07-08 00:39:48 -04:00
parent 30fb5ed041
commit a5946d558a
3 changed files with 19 additions and 16 deletions
+6 -5
View File
@@ -10,7 +10,7 @@ from sys import exit as s_exit
# utility functions
def get_titles_mods(_directory, _destination, _user_data):
def get_titles_mods(_directory, _destination, _user_data): # fetches and returns lists of titles and their mod times
_title_list, _mod_list = [], []
Path(path.expanduser('~/.config/sshync')).mkdir(0o700, parents=True, exist_ok=True) # create config directory
# local fetching
@@ -37,7 +37,8 @@ def get_titles_mods(_directory, _destination, _user_data):
return _title_list, _mod_list
def sort_titles_mods(_list_1, _list_2):
def sort_titles_mods(_list_1, _list_2): # creates and returns two lists (of titles and mod times) generated by sorting
# information from two different, provided lists
_title_list_2_sorted, _mod_list_2_sorted = [], []
# title sorting
for _title in _list_1[0]:
@@ -52,12 +53,12 @@ def sort_titles_mods(_list_1, _list_2):
return _title_list_2_sorted, _mod_list_2_sorted
def make_profile(_profile_dir, _local_dir, _remote_dir, _identity, _ip, _port, _user):
def make_profile(_profile_dir, _local_dir, _remote_dir, _identity, _ip, _port, _user): # creates a sshync job profile
open(_profile_dir, 'w').write(_user + '\n' + _ip + '\n' + _port + '\n' + _local_dir + '\n' + _remote_dir + '\n' +
_identity + '\n')
def get_profile(_profile_dir):
def get_profile(_profile_dir): # returns a list of data read from a sshync job profile
try:
_profile_data = open(_profile_dir).readlines()
except (FileNotFoundError, IndexError):
@@ -74,7 +75,7 @@ def get_profile(_profile_dir):
return _user, _ip, _port, _local_dir, _remote_dir, _identity
def run_profile(_profile_dir):
def run_profile(_profile_dir): # runs a sshync job profile
_user_data = get_profile(_profile_dir)
_remote_titles_mods_saver = get_titles_mods(_user_data[4], 'r', _user_data) # saved to prevent re-walking directory
_index_l = sort_titles_mods(_remote_titles_mods_saver, get_titles_mods(_user_data[3], 'l', _user_data))