@danielmkovalik · Post #2784 · 10.09.2025 г., 12:15
Israel bombs #Qatar with the blessing of the U.S., further eroding the rule of law in the world and destroying any credibility they have left.
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #121 · 20 јул.
Регулярно требуется преобразовать какой-либо текст в максимально совместимый текст для URL, имени файла, имени объекта в каком-то софте и тд. Требования совместимости простые: в тексте должны быть только допустимые символы. Обычно это a-z, 0-9 и "_" или "-". То есть, только прописные буквы латинского алфавита и цифры (как пример). Допустим, нам нужно название статьи в блоге преобразовать в slug для добавления его в URL этой статьи. Как это лучше всего сделать? В Django по умолчанию есть готовая функция slugify для таких случаев. Но я её никогда не использую. Почему? Потому что её недостаточно! Приведём пример >>> from django.utils.text import slugify >>> slugify('This is a Title') 'this-is-a-title' Пока всё отлично >>> slugify('This is a "Title!"') 'this-is-a-title' Спец символы удалились, всё хорошо. >>> slugify('Это заголовок статьи') '' Вот и приехали 😢. Если текст не английский то буквы просто игнорируются. Можно это поправить >>> slugify('Это заголовок статьи', allow_unicode=True) 'это-заголовок-статьи' Но тогда мы не вписываемся в условие. У нас появилась кириллица в тексте. Так как я часто пишу сайты для русскоязычных пользователей эта проблема весьма актуальна. Я не использую стандартную функцию и всегда пишу свою. Оригинал я не беру в расчёт и пишу полностью свою функцию. И так, по порядку: 🔸1. Исходный текст: >>> text = 'Мой заголовок №10 😁!' Взял специально посложней со специальными символами. 🔸2. Транслит Необходимо сделать транслит всех символов в латиницу. Здесь очень выручает библиотека unidecode. Помимо простого транслита кириллицы в латиницу она умеет преобразовывать спец символы и иероглифы в текстовые аналоги. from unidecode import unidecode >>> unidecode("Ñ Σ ® µ ¶ ¼ 月 山") 'N S (r) u P 1/4 Yue Shan' Очень крутая библиотека, советую👍 В нашем случае получаем такое преобразование: >>> text = unidecode(text) >>> print(text) 'Moi zagolovok No. 10 !' Отличный транслит. Смайл просто удалился, хотя я ждал что-то вроде :). Ну и ладно, всë равно невалидные символы. А еще наш код уже поддерживает любой язык, будь то хинди или корейский. 🔸4. Фильтр символов Unidecode не занимается фильтрацией по недопустимым символам. Это мы делаем в следующем шаге через regex. Просто заменим все символы на "_" если они вне указанного диапазона. >>> text = re.sub(r'[^a-zA-Z0-9]+', '_', text) >>> print(text) 'Moi_zagolovok_No_10_' Символ "+" в паттерне выручает когда несколько недопустимых символов идут рядом. Все они заменяются на один символ "_". 🔸5. Slugify Осталось удалить лишние символы по краям и сделать нижний регистр >>> text = text.strip('_').lower() >>> print(text) 'moi_zagolovok_no_10' Получаем отличный slug! 😎 🌎 Полный код в виде функции. ______________ PS. Проверку что в строке остался хоть один допустимый символ я бы вынес в отдельную функцию. #libs#tricks#django
Пребарај: #qatar
@danielmkovalik · Post #2784 · 10.09.2025 г., 12:15
Israel bombs #Qatar with the blessing of the U.S., further eroding the rule of law in the world and destroying any credibility they have left.
Hashtags
@VOYAGE · Post #1704 · 30.03.2026 г., 12:14
🪩 A breathtaking night party on the rooftop of the 36th floor at Raffles Doha, offering stunning views of Lusail city. #Qatar | @voyage
Hashtags
@VOYAGE · Post #1383 · 08.04.2025 г., 12:14
🪩 A breathtaking night party on the rooftop of the 36th floor at Raffles Doha, offering stunning views of Lusail city. #Qatar | @voyage
Hashtags
@IHMA_matbuotkotibi · Post #674 · 08.11.2025 г., 05:35
09:00 08.11.2025 Dohada “O‘zbekiston. Ochiq eshiklar mamlakati” Ko‘rgazmasi #Qatar muxbir: Murodjon Axatov https://t.me/zamon_lavhalar
Hashtags
@IHMA_matbuotkotibi · Post #671 · 07.11.2025 г., 09:38
Dohada O'zbekiston pavilyoni⚡️ “O’zbekiston” telekanali “Jarayon” 18:00 06.11.2025 #QATAR Rasmiy sahifalarimiz🌐 Telegram | Instagram | O'zTV1 Insta |O'zTV1 TG | UTube | O'zTV1FB | UzRadio103.1
Hashtags
@Whitehousewatch · Post #17042 · 14.01.2026 г., 15:30
#Qatar, #Iran: Il Dipartimento della Guerra ha cominciato a ritirare alcune truppe e alcuni asset dalla base al-Udeid in Qatar come precauzione in vista di una decisione di Donald Trump di colpire o meno l'Iran. La base in questione viene utilizzata per ospitare bombardieri, aerei di rifornimento, jet da combattimento, aerei per la sorveglianza e droni. Lo stesso era stato fatto a giugno pirma che gli Stati Uniti colpissero l'Iran.
@iswnews_en · Post #18548 · 11.04.2026 г., 12:02
🇮🇷/🇺🇸Based on unofficial news from Islamabad, Iran's red lines in negotiations with the US include the following: 1- The Strait of Hormuz must be under Iran's control. 2- Payment of compensation for war damages. 3- Release of Iran's frozen assets. 4- Any ceasefire must be implemented sustainably and genuinely on all relevant fronts. ‼️ Additionally, negotiations will begin after Iranian officials meet with Pakistani Prime Minister Shehbaz Sharif to discuss US violations of the ceasefire terms, at the forefront of which are the release of Iran's frozen funds in Qatar and a ceasefire in Lebanon. These two issues have been set as preconditions for the start of the talks. #Iran#Qatar
@iswnews_en · Post #16951 · 05.03.2026 г., 00:24
🇮🇷/🇺🇸🇶🇦💥💥 Explosions at US bases in Doha. #Iran#USA#Qatar
@Marwa_OsmanLB · Post #3057 · 16.08.2024 г., 14:40
Do not believe a single word that comes out of the meeting of the genocide enablers in #Qatar Only believe what comes out of the mouth of the resistance in #Gaza That is the only side I trust...and that side is not even present in Qatar.
@iswnews_en · Post #18016 · 01.04.2026 г., 01:19
🇮🇷/🇺🇸🇶🇦🚢💥The United Kingdom Maritime Trade Operations (UKMTO) has reported an incident 17 nautical miles north of Doha. The security officer reported that a tanker was struck by an unknown projectile, causing damage to the hull above the waterline. The crew is reported safe. 📊 Since the start of the war, Iranian armed forces have struck at least 24 violating vessels in the waters of the Persian Gulf, the Strait of Hormuz, and the Gulf of Oman. These attacks have been carried out using suicide naval drones, suicide drones, cruise missiles, anti‑ship ballistic missiles, armed speedboat assaults, and other means. #Iran#US#Qatar
@iswnews_en · Post #17450 · 20.03.2026 г., 00:58
🇮🇷/🇺🇸🇶🇦‼️Repairing the damage to the Ras Laffan gas complex will take 5 years! 🔹State-owned QatarEnergy, which operates the Ras Laffan gas complex, told Reuters that the damage inflicted on "two units" of the LNG facility, developed through a joint investment with the American company ExxonMobil, will require three to five years to repair. ➡️ The company added that this incident will reduce its annual revenue by $20 billion and force it to cancel long-term contracts with Italy, Belgium, Korea, and China. ✍️ As the Qataris themselves have acknowledged, Iran's "limited strike" on a "small section" of the Ras Laffan facilities has been this damaging. This reality once again emphasizes that any extensive Iranian attack on these facilities and other similar oil and gas installations in the region could lead to a huge and irreparable catastrophe in the history of human energy! Therefore, the U.S., Europe, and the Persian Gulf states have clearly received Iran's powerful and unequivocal message, and it is unlikely they will make any further mistakes from now on. Of course, the malice of the Zionist regime remains ever-present, but if this mistake is repeated, there will be no way back left for anyone! #Iran#US#Qatar
@iswnews_en · Post #17205 · 09.03.2026 г., 00:41
🇮🇷/🇺🇸🚨 Missile attack on Al Udeid base in Qatar. #Iran#US#Qatar