<commit_before>#!/usr/bin/env python3

import os

import path_utils
import fsquery
import git_lib

import terminal_colors
import mvtools_envvars

class gvbexcept(RuntimeError):
    def __init__(self, msg):
        self._set_message(msg)
    def _get_message(self):
        return self._message
    def _set_message(self, message):
        self._message = message
    message = property(_get_message, _set_message)

def filter_git_only(path_list):

    """ filter_git_only
    given path_list, will filter elements if they point to a git repository (.git folder)
    returns a subset of path_list that do point to a git repository's git folder
    """

    ret = []
    for d in path_list:
        if d.endswith(".git") or d.endswith(".git" + os.sep):
            ret.append(d)
    return ret

def pluck_dotgit(path_list):

    """ pluck_dotgit
    on success, returns a list that is a copy of the given list, with the trailing ".git" removed off the items
    returns None on failures
    """

    if path_list is None:
        return None

    ret_list = []
    for it in path_list:
        local_it = it
        if it.endswith(os.sep): # plucks out the trailing "/" on unices
            local_it = it[:len(it)-1]
        if local_it.endswith(".git"):
            local_it = path_utils.backpedal_path(local_it)
        ret_list.append(local_it)

    return ret_list

def filter_remotes(remotes, options):

    if remotes is None or options is None:
        return None

    """ filter_remotes
    on success, returns a 3-level dict of filtered remotes,
    according to passed |options|
    on failure, returns None

    valid options are:
    xor-remotename
    not-remotename

    xor-remoteop
    not-remoteop<commit_msg>git_visitor_base: removed usages of os.sep<commit_after>#!/usr/bin/env python3

import os

import path_utils
import fsquery
import git_lib

import terminal_colors
import mvtools_envvars

class gvbexcept(RuntimeError):
    def __init__(self, msg):
        self._set_message(msg)
    def _get_message(self):
        return self._message
    def _set_message(self, message):
        self._message = message
    message = property(_get_message, _set_message)

def filter_git_only(path_list):

    """ filter_git_only
    given path_list, will filter elements if they point to a git repository (.git folder)
    returns a subset of path_list that do point to a git repository's git folder
    """

    ret = []
    for d in path_list:
        if path_utils.filter_remove_trailing_sep(d).endswith(".git"):
            ret.append(d)
    return ret

def pluck_dotgit(path_list):

    """ pluck_dotgit
    on success, returns a list that is a copy of the given list, with the trailing ".git" removed off the items
    returns None on failures
    """

    if path_list is None:
        return None

    ret_list = []
    for it in path_list:
        local_it = path_utils.filter_remove_trailing_sep(it)
        if local_it.endswith(".git"):
            local_it = path_utils.backpedal_path(local_it)
        ret_list.append(local_it)

    return ret_list

def filter_remotes(remotes, options):

    if remotes is None or options is None:
        return None

    """ filter_remotes
    on success, returns a 3-level dict of filtered remotes,
    according to passed |options|
    on failure, returns None

    valid options are:
    xor-remotename
    not-remotename

    xor-remoteop
    not-remoteop
{'fraction_non_alphanumeric': 0.07548273844353423, 'fraction_numerical': 0.001462843768285547, 'mean_word_length': 2.8329596412556053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1340316', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1037, 'n_words': 334}