This file contains hidden or 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
| # -*-coding:utf-8-*- | |
| from importlib.abc import SourceLoader, MetaPathFinder | |
| from importlib.machinery import ModuleSpec | |
| import sqlite3 | |
| import os | |
| import sys | |
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| CODE_DB = os.path.join(BASE_DIR, 'source.db') |
This file contains hidden or 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 contextlib | |
| import os | |
| import random | |
| import signal | |
| import time | |
| from concurrent.futures import ProcessPoolExecutor, as_completed, process | |
| from multiprocessing import Pool, Process, Queue | |
| from multiprocessing.context import TimeoutError | |
| PIPES_DATA = { |
This file contains hidden or 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 time | |
| import contextlib | |
| from selenium import webdriver | |
| with contextlib.closing(webdriver.PhantomJS()) as d: | |
| d.implicitly_wait(10) | |
| d.get("http://www.finanse.mf.gov.pl/web/wp/pp/sprawdzanie-statusu-podmiotu-w-vat") | |
| input = d.find_element_by_id('b-7') | |
| input.send_keys('6652451039') | |
| d.find_element_by_id('b-8').click() | |
| time.sleep(4) |
This file contains hidden or 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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>The HTML5 Herald</title> | |
| <meta name="description" content="The HTML5 Herald"> | |
| <meta name="author" content="SitePoint"> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| def stars(text, _map): | |
| asterix_list = [] | |
| for character, asterix in zip(text, _map): | |
| if asterix: | |
| asterix_list.append('*') | |
| else: | |
| asterix_list.append(character) |
This file contains hidden or 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
| class ListItem: | |
| def __init__(self, tag=None, htmlclass=None): #Uwaga, funkcja nie jest przekazywana do konstruktora ! | |
| self.tag = tag or 'li' | |
| self.htmlclass = htmlclass or 'menuitem' | |
| def __call__(self, func): #Uwaga, funkcja jest teraz przekazywana w metodzie __call__ ! | |
| @wraps(func) | |
| def wrapper(text_line): | |
| result = "<{0} class='{1}'>{2}</{0}>".format(self.tag, self.htmlclass, func(text_line)) |
This file contains hidden or 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 functools import wraps | |
| class PrinterWrapped2: | |
| def __init__(self, func): | |
| wraps(func)(self) | |
| def __call__(self, *args, **kwargs): | |
| print("Printing..") | |
| f = self.__wrapped__(*args, **kwargs) | |
| print("Document printed..") |
This file contains hidden or 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 functools | |
| class PrinterWrapped: | |
| def __init__(self, func): | |
| self.func = func | |
| functools.update_wrapper(self, func) | |
| def __call__(self, *args, **kwargs): | |
| print("Printing..") |
This file contains hidden or 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
| class Printer: | |
| def __init__(self, func): | |
| self.func = func | |
| def __call__(self, *args, **kwargs): | |
| print("Printing..") | |
| f = self.func(*args, **kwargs) | |
| print("Document printed..") | |
| return f |
This file contains hidden or 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 functools import wraps, partial | |
| #Dekorator służący do dodawania funkcji jako atrybut obiektu | |
| def attach_wrapper(obj, func=None): | |
| if func is None: | |
| return partial(attach_wrapper, obj) | |
| setattr(obj, func.__name__, func) | |
| return func | |
| def list_item(tag=None, htmlclass=None): |
NewerOlder