This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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!!!! | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |