Thanks for the tip.

Actually, I over simplify for the sake of brevity. The goal is to be able
to add data to this file without changing the python code, because we need
to duplicate source code for the sake of making it work on Windows :( So we
try to reduce as much as possible the need to change the (duplicated)
source file.

On Fri, Nov 27, 2020 at 8:33 AM 'Felix Fontein' via Ansible Project <
[email protected]> wrote:

> Hi,
>
> > I've a collection where I would like to externalize an array of
> > strings. At run time, the collection will read their content and
> > create an array based on the file. The idea being that this list can
> > change without building again the collection.
>
> if the file is included in the collection, how can you update the file
> without building the collection?
>
> > I just wonder where, within my collection directory tree, to put this
> > data file (it can be txt, csv, or even yml) and which internal API
> > use to parse it.
>
> There's no internal API. You can place it whereever you want in the
> tree, there is no canonical place for it. I'd suggest to add some
> module_utils code for reading it, it can use os.path.dirname(__file__)
> to get hold of the module_utils directory path and load the file
> relative from there.
>
> I did something like that in one of my collections:
>
> https://github.com/felixfontein/ansible-tools/blob/main/plugins/filter/domain_suffix.py#L10
>
> https://github.com/felixfontein/ansible-tools/blob/main/plugins/public_suffix_list.dat
>
> Cheers,
> Felix
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/20201127083247.133133f7%40rovaniemi
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALuBA_otT5%3DGSC%3D07D3cAT2Ynro0i4GzDDn%2B9bkQPTxgWiXRBg%40mail.gmail.com.

Reply via email to