Ejemplo n.º 1
0
def prepare_training_data():
    pages = []

    with open('music_urls_2.csv', 'r', encoding='utf-8') as f:
        reader = csv.reader(f)
        for row in reader:
            if row[3] == '3':
                page = Page(row[0], 0)
            elif row[2] == '2':
                page = Page(row[0], 1)
            elif row[1] == '1':
                page = Page(row[0], 2)
            else:
                raise ValueError('Invalid row - {}'.format(str(row)))

            body = download.get_with_cache(page.url)

            if len(body) > 0:
                soup = BeautifulSoup(body, 'html.parser')
                page.title = str(soup.title.string)
                headers = soup.find_all('h1')
                if len(headers) > 0:
                    page.h1 = str(headers[0].text)
                pages.append(page)

    shuffle(pages)

    test_size = int(TEST_SIZE * len(pages))
    for p in pages[-test_size:]:
        p.purpose = 'test'

    return pages
Ejemplo n.º 2
0
Archivo: main.py Proyecto: emosa/DP
 def get(self):
     page = Page()   # Creates an instance of the imported class page
     page.title = "Title"
     page.css = "css/styles.css"
     page.body = "Miss piggy"
     page.update()
     self.response.write(page.whole_page)
Ejemplo n.º 3
0
def test_case_1(browser):

    page = Page(browser)

    # Navigate to the URL https://www.sogeti.com/
    page.load()

    # Hover over Services Link
    page.hover('//*[@id="header"]/div[1]/nav/ul/li[3]/div')

    #  and then Click Automation link.
    page.click('//*[@id="header"]/div[1]/div[5]/ul/li[7]/a')

    # Verify that Automation Screen is displayed
    assert 'Automation' in page.title()

    # and “Automation” text is visible in Page
    assert 'Automation' in page.get_attribute_of_element(
        '//*[@id="primary_content"]/div/div[2]/div/h1/span', 'textContent')

    # Hover again over Services Link
    page.hover('//*[@id="header"]/div[1]/nav/ul/li[3]/div')

    # Verify that the Services and Automation are selected
    assert 'selected' in page.get_attribute_of_element(
        '//*[@id="header"]/div[1]/div[5]/ul/li[7]', 'class')
Ejemplo n.º 4
0
def main():

	first = Page(1)
	
	first.title = "The first Page"
	first.add_content("Welcome to the first page. Here is a bunch of content")
	
	print first.get_page_number()
	print first.get_content()

	SomeClassName.my_static_function("Test")
Ejemplo n.º 5
0
Archivo: index.py Proyecto: crst/pgui
def Login(params=None, title=None):
    """
    Renders the login page.

    There is no separate login for the application, this is passed to
    the database!
    """
    p = Page()
    p.content('<!DOCTYPE html>')
    with p.html():
        with p.head():
            with p.title():
                p.content('pgui - Login')
            with p.link({'href': 'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/login.css', 'rel': 'stylesheet'}): pass

        with p.body():

            with p.div({'class': 'container'}):
                with p.form({'method': 'POST', 'class': 'login'}):
                    with p.h2({'class': 'login-header'}):
                        p.content('Connect to a postgres database server')

                    with p.label({'for': 'name', 'class': 'sr-only'}):
                        p.content('User name')
                    with p.input({'type': 'input', 'id': 'name', 'name': 'name', 'class': 'form-control', 'placeholder': 'User name'}): pass

                    with p.label({'for': 'password', 'class': 'sr-only'}):
                        p.content('Password')
                    with p.input({'type': 'password', 'id': 'password', 'name': 'password', 'class': 'form-control', 'placeholder': 'Password'}): pass

                    with p.label({'for': 'host', 'class': 'sr-only'}):
                        p.control('Host')
                    with p.input({'type': 'input', 'id': 'host', 'name': 'host', 'class': 'form-control', 'value': 'localhost'}): pass

                    with p.label({'for': 'port', 'class': 'sr-only'}):
                        p.content('Port')
                    with p.input({'type': 'input', 'id': 'port', 'name': 'port', 'class': 'form-control', 'value': '5432'}): pass

                    with p.button({'class': 'btn btn-lg btn-success btn-block', 'type': 'submit'}, args=['autofocus']):
                        p.content('Connect')


                with p.div({'class': 'login'}):
                    if 'err' in params and params['err']:
                        for err in params['err']:
                            with p.code():
                                p.content(err)

    return p
