More notes and some helpful scripts

master
Justyna Ilczuk 2013-01-19 12:05:28 +01:00
parent abe640e75c
commit b8dc38bc99
135 changed files with 143 additions and 4 deletions

60
notemanager.py Normal file
View File

@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
import os
from contextlib import closing
import sqlite3
DATABASE = '/tmp/notes.db'
def add_all_notes_in_dir(path):
os.chdir(path)
subjects = os.listdir(os.getcwd())
if "bootstrap" in subjects:
subjects.remove("bootstrap")
for subject in subjects:
os.chdir(subject)
for date in os.listdir(os.getcwd()):
notes = []
os.chdir(date)
for note in os.listdir(os.getcwd()):
notes.append({"tags": "none", "name": note})
add_note(subject, date, notes)
os.chdir("..")
os.chdir("..")
def add_note(subject, datestring, notes):
connection_db = connect_db()
db = connection_db.cursor()
db.execute('insert into notes (subject, datestring ) values (?, ?)', [subject, datestring])
note_id = db.lastrowid
for note in notes:
db.execute('insert into pages (note_id, name, tags ) values (?, ?, ?)', [note_id, note["name"], note["tags"]])
connection_db.commit()
def connect_db():
return sqlite3.connect(DATABASE)
def add_notes_to_db():
query_result = query_db("select * from pages ")
print query_result
if not query_result:
add_note("analiza", "9stycznia", notes)
db.close()
def init_db():
db = connect_db()
f = open("schema.sql", "r")
db.cursor().executescript(f.read())
db.commit()
def main():
init_db()
path = raw_input("Path: ")
try:
add_all_notes_in_dir(path)
except OSError:
pass
if __name__ == "__main__":
main()

43
noterapist.py Normal file
View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
import requests
import bs4
def rape(_callback, url):
r = requests.get(url)
r.encoding = "utf-8"
soup = bs4.BeautifulSoup(r.text)
gallery = soup.findAll("div", id="gallery")[0]
notes = gallery.findAll("ul")
for note in notes:
inner = note.find("li")
title = inner.find("b").text
funny = inner.find("i").text
_callback(title, funny, [c["href"] for c in inner.findAll("a")])
import os
import re
def callback(date, funny, pages):
print date
print funny
safe = re.sub("[^a-z0-9A-Z]", "", date)
try:
os.mkdir(safe)
except OSError:
pass
for i, page in enumerate(pages):
os.system("curl %s > %s/%02i.jpg" % (page, safe, i))
print page
def main():
subject = raw_input("Subject: ")
webpage = raw_input("Page name: ")
try:
os.mkdir(subject)
except OSError:
pass
os.chdir(subject)
rape(callback, "http://student.if.pw.edu.pl/~patmad/" + webpage)
if __name__ == "__main__":
main()

37
noterapist.py~ Normal file
View File

@ -0,0 +1,37 @@
import requests
import bs4
def rape(_callback, url):
r = requests.get(url)
r.encoding = "utf-8"
soup = bs4.BeautifulSoup(r.text)
gallery = soup.findAll("div", id="gallery")[0]
notes = gallery.findAll("ul")
for note in notes:
inner = note.find("li")
title = inner.find("b").text
funny = inner.find("i").text
_callback(title, funny, [c["href"] for c in inner.findAll("a")])
import os
import re
def callback(date, funny, pages):
print date
print funny
safe = re.sub("[^a-z0-9A-Z]", "", date)
try:
os.mkdir(safe)
except OSError:
pass
for i, page in enumerate(pages):
os.system("curl %s > %s/%02i.jpg" % (page, safe, i))
print page
rape(callback, "http://student.if.pw.edu.pl/~patmad/Mech.html")

View File

@ -56,7 +56,8 @@ def teardown_request(exception):
g.db.close()
except AttributeError:
pass
@app.route('/')
@app.route('/view')
@app.route('/view/<subject>/<datestring>')
def home(subject= "chemia", datestring= "12grudnia"):

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 KiB

Some files were not shown because too many files have changed in this diff Show More