diff options
| author | Eike Ziller <eike.ziller@qt.io> | 2024-11-12 14:03:49 +0100 |
|---|---|---|
| committer | Eike Ziller <eike.ziller@qt.io> | 2024-11-12 13:50:51 +0000 |
| commit | e484dc5994899d9f68ad25d4f3b21a07a096d70f (patch) | |
| tree | 745f66a6d56594c9eb0f2c8b5cf65e3206cbb810 /scripts/common.py | |
| parent | 9fcb8e8c794109c4a9cd28fecf0652a570fe649b (diff) | |
Scripts: Share a useful function
To be used in upcoming scripts
Change-Id: I56bb024f35b1feb156deae122235d09116d4eaa1
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'scripts/common.py')
| -rw-r--r-- | scripts/common.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/common.py b/scripts/common.py index 45843b9fddb..e343a46dad1 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -4,6 +4,7 @@ from __future__ import annotations import argparse import asyncio +from itertools import islice import os import locale from pathlib import Path @@ -62,6 +63,13 @@ def get_commit_SHA(path): return git_sha +def get_single_subdir(path: Path): + entries = list(islice(path.iterdir(), 2)) + if len(entries) == 1: + return path / entries[0] + return path + + def sevenzip_command(threads=None): # use -mf=off to avoid usage of the ARM executable compression filter, # which cannot be extracted by p7zip |