Ejemplo n.º 6
0
Archivo: shared.py Proyecto: crst/pgui
def Header(params=None, title=None, css=None, js=None):
    p = Page()

    p.content('<!DOCTYPE html>')
    with p.html(close=False):
        with p.head():
            with p.title():
                p.content('pgui - %s/%s' % (cu.database, title))

            with p.meta({'charset': 'utf-8'}): pass
            with p.script({'src': 'static/lib/jquery/jquery-2.1.3.js'}): pass
            with p.script({'src': 'static/pgui.js'}): pass
            with p.link({'href': 'static/pgui.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/codemirror/codemirror-5.1/lib/codemirror.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/codemirror/codemirror-5.1/theme/neo.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.css', 'rel': 'stylesheet'}): pass
            if css:
                for c in css:
                    with p.link({'href': c, 'rel': 'stylesheet'}): pass
            with p.script({'src': 'static/lib/bootstrap/bootstrap-3.3.4-dist/js/bootstrap.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/lib/codemirror.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/emacs.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/vim.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/sublime.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/mode/sql/sql.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.js'}): pass
            if js:
                for j in js:
                    with p.script({'src': j}): pass

        with p.body(close=False):
            config = 'PGUI.user = "******"; PGUI.db = "%s"; PGUI.host = "%s";' % (cu.name, cu.database, cu.host)
            with p.script():
                p.content(config)

    return p
Ejemplo n.º 7
0
        self.content = content

pages=[]
bus01 = BusPage("801","57596","Gower Street / UCH","N")
bus02 = BusPage("802","50975","Euston Square Station","P")
bus03 = BusPage("803","51664","Euston Station","H")
bus04 = BusPage("804","75100","Euston Station","AZ")
bus05 = BusPage("805","73933","Euston Station","C")
bus06 = BusPage("806","53602","Euston Bus Station","AP")
bus07 = BusPage("807","56230",Foreground.GREEN+"Euston Station"+Foreground.DEFAULT,"D")
bus08 = BusPage("808","47118","Euston Bus Station","G")
bus09 = BusPage("809","58234","Euston Station","E")
bus10 = BusPage("810","51581","Upper Woburn Place / Euston Road","L")
bus11 = BusPage("811","72926","Upper Woburn Place","M")
bus12 = BusPage("812","72238","Jubilee Road","PD")
bus13 = BusPage("813","58812","Jubilee Road","J")
bus14 = BusPage("814","55027","Wembley Park Station","O")
bus15 = BusPage("815","59287",Foreground.GREEN+"Euston Square Station"+Foreground.DEFAULT,"Q")

tv_page = Page("800")
tv_page.content = colour_print(printer.text_to_ascii("Buses Index"))+"\n"
tv_page.title = "Buses Index"
i=0
for page in pages:
    tv_page.content+=tv_page.colours.Foreground.RED+page[0]+tv_page.colours.Foreground.DEFAULT+" "+page[1]
    if i==1:
        tv_page.content += "\n"
    else:
        tv_page.content += " "*(38-len(page[0]+page[1]))
    i = 1-i
