<commit_before>""" Common tools for tsrc commands """

import os

import path

import tsrc
import tsrc.workspace


def find_workspace_path():
    """ Look for a workspace root somewhere in the upper directories
    hierarchy

    """
    head = os.getcwd()
    tail = True
    while tail:
        tsrc_path = os.path.join(head, ".tsrc")
        if os.path.isdir(tsrc_path):
            return path.Path(head)
        tbuild_yml_path = os.path.join(head, "tbuild.yml")
        if os.path.exists(tbuild_yml_path):
            return path.Path(head)

        else:
            head, tail = os.path.split(head)
    raise tsrc.Error("Could not find current workspace")


def get_workspace(args):
    if args.workspace_path:
        workspace_path = path.Path(args.workspace_path)
    else:
        workspace_path = find_workspace_path()
    return tsrc.workspace.Workspace(workspace_path)
<commit_msg>Don't stop at tbuild.yml to find manifest directory<commit_after>""" Common tools for tsrc commands """

import os

import path

import tsrc
import tsrc.workspace


def find_workspace_path():
    """ Look for a workspace root somewhere in the upper directories
    hierarchy

    """
    head = os.getcwd()
    tail = True
    while tail:
        tsrc_path = os.path.join(head, ".tsrc")
        if os.path.isdir(tsrc_path):
            return path.Path(head)

        else:
            head, tail = os.path.split(head)
    raise tsrc.Error("Could not find current workspace")


def get_workspace(args):
    if args.workspace_path:
        workspace_path = path.Path(args.workspace_path)
    else:
        workspace_path = find_workspace_path()
    return tsrc.workspace.Workspace(workspace_path)

{'fraction_non_alphanumeric': 0.09633569739952719, 'fraction_numerical': 0.0, 'mean_word_length': 2.7706013363028954, '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': '5791527', 'n_tokens_mistral': 537, 'n_tokens_neox': 531, 'n_words': 136}