3 NOTES_DIRECTORY
= '/home/dylan/docs/notes'
10 config
= ConfigParser
.RawConfigParser()
11 config
.read('/etc/dylansserver.ini')
12 domain
= config
.get('database', 'domain')
13 user
= config
.get('database', 'user')
14 password
= config
.get('database', 'password').replace('"', '')
15 database
= config
.get('database', 'database')
16 cursor
= db
.connect(domain
, user
, password
, database
).cursor()
18 notes
= os
.listdir(NOTES_DIRECTORY
)
20 sql
= "SELECT title FROM notes"
22 results
= cursor
.fetchall()
25 existing_titles
.append(row
[0])
28 if note
[:1] == '.': continue
29 if note
== 'index.php' or note
== 'notes.php': continue
30 url
= note
[:note
.index('.')]
31 f
= open(os
.path
.join(NOTES_DIRECTORY
, note
))
32 title
= str(f
.readline()[:-1])
33 date_posted
= time
.strptime(str(f
.readline()[:-1]), "%Y/%m/%d %I:%M%p")
34 text
= ''.join(f
.readlines()) #converts list to single string
35 if title
in existing_titles
: continue
36 sql
= "INSERT INTO notes (date_posted, url, title, text)\
37 VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\
38 % (time
.strftime("%Y/%m/%d %I:%M:00", date_posted
), url
, title
, db
.escape_string(text
))