Ejemplo n.º 8
0
import os
from page import Page
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "I'm a Teapot"
sub_page.in_index=False
sub_page.content = colour_print(printer.text_to_ascii("418", padding={"left": 30}))
sub_page.content += "\n\n"
sub_page.content = """
                                     ,o.
                                    c.o8o
                                   (CoC8@)
     /).                            CcC@8
     V@@8.                        ..o@8@o..                ,.oooo.
      `@88`.              ,cc@8@88C'cc:cc`C88@88o.    ,ooc***"'.:*Oo.
       `OCCo8          .OCc**@@8@88@CoCoC@88@8@@**'oCOOoo::.....oo:.o.
        8Cooc8       .oocococccc**8@8CcC8@8**OCOO8O88@88ooC@88@@@@8c:o
         8c:c:8.   .'cocc:c:c:::::c:c:ccocooCoCCOCOO8O888o88'    8*cc8
         `8:.:.8@@8@8occcc:c:::::::c:ccccooooCCOCOO8O88@@@8      8o o8
          8.. ..@8OC8@c:c::.:.....:.::c:ccocooCoCCOO8O88@8@.    ,C:.C;
          `8.:..@coCC@cc::.:.. . ..:.::ccocooCoCCOO8O88@8@@8   ;C:.o;
           *c.o88OC8@8c::.:..     ..:.::ccccooCoCCOOOO88@8@@ ,8C:o8'
            `*@8@@8@'occ::.:.. . ..:.::ccocooCoCCOO8O88@8@@@*8OC8C'
               `88;cocc:c::.:.....:.::c:ccocooCoCCOO8O88@8@@OCC8@'
                 8oooocccc:c:::::::c:ccccooooCCOCOO8O88@@@@@88@'
                 `Coococc:c:c:::::c:c:ccocooCoCCOCOO8O88@@@C@'
                  `8oCoocococccccccococooCoCCOCOO8O88@8@@@*'
                    'CcoocococococococooooCoCCOCOO8O88@@8
Ejemplo n.º 9
0
import os
from page import Page
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "Resource Limit"
sub_page.in_index=False
sub_page.content = colour_print(printer.text_to_ascii("508", padding={"left": 30}))
sub_page.content += "\n\n"
sub_page.content += colour_print(printer.text_to_ascii("Resource Limit Is Reached"))
Ejemplo n.º 10
0
Archivo: shared.py Proyecto: crst/pgui
def Header(params=None, title=None, css=None, js=None):
    p = Page()

    p.content('<!DOCTYPE html>')
    with p.html(close=False):
        with p.head():
            with p.title():
                p.content('pgui - %s/%s' % (cu.database, title))

            with p.meta({'charset': 'utf-8'}):
                pass
            with p.script({'src': 'static/lib/jquery/jquery-2.1.3.js'}):
                pass
            with p.script({'src': 'static/pgui.js'}):
                pass
            with p.link({'href': 'static/pgui.css', 'rel': 'stylesheet'}):
                pass
            with p.link({
                    'href':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({
                    'href':
                    'static/lib/codemirror/codemirror-5.1/lib/codemirror.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({
                    'href':
                    'static/lib/codemirror/codemirror-5.1/theme/neo.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({
                    'href':
                    'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.css',
                    'rel': 'stylesheet'
            }):
                pass
            if css:
                for c in css:
                    with p.link({'href': c, 'rel': 'stylesheet'}):
                        pass
            with p.script({
                    'src':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/js/bootstrap.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/lib/codemirror.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/keymap/emacs.js'
            }):
                pass
            with p.script(
                {'src': 'static/lib/codemirror/codemirror-5.1/keymap/vim.js'}):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/keymap/sublime.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/mode/sql/sql.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.js'
            }):
                pass
            if js:
                for j in js:
                    with p.script({'src': j}):
                        pass

        with p.body(close=False):
            config = 'PGUI.user = "******"; PGUI.db = "%s"; PGUI.host = "%s";' % (
                cu.name, cu.database, cu.host)
            with p.script():
                p.content(config)

    return p
Ejemplo n.º 11
0
import os
from page import Page
from random import choice
import colours
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "Annawards"
sub_page.index_num = "456-457"
content = colour_print(
    printer.text_to_ascii("Annawards", padding={"left": 6}))

awards = [
          ["Boo Cow Annawards",{"Pietro Servini":1,"Stephen Muirhead":1,"Belgin Seymenoglu":2}],
            # Tea Wrecks was formerly known as Tea Breaker
          ["Tea Wrecks Annawards",{"Anna Lambert":1,"Rafael Prieto Curiel":1,"Belgin Seymenoglu":1}],
          ["Towel Flood Annawards",{"Jigsaw":1,"Belgin Seymenoglu":2}],
          ["Worst Sorting Hat",{"Anna Lambert":20}],
          ["Boo Key",{"Anna Lambert":1,"Sam Brown":1,"Rafael Prieto Curiel":1,"Mart Wright":1}],
          ["Stolen Pen",{"Anna Lambert":1}]
         ]
pages = ["457","457","458","458","458","458"]

content += "\nWho has the most Annawards?\n\n"

for i,award in enumerate(awards):
    content += "\n"+sub_page.colours.Foreground.GREEN+award[0]+sub_page.colours.Foreground.DEFAULT+" (see page "+pages[i]+")\n"
    max_ = 0
    max_p = None
Ejemplo n.º 12
0
import os
import screen
from page import Page
from random import choice

def colour_me(text):
    output = ""
    for i in text:
        output += choice(test_page.colours.Foreground.non_boring) + i
    output += test_page.colours.Foreground.DEFAULT
    return output

page_number = os.path.splitext(os.path.basename(__file__))[0]
test_page = Page(page_number)
test_page.title = "Test Page"
test_page.is_enabled = False

test_page.content = ""

test_page.content += "\n" + colour_me("TEST PAGE") + "\n"

# 000000011111111112222222222333333333344444444445555555555666666666677777777778
# 345678901234567890123456789012345678901234567890123456789012345678901234567890
#"          DEFAULT BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"
#"BOLD      "
#"FAINT     "
#"STANDOUT  "
#"BLINK     "
#"UNDERLINE "
#"STRIKE    "
test_page.content += "\n" + colour_me("FOREGROUNDS & STYLES") + "\n"
Ejemplo n.º 13
0
import os
from page import Page
import colours
from printer import instance as printer

r1 = Page("581")
r1.title = "Bad Tempered Cake"
r1.in_index = False
r1.content = (colours.colour_print(
    printer.text_to_ascii("bad tempered cake"),
    colours.Background.RED,
    colours.Foreground.BLUE) +
"""
1/2 lb    Rich tea and/or digestive biscuits
    4 oz    Margarine
    1 dsp   Sugar
    3 dsp   Cocoa
    3 dsp   Drinking chocolate
