@mideastpress · Post #42038 · 08.04.2026 г., 18:20
🇮🇶 The Secretary-General of the Islamic Resistance in #Iraq - Al-Nujaba Movement announces that they are not part of the agreement and that military operations will be resumed.
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
Пребарај: #iraq
@mideastpress · Post #42038 · 08.04.2026 г., 18:20
🇮🇶 The Secretary-General of the Islamic Resistance in #Iraq - Al-Nujaba Movement announces that they are not part of the agreement and that military operations will be resumed.
Hashtags
@WhiteHouseWatch · Post #17832 · 01.03.2026 г., 21:49
#Iraq: Alcuni manifestanti stanno cercando di fare irruzione nell'ambasciata statunitense in Bagdad. Le squadre di sicurezza stanno sparando contro i manifestanti.
Hashtags
@fight4f · Post #8845 · 22.10.2024 г., 15:36
Photos sent by friends in Iraq (Shia counter-terrorism forces) hunting Wahhabis (remnants of the Islamic State) in Iraq . #Iraq
Hashtags
@fight4f · Post #8743 · 20.09.2024 г., 08:04
消息:伊拉克伊斯蘭抵抗運動的支派 Kata'eb Sayyed al-Shuhada 承諾支持黎巴嫩的真主黨,他們已準備好動員數千名戰士援助黎巴嫩。 #Iraq https://t.me/Middle_East_Spectator
Hashtags
@fight4f · Post #8672 · 26.08.2024 г., 07:22
伊拉克的藥材鋪 (地點: Karbala) Karbala 是巴格達以南一百公里的一個什葉派聖城。 基本上,全世界有草本植物的地方,也有自己一套的經驗醫學和本草綱目。伊拉克的「米索不達美亞」是暫時考古之中, 承認的最早出現系統及文字的人類文明, 那時他們已經懂得「做手術」。 #Iraq
Hashtags
@popularxfront · Post #6196 · 08.05.2026 г., 16:27
🇮🇶#Iraq: Hajaj Ahmed Hardan al-Tikriti, widely known among survivors as "Saddam Hussein’s personal butcher" was brought before the Rusafa Criminal Court in Baghdad over crimes linked to the Anfal genocide against the Kurds. A former warden at the notorious Nugra Salman prison in Iraq’s southern Muthanna province, he is accused of overseeing torture and carrying out executions, forced disappearances, starvation, and the abuse of thousands of Kurdish detainees during the late 1980s. Since his arrest on July of last year, after decades in hiding, al-Tikriti has appeared multiple times before the Rusafa Court in connection with atrocities committed at Nugra Salman prison. Around 221 relatives of Anfal victims from several Kurdish regions attended the court session wearing traditional Kurdish clothing, demanding justice for the massacres and crimes committed against the Kurdish population. Attached footage shows Hajaj in handcuffs next to the Nugra Salman Prison. (via Rudaw & @kurdishactivism_ on IG)
Hashtags
@popularxfront · Post #6080 · 29.04.2026 г., 06:56
🇮🇶#Iraq: The “Guardians of Blood Brigades” have struck a communication tower at the US Victoria Base in Baghdad using a fiber-optic drone armed with an RPG warhead. (via @war_noir)
Hashtags
@popularxfront · Post #6002 · 24.04.2026 г., 01:17
🇮🇶#Iraq: The Kurdistan National Army headquarters in Chamshari was struck by a drone last night. So far, no information has been released regarding who launched the attack. (via @KurdishFrontNews)
Hashtags
@popularxfront · Post #5989 · 22.04.2026 г., 21:10
🇮🇶#Iraq: Footage showing drone interceptions over Erbil in Iraqi Kurdistan after an alleged massive drone attack.
Hashtags
@popularxfront · Post #5850 · 10.04.2026 г., 09:18
🇮🇶#Iraq: Footage shows US forces attempting to shoot down drones over Erbil Governorate in Iraq's Kurdistan overnight. Several reports state that the drones belong to Iran-backed militias, with one of the most active groups in Iraq lately being the Guardians of Blood Brigades. (via Archer83Able on X)
Hashtags
@popularxfront · Post #5817 · 08.04.2026 г., 07:59
🇮🇶#Iraq: The "Islamic Resistance in Iraq" has carried out several attacks against US bases in Iraq, as well as in the Kurdistan Region, overnight. The militants used cruise missiles and kamikaze drones in the attacks. (via @war_noir)
Hashtags
@popularxfront · Post #5728 · 02.04.2026 г., 23:30
🇮🇶#Iraq: Footage released by the Islamic Resistance in Iraq (IRI) shows a drone strike targeting a fuel tank at the US Victory Camp base near Baghdad Airport. (via @conflictarchive)
Hashtags