diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-09-19 19:21:11 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-09-19 19:21:11 +0200 |
| commit | a3324b7e71ec48daab81981e7d85967a590d4f79 (patch) | |
| tree | def4a8d901d9a56047a0e63f5f3d93803c93ee87 /g2h/file.py | |
| parent | bd403e6ab18d5cc7818e86d43c3ca0b15c5e53a1 (diff) | |
| download | git2hugo-a3324b7e71ec48daab81981e7d85967a590d4f79.tar.gz | |
g2h: Add utility script
Also move the sources into the more conventional src/g2h dir
Diffstat (limited to 'g2h/file.py')
| -rw-r--r-- | g2h/file.py | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/g2h/file.py b/g2h/file.py deleted file mode 100644 index e07f251..0000000 --- a/g2h/file.py +++ /dev/null @@ -1,27 +0,0 @@ -import os - -def generate_breadcrumbs(content_subdir, commit, dir, files): - breadcrumbs = '[/](/{})'.format(os.path.join(content_subdir, tree_join(commit, ''))) - subpath = '' - for segment in dir.split(os.sep): - if not segment or len(segment) == 0: - continue - subpath = os.path.join(subpath, sanitize_file_name(segment, files)) - breadcrumbs += '/[{}](/{})'.format(segment, os.path.join(content_subdir, tree_join(commit, subpath))) - return breadcrumbs - - -def sanitize_file_name(file_name, files): - if not file_name.startswith('.'): - return file_name - - file_names = [ f.name for f in files ] - for i in range(1, 10): - new_name = file_name.replace('.', '_' * i, 1) - if not new_name in file_names: - return new_name - - raise RuntimeError('Couldn not find unused sanitized file name') - -def tree_join(commit, path): - return os.path.join(commit.hexsha, 't', path) |