fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

#jinja

1 post1 participant1 post today
Replied to Franck Nijhof

@frenck My biggest #Jinja gripe, in HA context, is unavailable/unknown. Semantically these aren't really values. In creating a template sensor for the difference of two temperatures, I have to check for them, and in general there are a lot of if foo not unavailable and foo not unknown.

What I would like is propagation, so that any template whose output expression has used a variable that is unknown has value unknown, and then similarly for unavailable.

🚀 𝗖𝗮𝗹𝗹𝗶𝗻𝗴 𝗮𝗹𝗹 𝗛𝗼𝗺𝗲 𝗔𝘀𝘀𝗶𝘀𝘁𝗮𝗻𝘁 𝘁𝗲𝗺𝗽𝗹𝗮𝘁𝗲 𝘄𝗶𝘇𝗮𝗿𝗱𝘀! 🧙‍♂️

I’m working on extending the template engine with some new functions, filters, and tests, for example:

✅ flatten(list_of_lists) – Flattens nested lists into a single list
✅ combine(dict1, dict2, ...) – Merges multiple dictionaries together

Now, I need your input! 💡

🔍 What template functions, filters, or tests would make your automations easier?
💬 What repetitive Jinja gymnastics do you find yourself doing over and over?

Continued thread

You know, the _one_ time I'd have actually appreciated unsolicited advice, the fedi doesn't deliver.

Because I'm indeed wondering if there are good alternatives to #Jinja in #Python.

Replied in thread

@JingleDJ Thanks! I've done a bit more reading and experimentation and (along with some other suggestions from folk) I'm fairly confident about things. But it's not natural is it?! Basically, I still agree with this guy: reddit.com/r/homeassistant/com

Anyway, it is what it is. No changing it now - although installing PyScript or AppDaemon is appealing (even though I've never used Python in anger (yet...) - I'd still be a lot more productive I think)...
#HomeAssistant #Jinja #Python #WhyWhyWhy #HoHum

Ok, I've got a #cloudengineer spicy 🌶️ take that will lose some followers.

(Preface: I've used #terraform and built up some moderately complex infra with it. Nothing crazy. I'm not an expert, but definitely not new to it either.)

I will take #ansible every day of the week over TF for any task that's not just spinning up vanilla, CSP-specific infra. That's the one place where TF shines, and everything else imo is just unnecessarily irritating.

Ansible is cleaner, easier to reason about, and just makes sense to my brain.

I think it's TF's syntax. It reminds me of #jinja or #golang template language with the unintuitive way of evaluating conditions and calling functions.

I said what I said.

Just rewriting #jinja python code generator to #libCST . So far it takes more code to do the same but it's much simpler to do the hard stuff, especially when there's a lot of conditionals.

Take annotated class field: can be generic or not, can have annotated metadata or not. Annotated metadata may be name (class or function), generic or not, or a call, and so on.

A big nuisance of libCST is indentation - it belongs to the previous node, even though we tend to think as part of the next one. For an indented language it's rather weird design decision.

Создание динамических таблиц в SuperSet

Однажды в студеную зимнюю пору из-за морей, из-за океанов прилетело известие: лицензии не выдаем, тех.поддержку не оказываем, а можем и вовсе отключить все системы. В компании погоревали, но делать нечего, решили переходить на новые системы, да такие, чтобы не смогли в любой момент их превратить в тыкву. И стали смотреть в сторону open-sourсe решений. Проанализировали несколько BI-систем и остановились на SuperSet. /*После QlikSense и Tableau казалось, что это так себе затея*/ Меня зовут Корнева Настя, я отвечаю за разработку BI-отчетности в Magnit Tech в рамках проекта Аналитика УЦП (управление цепочками поставок). В этой статье поделюсь нашим опытом создания динамических сводных таблиц в BI-инструменте SuperSet, что будет полезно разработчикам отчетности и всем, кому интересна тематика.

habr.com/ru/companies/magnit/a

ХабрСоздание динамических таблиц в SuperSetОднажды в студеную зимнюю пору из-за морей из-за океанов прилетело известие: лицензии не выдаем, тех. поддержку не оказываем, а можем и вовсе отключить все системы. В компании погоревали, но делать...

Hey #Ansible and/or #Jinja crowd: Any idea how I can, reasonably easily, transform the 'records_in' data into 'records_out'?

What I basically need is to merge these records by _two_ keys: prefix and type. If it was only one key, this would probably be a candidate for the mergeby filter (docs.ansible.com/ansible/lates), but no, it should only merge items where both of these keys are identical.

Note that I'm converting 'value' into a list on the fly here, too, where necessary. That's only nice-to-have.

Пара шаблонов кастомизированных элементов Handlebars для Apache Superset — 2

Причины написания статьи, общие правила использования handlebars в superset и советы содержатся в первой статье , поэтому сразу опишу следующие шаблоны.

habr.com/ru/articles/853476/

ХабрПара шаблонов кастомизированных элементов Handlebars для Apache Superset — 2Готовые шаблоны Handlebars для Apache Superset Причину написания статьи, основные правила использования Handlebars для Superset и подсказки описывает первая часть статьи , поэтому повторяться не буду...

Пара шаблонов кастомизированных элементов Handlebars для Apache Superset

Apache Superset всё чаще становится выбором для визуализации данных благодаря открытому коду. Но, увы, столкнувшись с его ограничениями и тонкостями, даже самые опытные пользователи могут столкнуться с трудностями. Есть много ограничений, которые требуют обращения за доработками к разработчикам, но с помощью шаблона Handlebars в сочетании с шаблонизацией jinja некоторые трудности можно обойти. С его помощью можно внедрить web-верстку прямо в ваши дашборды, обходя множество подводных камней. Готовых шаблонов для handlebars (superset) мало, так как это довольно трудоемкая задача, часто выходящая за рамки работы с готовыми BI-системами.

habr.com/ru/articles/851756/

ХабрПара шаблонов кастомизированных элементов Handlebars для Apache SupersetГотовые шаблоны Handlebars для Apache Superset Apache Superset всё чаще становится выбором для визуализации данных благодаря открытому коду. Но, увы, столкнувшись с его ограничениями и тонкостями,...

OK, I have a #python #flask #jinja issue that the docs aren't making clear. Say I have an app that's hosted on multiple domains. I want some footer link to be to foo.$domain for whatever domain was used to reach the app.

url_for seems like it will provide protocol + domain. it's not clear if there's a clean way to provide "foo.example.com" for whatever value of "example.com" and a static value of "foo".

Seems like this should be doable. Any suggestions?