Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Dump headers of parent nested tables

オープン
#447 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

エントリーポイント tomlkit.dumps(my_dict) から開始し、現在の出力を要求されている親テーブルのヘッダーと比較します。望ましいフォーマットをどのように公開できるかを判断し、その後、ネストされたテーブル apps.test.whatever_1 と apps.test.whatever_2 がヘッダーとインデントを保持していることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Hello,

  1. I was trying to convert this python dictionnary

    my_dict = {
        "apps": {
            "test": {
                "whatever_1": {
                    "date": "2025-12-16",
                },
                "whatever_2": {
                    "date": "2025-12-16",
                },
            },
        },
    }
    

    ...to this TOML output:

    [apps]
        [apps.test]
            [apps.test.whatever_1]
            date = "2025-12-16"
            [apps.test.whatever_2]
            date = "2025-12-16"
    
    
  2. I first had great hopes with:

    print(tomlkit.dumps(my_dict))
    

    but that outputs

    [apps.test.whatever_1]
    date = "2025-12-16"
    
    [apps.test.whatever_2]
    date = "2025-12-16"
    
  3. With a bit of pain, I eventually manage to get the expected output using:

    my_dict_new = tomlkit.document()
    for category_name, apps in my_dict.items():
        cat = tomlkit.table(False)
        for app_name, app_reports in apps.items():
            app = tomlkit.table(False).indent(4)
            for report_name, report_data in app_reports.items():
                rep = tomlkit.table(False).indent(4)
                for key, val in report_data.items():
                    rep.add(key, val).indent(4) 
                app.append(report_name, rep)
            cat.append(app_name, app)
        my_dict_new.append(category_name, cat)
    
    print(tomlkit.dumps(my_dict_new))
    

As this the reverse scenario from #47 and #107 in which the target output here seemed to be the default .dumps() output at the time, I wonder whether there would be a quicker way to access the old behavior again (i.e. dump headers for parent nested headers) ?

主要言語
Python
スター
850
フォーク
163
平均マージ
13分
マージ済み PR(30日)
2

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python-poetry/tomlkit のほかの issue

python-poetry/tomlkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。