Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing entries #77

Closed
pdimop opened this issue Jul 4, 2022 · 3 comments
Closed

missing entries #77

pdimop opened this issue Jul 4, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@pdimop
Copy link

pdimop commented Jul 4, 2022

DATA_TO_PARSE = '''
lsp "lsp100"
    primary "name"
        include "1"
        exclude "2"
    exit
    secondary "name"
        include "3"
        exclude "4"
    exit
exit
lsp "lsp101"
    primary "name"
        include "5"
        exclude "6"
    exit
    secondary "name"
        include "7"
        exclude "8"
    exit
exit
'''

TTP_TEMPLATE = '''
<group name="lsp**.{{ lspname }}**">
lsp "{{ lspname | _start_ }}"
    <group name="primary**.{{ primaryname }}**">
    primary "{{ primaryname | _start_ }}"
        <group name="include**.{{ item }}**">
        include "{{ item | _start_ }}"
        </group>
        <group name="exclude**.{{ item }}**">
        exclude "{{ item | _start_ }}"
        </group>
    exit{{ _end_ }}
    </group>
    <group name="secondary**.{{ secondaryname }}**">
    secondary "{{ secondaryname | _start_ }}"
        <group name="include**.{{ item }}**">
        include "{{ item | _start_ }}"
        </group>
        <group name="exclude**.{{ item }}**">
        exclude "{{ item | _start_ }}"
        </group>
    exit{{ _end_ }}
    </group>
exit{{ _end_ }}
</group>
'''

output=

[[{'lsp': {'lsp100': {'primary': {'name': {'exclude': {'2': {}}, 'include': {'1': {}}}},
                      'secondary': {'name': {'exclude': {'4': {}}, 'include': {'3': {}}}}},
           'lsp101': {'primary': {'name': {                        'include': {'5': {}}}},
                      'secondary': {'name': {'exclude': {'8': {}}, include': {'7': {}}}}}}}]]

missing 'exclude':'6'

@dmulyalin
Copy link
Owner

@pdimop thank you for raising this issue, likely a bug, will have a look to fix it, in a meantime this template may give results you likely looking for:

<group name="lsp**.{{ lspname }}**">
lsp "{{ lspname | _start_ }}"
    <group name="{{ type }}**.{{ primaryname }}**">
    {{ type }} "{{ primaryname | _start_ }}"
        <group name="include**.{{ item }}**">
        include "{{ item | _start_ }}"
        </group>
        <group name="exclude**.{{ item }}**">
        exclude "{{ item | _start_ }}"
        </group>
    exit{{ _end_ }}
    </group>
exit{{ _end_ }}
</group>

@dmulyalin
Copy link
Owner

Added fix in latest commit , if you'd like, feel free to install from master and test it:

python3 -m pip install git+https://github.com/dmulyalin/ttp

@pdimop
Copy link
Author

pdimop commented Jul 9, 2022

thank you! it very nice to use a module with so active Contributors

@pdimop pdimop closed this as completed Jul 9, 2022
@dmulyalin dmulyalin added the bug Something isn't working label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants