Fixed merge conflict, added addition item for ignore
This commit is contained in:
parent
3645c1f4ef
commit
7c28f8e4d4
|
@ -1 +1,2 @@
|
|||
__pycache__
|
||||
.mypy_cache
|
||||
|
|
2
data.py
2
data.py
|
@ -81,7 +81,7 @@ def get(config, ignore_names):
|
|||
link_data = linkulator_lines
|
||||
|
||||
## THIS IS SUPPOSED TO SORT ALL LINKS BY CREATION DATE. NEED TO CONFIRM THAT IT WORKS.
|
||||
link_data.sort(key=lambda x: x[2])
|
||||
link_data.sort(key=lambda x: x[2], reverse=True)
|
||||
|
||||
category_counts.clear() ## CLEAR SO WE DON'T DOUBLE-COUNT IF FNC RUN MORE THAN ONCE.
|
||||
for line in link_data:
|
||||
|
|
58
linkulator
58
linkulator
|
@ -13,6 +13,7 @@ from glob import glob
|
|||
from pathlib import Path, PurePath
|
||||
from shutil import which
|
||||
|
||||
import data
|
||||
import config
|
||||
import posts
|
||||
|
||||
|
@ -61,61 +62,14 @@ def parse_ignore_file():
|
|||
|
||||
|
||||
def build_menu():
|
||||
## WHENEVER THIS FUNCTION IS CALLED, THE DATA IS REFRESHED FROM FILES. SINCE
|
||||
## DISK IO IS PROBABLY THE HEAVIEST PART OF THIS SCRIPT, DON'T DO THIS OFTEN.
|
||||
|
||||
files_pattern = str(
|
||||
PurePath(config.PATHS.all_homedir_pattern).joinpath(
|
||||
config.PATHS.datadir, config.PATHS.datafile
|
||||
)
|
||||
)
|
||||
linkulator_files = glob(files_pattern)
|
||||
|
||||
global link_data
|
||||
linkulator_lines = []
|
||||
for filename in linkulator_files:
|
||||
with open(filename) as f:
|
||||
# get file owner username from path
|
||||
file_owner = PurePath(filename).parent.parent.name
|
||||
if file_owner in ignore_names:
|
||||
# ignore names found in ignore file
|
||||
continue
|
||||
for line in f:
|
||||
if line.count("|") != pipe_count:
|
||||
# ignore lines that fail validation
|
||||
continue
|
||||
line = line.rstrip("\n")
|
||||
split_line = line.split("|")
|
||||
if split_line[0] and float(split_line[0]) < time.time(): # ONLY USE LINK IF DATE IS EARLIER THAN NOW
|
||||
split_line.insert(0, file_owner)
|
||||
linkulator_lines.append(split_line) ## creating a list of lists
|
||||
|
||||
if len(linkulator_lines) == 0:
|
||||
print("It looks link there are no links yet. Run 'linkulator -p' to add one.")
|
||||
exit()
|
||||
|
||||
i = 1
|
||||
for idx, line in enumerate(linkulator_lines):
|
||||
if line[2] == "": # CREATE/INSERT PARENT ID:
|
||||
linkulator_lines[idx].insert(0, i)
|
||||
i = i + 1
|
||||
else: ## NOT PARENT, SO NO PARENT ID
|
||||
linkulator_lines[idx].insert(0, "")
|
||||
link_data = linkulator_lines
|
||||
|
||||
## THIS IS SUPPOSED TO SORT ALL LINKS BY CREATION DATE. NEED TO CONFIRM THAT IT WORKS.
|
||||
link_data.sort(key=lambda x: x[2], reverse=True)
|
||||
|
||||
global categories
|
||||
global category_counts
|
||||
categories = []
|
||||
category_counts.clear() ## CLEAR SO WE DON'T DOUBLE-COUNT IF FNC RUN MORE THAN ONCE.
|
||||
for line in link_data:
|
||||
if line[4] not in categories and line[4] != "":
|
||||
categories.append(line[4])
|
||||
category_counts[line[4]] = 1
|
||||
elif line[4] in categories:
|
||||
category_counts[line[4]] = category_counts[line[4]] + 1
|
||||
|
||||
link_data, categories, category_counts = data.get(config, ignore_names)
|
||||
if len(link_data) == 0:
|
||||
print("It looks link there are no links yet. Run 'linkulator -p' to add one.")
|
||||
graceful_exit()
|
||||
|
||||
|
||||
def print_categories():
|
||||
|
|
Loading…
Reference in New Issue