MemOpt #18
@@ -72,18 +72,16 @@ def add_longest_common_two_local(df, col="filename_x", new_col="longestcfp", min
|
||||
return df
|
||||
|
||||
|
||||
def export_groups_for_review(df, col="filename_x", group_col="longestcfp", csv_path="filegroups_review.csv"):
|
||||
def export_groups_for_review(df, col="filename_x", group_col="longestcfp"):
|
||||
"""
|
||||
Compute longest common paths, group filepaths, write CSV for review.
|
||||
"""
|
||||
df = add_longest_common_two_local(df, col=col, new_col=group_col)
|
||||
grouped = df.groupby(group_col)[col].apply(list).reset_index()
|
||||
grouped.to_csv(csv_path, index=False)
|
||||
print(f"Grouped file list saved to: {csv_path}")
|
||||
return grouped, df
|
||||
|
||||
|
||||
def mask_from_csv(df, csv_path, filepath_col="filename_x", group_col="longestcfp"):
|
||||
def mask_from_csv(df, csv_path, filepath_col):
|
||||
"""
|
||||
Reads reviewed CSV of groups, keeps only files in approved groups.
|
||||
"""
|
||||
@@ -98,7 +96,8 @@ def mask_from_csv(df, csv_path, filepath_col="filename_x", group_col="longestcfp
|
||||
|
||||
# Keep only rows in df that are in approved_files
|
||||
masked_df = df[df[filepath_col].isin(approved_files)].copy()
|
||||
return masked_df
|
||||
remainder = df[~df[filepath_col].isin(approved_files)].copy()
|
||||
return masked_df, remainder
|
||||
|
||||
def filter_and_drop(approved, eligiblepaths, min_hashes):
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2025 James Brotosky, Brandon Wickline
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
def addHash(policy, hash):
|
||||
pass
|
||||
|
||||
def addPath(policy, hash):
|
||||
pass
|
||||
Reference in New Issue
Block a user