Skip to content

feat: new subcommand, dictknife describe#151

Open
podhmo wants to merge 5 commits into
masterfrom
describe
Open

feat: new subcommand, dictknife describe#151
podhmo wants to merge 5 commits into
masterfrom
describe

Conversation

@podhmo
Copy link
Copy Markdown
Owner

@podhmo podhmo commented Jul 1, 2019

$ dictknife describe person.json -o json
{
  "@type": "dict",
  "@keys": [
    "age",
    "father",
    "mother",
    "name"
  ],
  "@max_depth": 2
}
$ dictknife describe -d 1 person.json -o json
{
  "age": 20,
  "name": "foo",
  "father": {
    "@type": "dict",
    "@keys": [
      "age",
      "name"
    ],
    "@max_depth": 1
  },
  "mother": {
    "@type": "dict",
    "@keys": [
      "age",
      "name"
    ],
    "@max_depth": 1
  }
}
$ dictknife describe -d 2 person.json -o json
{
  "age": 20,
  "name": "foo",
  "father": {
    "age": 40,
    "name": "boo"
  },
  "mother": {
    "age": 40,
    "name": "bar"
  }
}

@podhmo
Copy link
Copy Markdown
Owner Author

podhmo commented Jul 1, 2019

with --minimum

$ dictknife describe --minimum person.json -o json
"dict@depth:2@length:4"
$ dictknife describe --minimum -d 1 person.json -o json
{
  "age": 20,
  "name": "foo",
  "father": "dict@depth:1@length:2",
  "mother": "dict@depth:1@length:2"
}
$ dictknife describe --minimum -d 2 person.json -o json
{
  "age": 20,
  "name": "foo",
  "father": {
    "age": 40,
    "name": "boo"
  },
  "mother": {
    "age": 40,
    "name": "bar"
  }
}

@podhmo
Copy link
Copy Markdown
Owner Author

podhmo commented Feb 8, 2020

⚠️ merge to shape?

@podhmo
Copy link
Copy Markdown
Owner Author

podhmo commented Jul 5, 2025

This pull request introduces a new describe command to the dictknife library, enabling users to analyze and summarize the structure of dictionaries with configurable depth and output formats. Additionally, minor syntax updates were made across several function definitions for consistency.

New Feature: Describe Command

  • Added a new describe function in dictknife/commands/dictknife.py to summarize dictionary structures with options for depth, minimization, and format customization.
  • Integrated the describe command into the CLI by updating the print_help method and adding relevant arguments such as depth, minimum, input/output format, and source/destination files.
  • Implemented the Describer class in dictknife/describe.py, which recursively analyzes dictionary structures with configurable behavior for the last level of recursion. Includes helper functions on_last_default and on_last_minimize for summarization.

Code Consistency Updates

  • Updated function definitions in dictknife/commands/dictknife.py to include trailing commas in parameter lists for improved readability and consistency. [1] [2] [3] [4] [5]
  • Modified CLI argument definitions to include trailing commas for consistency in main() method. [1] [2]

@podhmo podhmo changed the title feat: describe feat: new subcommand, dictknife describe Jul 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant