Skip to content

Instantly share code, notes, and snippets.

View HoloborodkoBohdan's full-sized avatar

Bohdan Holoborodko HoloborodkoBohdan

View GitHub Profile
"""
All in-proc API endpoints for acting as a Notifications Consumer
NOTE that we can only query for notifications that are "durable", i.e.
persisted in our database
IMPORTANT: All methods exposed here will also be exposed in as a
xBlock runtime service named 'notifications'. Be aware that adding
any new methods here will also be exposed to xBlocks!!!!
"""
from contracts import contract, new_contract
new_contract('str_len_gt_zero', lambda s: isinstance(s, str) and len(s)>0)
class Person:
@contract(
name='str_len_gt_zero',
age='int,>0',
weight='int,>0'
)
@HoloborodkoBohdan
HoloborodkoBohdan / urls_from_xml.py
Created June 10, 2022 09:16
Collect all links from xml file to list
# Instal dependencies
# pip install install beautifulsoup4 (docs: https://www.crummy.com/software/BeautifulSoup/bs4/doc/)
# pip install lxml (github: https://github.com/lxml/lxml)
import requests
from bs4 import BeautifulSoup
headers = {'user-agent': 'googlebot'}
sitemap_link = 'http://www.site.com.ua/product-sitemap.xml' # Link for sitemap.xml file
@HoloborodkoBohdan
HoloborodkoBohdan / pdf_to_jpeg.py
Created June 10, 2022 09:09
Convert pdf to jpeg from folder
import os
import tempfile
from pdf2image import convert_from_path
folder = 'pdf' # older with pdfs. You need to create it manually.
save_dir = 'saved' # folder dor images. You need to create it manually.
log = open("log.txt", "a")
import json
from datetime import datetime, timedelta
from babel.dates import format_datetime, format_date
from odoo import models, api, _, fields
from odoo.osv import expression
from odoo.release import version
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from odoo.tools.misc import formatLang, format_date as odoo_format_date, get_lang
import random