8000 tools/normalise_mpconfigport.py: Add script to normalise config (WIP) by dpgeorge · Pull Request #7538 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

tools/normalise_mpconfigport.py: Add script to normalise config (WIP) #7538

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

Closed

Conversation

dpgeorge
Copy link
Member

No description provided.

@dpgeorge dpgeorge added the tools Relates to tools/ directory in source, or other tooling label Jul 13, 2021
@robert-hh
Copy link
Contributor
robert-hh commented Jul 13, 2021

This script does run on Debian 10, since the default Python version is 3.7. Python 3.7 does not support assignment expressions. Less elegant replacement:

def parse_config(filename, parse_section_names=False):
    config = collections.OrderedDict()
    section_num = 0
    section_comment = None
    with open(filename) as f:
        for line in f:
            m = re.match(r"#define (MICROPY_[A-Z0-9_]+) +(.+)", line)
            if m:
                if section_comment:
                    if parse_section_names:
                        config[f"_section{section_num}"] = section_comment
                    section_num += 1
                    section_comment = None
                config[m.group(1)] = m.group(2)
            else:
                m = re.match(r"/\* (.+) \*/", line)
                if m:
                    section_comment = m.group(1).strip()
                else:
                    m = re.match(r"// (Extended modules)", line)   
                    if m:
                        section_comment = m.group(1)

    return config

@codecov-commenter
Copy link
codecov-commenter commented Jul 13, 2021

Codecov Report

Merging #7538 (048bc42) into master (6430cd3) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7538   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files         154      154           
  Lines       19988    19988           
=======================================
  Hits        19646    19646           
  Misses        342      342           
Impacted Files Coverage Δ
py/runtime.c 99.23% <0.00%> (-0.16%) ⬇️
py/obj.c 96.82% <0.00%> (+0.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6430cd3...048bc42. Read the comment docs.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the tools-normalise-mpconfigport branch from df8dd48 to 048bc42 Compare July 13, 2021 12:32
@dpgeorge
Copy link
Member Author

I really like the walrus operator!

Anyway, updated to not use it.

@robert-hh
Copy link
Contributor

Thanks. Agreed that it looks much better with the walrus operator. But the new code variant looks good. Very clear.

@dpgeorge
Copy link
Member Author

This is not really needed now that we have ROM feature levels.

@dpgeorge dpgeorge closed this Jun 24, 2022
@dpgeorge dpgeorge deleted the tools-normalise-mpconfigport branch June 24, 2022 10:03
RetiredWizard pushed a commit to RetiredWizard/micropython that referenced this pull request Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relates to tools/ directory in source, or other tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0