bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WIP patch to reduce rewrite_filename duplication


From: Bruno Haible
Subject: Re: WIP patch to reduce rewrite_filename duplication
Date: Thu, 25 Apr 2024 22:18:38 +0200

Hi Collin,

> > IMO, the creation of a rewrite_file_name method (singular! you mentioned
> > a couple of days ago that the ability to rewrite a single file name is
> > one of the motivations for this refactoring) in a central place goes in
> > the correct direction. However, moving knowledge about 'cache' and 'config'
> > into GLFileTable does not.
> 
> Sure, I agree. Though I'm not sure the best place to put it. All of
> our non-private functions are in constants.py, but this function seems
> out of place there. Since all of the functions there are string
> helpers and such. In other words, no GL* classes are imported there.

I agree, it's out-of-place in constants.py.

> Maybe it would be best to create a functions.py file?

Sounds reasonable, yes.

> For the actual function it would be something like this:
> 
>     def rewrite_file_name(config: GLConfig,
>                           file_name: str,
>                           also_tests_lib: bool = False) -> str:
>         ...
>         if also_tests_lib and file_name.startswith('tests=lib/'):
>            # OK

Yep, that's the right way to do it. Maybe file_name should come first
(by the usual heuristic that the argument that shows most variation
comes first)?

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]