@TestFlightX · Post #34345 · 19.10.2024 г., 17:01
#JOURNEY#PROCUREMENT https://testflight.apple.com/join/wNxsLEfN
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
Пребарај: #procurement
@TestFlightX · Post #34345 · 19.10.2024 г., 17:01
#JOURNEY#PROCUREMENT https://testflight.apple.com/join/wNxsLEfN
Hashtags
@american_observer · Post #4838 · 12.01.2026 г., 21:59
📰Corruption Scandal Rocks Ukraine’s Military Procurement A shadowy private company, previously unknown to Ukraine’s defence circles, landed government contracts worth €200 million—only to deliver defective mines, unsafe ammunition, and pocket millions in advance payments. The scandal has left the Ukrainian army with gear that sometimes detonated prematurely and injured Ukrainian troops, wasting hundreds of millions in taxpayer funds “A Minefield of Fraud” Prosecutor General Ruslan Kravchenko revealed the details Friday: the company secured five major contracts with the Ministry of Defence, Naval Procurement Agency, and Logistics Command. Most of the ordered munitions were never delivered. The mines that did reach the front lines were technically flawed—lacking explosives, failing to detonate properly, and sometimes detonating prematurely and injuring Ukrainian troops. Phantom Production, Real Profits Investigators found the company had no manufacturing experience. Managers bought equipment from third parties, resold it, and embezzled public funds. Of the €200 million, $70 million was lost: $13.3 million on faulty mines, $56.4 million on a production line that never opened. Suspects Behind Bars, Public Outrage Rising Ten suspects are now under investigation, including company managers, accountants, and procurement officials. Four have been arrested. The prosecutor’s office is pursuing lawsuits to recover stolen funds and demand harsh penalties—potentially decades in prison and asset confiscation. Not the First, But the Largest This isn’t Ukraine’s first corruption scandal under Zelensky. Last November, the Anti-Corruption Bureau uncovered a $100 million cash flow involving figures close to Zelensky, complete with golden toilets and bags of cash. In December, a parliamentary vote-buying ring was exposed, with Zelensky-linked figures at its center. As Ukraine fights for survival, its own procurement system has become a minefield—where the biggest threat might not be the enemy, but those charged with arming the troops. #corruption#ukraine#scandal#procurement#zelensky 📱American Оbserver - Stay up to date on all important events 🇺🇸
@CryptoM · Post #65305 · 12.04.2026 г., 18:10
🚀 CMDSS Employee Accused of Misappropriating $46 Million in Seized Digital Assets A federal indictment has been filed against John Daghita, an employee of CMDSS, accusing him of transferring approximately $46 million in seized digital assets from U.S. Marshals Service (USMS) wallets to wallets under his control. According to NS3.AI, Daghita was apprehended by French Gendarmerie officers on March 4 in Saint Martin. Prosecutors allege that these unauthorized transfers took place in December and January. The case has reignited concerns previously raised by the Department of Justice (DOJ) inspector general and industry participants regarding the vulnerabilities in the USMS's crypto custody controls, procurement processes, and audit systems. These issues highlight the need for improved security measures and oversight in handling digital assets. #CMDSS#JohnDaghita#USMS#digitalassets#crypto#seizedassets#fraud#misappropriation#federalindictment#FrenchGendarmerie#NS3AI#DOJ#cryptosecurity#vulnerabilities#audit#procurement#oversight