forked from coreutils/gnulib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gnulib-tool.py: Reduce code duplication in file name transformations.
* pygnulib/functions.py: New file for shared functions between modules. Add a function based on functions removed from GLImport and GLTestDir. Accepts a single file name instead of a list. * pygnulib/GLImport.py (GLImport.prepare): Use the new function. (GLImport.rewrite_new_files, GLImport.rewrite_old_files): Remove functions. * pygnulib/GLTestDir.py (GLTestDir.execute): Use the new function. (GLTestDir.rewrite_files): Remove functions. * pygnulib/main.py (main): Remove unused function import. Use the new function.
- Loading branch information
1 parent
7941742
commit 9af79f6
Showing
5 changed files
with
88 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
2024-04-25 Collin Funk <[email protected]> | ||
|
||
gnulib-tool.py: Reduce code duplication in file name transformations. | ||
* pygnulib/functions.py: New file for shared functions between modules. | ||
Add a function based on functions removed from GLImport and GLTestDir. | ||
Accepts a single file name instead of a list. | ||
* pygnulib/GLImport.py (GLImport.prepare): Use the new function. | ||
(GLImport.rewrite_new_files, GLImport.rewrite_old_files): Remove | ||
functions. | ||
* pygnulib/GLTestDir.py (GLTestDir.execute): Use the new function. | ||
(GLTestDir.rewrite_files): Remove functions. | ||
* pygnulib/main.py (main): Remove unused function import. Use the new | ||
function. | ||
|
||
2024-04-25 Bruno Haible <[email protected]> | ||
|
||
doc: Remove documentation of IRIX as supported platform. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (C) 2002-2024 Free Software Foundation, Inc. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from __future__ import annotations | ||
|
||
import os.path | ||
from .constants import substart | ||
from .GLConfig import GLConfig | ||
|
||
|
||
def rewrite_file_name(file_name: str, config: GLConfig, also_tests_lib: bool = False) -> str: | ||
'''Replace auxdir, docbase, sourcebase, m4base and testsbase from their | ||
default to the ones specified in a GLConfig object. | ||
- file_name, the file name to transform, | ||
- config, the GLConfig storing directory names, | ||
- also_tests_lib, True if 'tests=lib/' should be replaced.''' | ||
if type(file_name) is not str: | ||
raise TypeError(f'file_name must be a str type, not {type(file_name).__name__}') | ||
auxdir = config['auxdir'] | ||
docbase = config['docbase'] | ||
sourcebase = config['sourcebase'] | ||
m4base = config['m4base'] | ||
testsbase = config['testsbase'] | ||
if file_name.startswith('build-aux/'): | ||
result = substart('build-aux/', '%s/' % auxdir, file_name) | ||
elif file_name.startswith('doc/'): | ||
result = substart('doc/', '%s/' % docbase, file_name) | ||
elif file_name.startswith('lib/'): | ||
result = substart('lib/', '%s/' % sourcebase, file_name) | ||
elif file_name.startswith('m4/'): | ||
result = substart('m4/', '%s/' % m4base, file_name) | ||
elif file_name.startswith('tests/'): | ||
result = substart('tests/', '%s/' % testsbase, file_name) | ||
elif also_tests_lib and file_name.startswith('tests=lib/'): | ||
result = substart('tests=lib/', '%s/' % testsbase, file_name) | ||
elif file_name.startswith('top/'): | ||
result = substart('top/', '', file_name) | ||
else: # file is not a special file | ||
result = file_name | ||
return os.path.normpath(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters