def get_pages(self): pages = [] if self.config.manual_duplex: front_pages = sorted(file.name for file in Path('scans').glob( f'{self.config.name}_*_front.{self.config.scan_format}')) back_pages = sorted((file.name for file in Path('scans').glob( f'{self.config.name}_*_back.{self.config.scan_format}')), reverse=True) if len(front_pages) != len(back_pages): raise AssertionError( 'Same number of front and back pages needed!') for i in range(len(front_pages)): pages.append(Page(front_pages[i], is_backside=False)) pages.append(Page(back_pages[i], is_backside=True)) else: for file in sorted( Path('scans').glob( f'{self.config.name}_*.{self.config.scan_format}')): is_backside = bool( re.match(rf'.*_\d{{3}}[02468].{self.config.scan_format}', file.name)) pages.append(Page(file.name, is_backside=is_backside)) if not pages: raise FileNotFoundError( 'no scans found! Seems like scanimage produced no output? Check your setup / scanner.' ) return pages
def get_page(self, url): chrome = PyChromeDevTools.ChromeInterface(host="localhost", port=9222) chrome.Page.enable() chrome.Page.navigate(url=url) chrome.wait_event("Page.loadEventFired", timeout=60) id = chrome.DOM.getDocument()['result']['root']['nodeId'] return Page( url=url, html=chrome.DOM.getOuterHTML(nodeId=id)['result']['outerHTML'])
def __init__(self, no_of_pages): self.buffer_pool = [] self.disk_manager = DiskManager(64) for i in range(no_of_pages): self.buffer_pool[i] = Page(i, 64) # Setting default page size to 64 self.replacer = LRUReplacer(self) self.page_map = {} self.no_of_pages = no_of_pages
import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk from src.page import Page from transliterator.gui.controller import on_start_clicked as on_transliterate_clicked from lexical_analyzer.gui.controller import on_start_clicked as on_lex_analyzer_clicked from syntax_analyzer.gui.controller import on_start_clicked as on_syn_analyzer_clicked settings = Gtk.Settings.get_default() settings.set_property("gtk-theme-name", "Raleigh") # settings.set_property("gtk-application-prefer-dark-theme", True) # if you want use dark theme, set second arg to True window = Gtk.Window(title='Теория формальных граматик и автоматов', resizable=False) window.connect('delete-event', Gtk.main_quit) notebook = Gtk.Notebook() notebook.append_page(Page(on_transliterate_clicked), Gtk.Label("Транслитератор")) notebook.append_page(Page(on_lex_analyzer_clicked), Gtk.Label("Лехический анализатор")) notebook.append_page(Page(on_syn_analyzer_clicked), Gtk.Label("Синтаксический анализатор")) window.add(notebook) window.show_all() Gtk.main()
def __set_page_title(self): self.title = requests.get(self.base_url, auth=self.auth).json()['title'] self.page = Page(title=self.title) return self
from src.page import Page page = Page('sample.png', 250) page.analyze_notes() page.analyze_sharp_flat_natural() page.draw_sharp_flat_natural() page.draw_notes() page.save('hhh.png')
def get_page(self, url): html = requests.get(url).content return Page(url=url, html=html)
from src.page import Page import src.cms as cms #editable contentfiles to cms cms.editable = {"Name of content": "body.txt"} cms.enable() #clear page folder befor rerender mypage = Page( opt={ 'url': '/asd', "template": "document.html", "contentFiles": { "body": 'body.txt' }, "cssList": ['myStyle.css', 'myStyle2.css'], "jsList": ['first.js', 'second.js'] })
from src.page import Page p = Page() print(p.has_capacity()) p.write(255) p.write(1024) p.write(1023) print(p.read(0)) print(p.read(1)) print(p.read(2))
from src.page import Page from pdf2image import convert_from_path import os import tempfile import img2pdf filename = 'target.pdf' images = convert_from_path('./' + filename, dpi=500) for i in range(0, len(images)): print('Start working on page ' + str(i + 1)) images[i].save('./output/' + str(i) + '.jpg', 'JPEG') page = Page('./output/' + str(i) + '.jpg', 350) # page.analyze_notes() # page.analyze_sharp_flat_natural() page.draw_page() page.draw_lines() page.draw_bars() # page.draw_sharp_flat_natural() # page.draw_notes() page.save('./output/' + str(i) + '.jpg') output = open("./output/output.pdf", "wb") page_names = [] for filename in os.listdir('./output'): if filename.endswith(".jpg"): page_names.append('./output/' + filename)