8663f9c44c1333686c428854ff378af059dc5276
3 NOTES_DIRECTORY
= '/home/dylan/docs/notes'
10 config
= ConfigParser
.RawConfigParser()
11 config
.read('/etc/dylanstestserver.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
== 'index.php' or note
== 'notes.php': continue
29 url
= note
[:note
.index('.')]
30 f
= open(os
.path
.join(NOTES_DIRECTORY
, note
))
31 title
= str(f
.readline()[:-1])
32 text
= ''.join(f
.readlines()) #converts list to single string
33 if title
in existing_titles
: continue
34 mtime
= time
.localtime(os
.path
.getmtime(os
.path
.join(NOTES_DIRECTORY
, note
)))
35 date_posted
= "%s-%s-%s" % (str(mtime
.tm_year
)[2:], mtime
.tm_mon
, mtime
.tm_mday
)
36 sql
= "INSERT INTO notes (date_posted, url, title, text)\
37 VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\
38 % (date_posted
, url
, title
, db
.escape_string(text
))