Skip to main content

No project description provided

Project description

lkmlfmt

lkmlfmt formats your LookML files including embedded SQL and HTML.

Installation

pip install lkmlfmt

CLI

Use lkmlfmt command to format your LookML file(s). For further information, use --help option.

lkmlfmt [OPTIONS] [FILE]...

API

from lkmlfmt import fmt

lkml = fmt("""\
view: view_name {
  derived_table: {
    sql:
    with cte as (
      select col1, col2 from tablename
      where ts between current_date()-7 and current_date())
    select {% if true %} col1 {% else %} col2 {% endif %} from cte
    ;;
  }
}
""")

assert lkml == """\
view: view_name {
  derived_table: {
    sql:
      with
        cte as (
          select col1, col2
          from tablename
          where ts between current_date() - 7 and current_date()
        )
      select
        {% if true %} col1
        {% else %} col2
        {% endif %}
      from cte
    ;;
  }
}
"""

GitHub Actions

To check if your LookML files are formatted.

on: [pull_request]
jobs:
  format-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          # '>=3.11' is required
          python-version: '3.11'

      # you should specify the version of lkmlfmt!
      - run: pip install lkmlfmt
      - run: lkmlfmt --check path/to/lookml/file/or/directory

To format arbitrary branch and create pull request.

on: [workflow_dispatch]
jobs:
  format-pr:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          # '>=3.11' is required
          python-version: '3.11'

      # you should specify the version of lkmlfmt!
      - run: pip install lkmlfmt
      - run: lkmlfmt path/to/lookml/file/or/directory

      # check the documentation especially about workflow permissions
      # https://github.com/marketplace/actions/create-pull-request
      - uses: peter-evans/create-pull-request@v5
        with:
          branch: format/${{ github.ref_name }}

Feedback

I'm not ready to accept pull requests, but your feedback is always welcome. If you find any bugs, please feel free to create an issue.

See also

In default, lkmlfmt formats embedded sql using sqlfmt.

You can install plugins to change the format of embeded looker expression, sql or html. They are distributed under their own licenses, so please check if they are suitable for your purpose.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lkmlfmt-0.0.15.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lkmlfmt-0.0.15-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file lkmlfmt-0.0.15.tar.gz.

File metadata

  • Download URL: lkmlfmt-0.0.15.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for lkmlfmt-0.0.15.tar.gz
Algorithm Hash digest
SHA256 06e133a08adb71e4d8375ca156325ab1b485d25f18b15cc2823f1f1918056076
MD5 da1ff3f94ded3fb61e866edf2da17bcb
BLAKE2b-256 9eb26b4f22fdd8e6503baf670cbc3da8a860d322932c9f31d42e250d034f7e14

See more details on using hashes here.

File details

Details for the file lkmlfmt-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: lkmlfmt-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for lkmlfmt-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 82f9dea471733141b56d0dabbe3a9a2079efd78bbcb2e20a3b55b198038a8e72
MD5 0d31221edc59f2d03d52177328badda5
BLAKE2b-256 031c3fd27cd595af54563332c6e8c2ffc6078833c86a40c0722efa7610b6eede

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page