Merge branch 'homePaths' of cmccabe/linkulator2 into master
This commit is contained in:
commit
51299aa627
|
@ -0,0 +1,26 @@
|
|||
# Linkulator, a link aggregator for the shell
|
||||
|
||||
## Installation
|
||||
|
||||
## Configuration
|
||||
### User home directory location
|
||||
*String CONFIG.all_homedir_pattern*
|
||||
|
||||
Customise user home directory hierarchy. Default is */home/\*/* to support a standard structure like */home/username/*
|
||||
|
||||
For example, you may have home directories in a location like */userdata/(first letter)/(username)* i.e. */userdata/a/auser*. The glob pattern would need to be updated to */userdata/i\*/\*/*
|
||||
|
||||
### Data directory name
|
||||
*String CONFIG.datadir*
|
||||
|
||||
Customise the name of the directory where user data is stored. Default is *.linkulator*.
|
||||
|
||||
### Data file
|
||||
*String CONFIG.datafile*
|
||||
|
||||
Customise the name of the file where user links and replies are stored. Default is *linkulator.data*
|
||||
|
||||
### Ignore file
|
||||
*String CONFIG.ignorefile*
|
||||
|
||||
Customise the name of the file where ignored users are stored. Default is *ignore*
|
17
linkulator
17
linkulator
|
@ -19,7 +19,6 @@ from config import CONFIG as config
|
|||
|
||||
username = getpass.getuser()
|
||||
|
||||
homedir_filepaths = "/home/*/"
|
||||
browser = "lynx"
|
||||
|
||||
help_text = """
|
||||
|
@ -83,14 +82,15 @@ def build_menu():
|
|||
linkulator_lines = []
|
||||
for filename in linkulator_files:
|
||||
with open(filename) as f:
|
||||
file_owner = PurePath(
|
||||
filename
|
||||
).parent.parent.name # EXTRACT USERNAME FROM PATH.
|
||||
# get file owner username from path
|
||||
file_owner = PurePath(filename).parent.parent.name
|
||||
if file_owner in ignore_names:
|
||||
continue ## IGNORE NAMES IN ignore_file
|
||||
# ignore names found in ignore file
|
||||
continue
|
||||
for line in f:
|
||||
if line.count("|") != pipe_count:
|
||||
continue ## IGNORE LINES THAT AREN'T FORMATTED PROPERLY.
|
||||
# ignore lines that fail validation
|
||||
continue
|
||||
line = line.rstrip("\n")
|
||||
split_line = line.split("|")
|
||||
split_line.insert(0, file_owner)
|
||||
|
@ -275,12 +275,11 @@ def reply(owner, tstamp, post_id):
|
|||
|
||||
comment = input("Enter your comment: ")
|
||||
|
||||
filename = "/home/" + username + "/.linkulator/linkulator.data"
|
||||
if os.path.exists(filename):
|
||||
if os.path.exists(config.my_datafile):
|
||||
append_write = "a" # append if already exists
|
||||
else:
|
||||
append_write = "w+" # make a new file if not
|
||||
with open(filename, append_write) as file:
|
||||
with open(config.my_datafile, append_write) as file:
|
||||
timestamp = str(time.time())
|
||||
file.write(timestamp + "|" + owner + "+" + tstamp + "|||" + comment + "\r")
|
||||
|
||||
|
|
Loading…
Reference in New Issue