1 1/2 tbsp  Golden syrup
    2 oz    Sultanas
    2 bars  Milk chocolate

1. Break the biscuits.
2. Melt the margarine, sugar, cocoa, drinking chocolate and syrup over a medium
   heat.
3. Mix with biscuits and sultanas and press down in baking tray.
4. Cover with melted milk chocolate.
5. Leave in the fridge to set""")

r2 = Page("582")
r2.title = "Huda Friendship Cake"
Ejemplo n.º 14
0
train16 = TrainPage("866","Ffairfach","FFA")
train17 = TrainPage("867","London Victoria","VIC")
train18 = TrainPage("868","London Waterloo","WAT")
train19 = TrainPage("869","London Waterloo East","WAE")
train20 = TrainPage("870","Banbury","BAN")
train21 = TrainPage("871","Reading","RDG")
train22 = TrainPage("872","Oxford","OXF")
train23 = TrainPage("873","Stratford-upon-Avon","SAV")
train24 = TrainPage("874","B'ham New Street","BHM")
train25 = TrainPage("875","B'ham Moor Street","BMO")
train26 = TrainPage("876","B'ham Snow Hill","BSW")
train27 = TrainPage("877","Wembley Stadium","WCX")
train28 = TrainPage("878","Kilmarnock","KMK")
train29 = TrainPage("879","Moreton-in-Marsh","MIM")
train30 = TrainPage("880","Ealing Broadway","EAL")
train31 = TrainPage("881","Farringdon","ZFD")
train32 = TrainPage("882","East Croydon","ECR")
train32 = TrainPage("883","St Pancras to East Croydon","STP",to=["Three Bridges","Brighton"])

tv_page = Page("850")
tv_page.content = colour_print(printer.text_to_ascii("Trains Index"))+"\n"
tv_page.title = "Trains Index"
i=0
for page in pages:
    tv_page.content+=tv_page.colours.Foreground.RED+page[0]+tv_page.colours.Foreground.DEFAULT+" "+page[1]
    if i==1:
        tv_page.content += "\n"
    else:
        tv_page.content += " "*(38-len(page[0]+page[1]))
    i = 1-i
Ejemplo n.º 15
0
import os
from page import Page
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "Subtitles"
sub_page.content = colour_print(
    printer.text_to_ascii("subtitles", padding={"left": 6}))
Ejemplo n.º 16
0
Archivo: index.py Proyecto: crst/pgui
def Login(params=None, title=None):
    """
    Renders the login page.

    There is no separate login for the application, this is passed to
    the database!
    """
    p = Page()
    p.content('<!DOCTYPE html>')
    with p.html():
        with p.head():
            with p.title():
                p.content('pgui - Login')
            with p.link({
                    'href':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({'href': 'static/login.css', 'rel': 'stylesheet'}):
                pass

        with p.body():

            with p.div({'class': 'container'}):
                with p.form({'method': 'POST', 'class': 'login'}):
                    with p.h2({'class': 'login-header'}):
                        p.content('Connect to a postgres database server')

                    with p.label({'for': 'name', 'class': 'sr-only'}):
                        p.content('User name')
                    with p.input({
                            'type': 'input',
                            'id': 'name',
                            'name': 'name',
                            'class': 'form-control',
                            'placeholder': 'User name'
                    }):
                        pass

                    with p.label({'for': 'password', 'class': 'sr-only'}):
                        p.content('Password')
                    with p.input({
                            'type': 'password',
                            'id': 'password',
                            'name': 'password',
                            'class': 'form-control',
                            'placeholder': 'Password'
                    }):
                        pass

                    with p.label({'for': 'host', 'class': 'sr-only'}):
                        p.control('Host')
                    with p.input({
                            'type': 'input',
                            'id': 'host',
                            'name': 'host',
                            'class': 'form-control',
                            'value': 'localhost'
                    }):
                        pass

                    with p.label({'for': 'port', 'class': 'sr-only'}):
                        p.content('Port')
                    with p.input({
                            'type': 'input',
                            'id': 'port',
                            'name': 'port',
                            'class': 'form-control',
                            'value': '5432'
                    }):
                        pass

                    with p.button(
                        {
                            'class': 'btn btn-lg btn-success btn-block',
                            'type': 'submit'
                        },
                            args=['autofocus']):
                        p.content('Connect')

                with p.div({'class': 'login'}):
                    if 'err' in params and params['err']:
                        for err in params['err']:
                            with p.code():
                                p.content(err)

    return p
Ejemplo n.º 17
0
import os
from page import Page
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "Page Not Found"
sub_page.in_index=False
sub_page.content = colour_print(printer.text_to_ascii("404", padding={"left": 30}))
sub_page.content += "\n\n"
sub_page.content += colour_print(printer.text_to_ascii("Page Not Found", padding={"left": 2}))
Ejemplo n.º 18
0
import os
from os.path import join,expanduser
from page import Page
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
p_page = Page(page_number)

p_page.title = "House Points"
p_page.index_num = "402-403"

content = p_page.colours.colour_print(printer.text_to_ascii("house points"))

content += "\n\n"

R = p_page.colours.Foreground.RED
G = p_page.colours.Foreground.GREEN
D = p_page.colours.Foreground.DEFAULT

content += G+"Year " + " Gryffindor Slytherin Hufflepuff"    +   " Ravenclaw Durmstrang Squib Peeves"+D+"\n"
content += G+"2015a"+D+" 692        535       "+R+"1155"+D+"       702       440        513   0\n"
content += G+"2015b"+D+" 3382       408       "+R+"4614"+D+"       3591      606        2174  38\n"

p_page.content = content