Skip to content

Commit

Permalink
Added Author field
Browse files Browse the repository at this point in the history
  • Loading branch information
leostat committed May 6, 2017
1 parent 412b64d commit 5dac0ff
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 33 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# what
# What is it?
RTFM is a great and useful book, BUT a bit pointless when you have to transcribe it, so this little program will aim to be the spiritual successor to it.

I would recommend picking up a copy of the book from amazon, it is pretty handy to have!
I would recommend picking up a copy of the book from Amazon, it is pretty handy to have!

# Usage
```
Expand Down Expand Up @@ -97,7 +97,8 @@ https://github.com/leostat/rtfm
# The TODO list
* Lots, this is an alpha so far
* The 'important' functionality is present, but still lots of work to do

* Changes are happening on the DB, which means it may 'break' from time to time, just do a git pull to fix

## Fixes:
* Probabley should use prepared statements : local so dont care
* Check for dupe tags
Expand Down
1 change: 1 addition & 0 deletions clean.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CREATE TABLE TblCommand(
CmdID INTEGER PRIMARY KEY,
Cmd BYTE NOT NULL,
cmnt TEXT,
author TEXT,
date DATE
);
CREATE TABLE TblTagContent(
Expand Down
22 changes: 12 additions & 10 deletions rtfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def run():
iok = 1
sys.exit()
if not iok:
debug("http://www.youtube.com/watch?v = qRFhNZNu_xw")
debug("http://www.youtube.com/watch?v=qRFhNZNu_xw")
err("RTFM: rtfm -h OR rtfm.py -c ''")
else:
Search(conn, sqlcmd, sqltpl, sqllst)
Expand All @@ -125,7 +125,7 @@ def run():
####
def Search(conn, sqlcmd, sqltpl, sqllst):
cur = conn.cursor()
sql = "SELECT c.cmdid, c.cmd, c.cmnt, c.date, group_concat(DISTINCT tc.tag), group_concat(DISTINCT ref) "
sql = "SELECT c.cmdid, c.cmd, c.cmnt, c.date, c.author, group_concat(DISTINCT tc.tag), group_concat(DISTINCT ref)"
sql += " FROM tblcommand c JOIN tbltagmap tm ON tm.cmdid = c.cmdid JOIN tbltagcontent tc ON "
sql += " tc.tagid = tm.tagid JOIN tblrefmap rm ON rm.cmdid = c.cmdid"
sql += " JOIN tblrefcontent rc on rc.id = rm.refid"
Expand All @@ -144,7 +144,7 @@ def Search(conn, sqlcmd, sqltpl, sqllst):


def Updater(conn):
ok("This may appear to hang. Its due to my bad SQL, sorry, run with debug to get more info")
ok("This may appear to hang. Its due to my bad SQL, sorry, run with debug to get more info")
icmd = []
itags = []
irefs = []
Expand Down Expand Up @@ -260,8 +260,8 @@ def dbInsertRefs(conn, refs, cmdid):
def dbInsertCmdS(conn, cmd):
cur = conn.cursor()
if options.debug:
debug("I: INSERT INTO tblcommand VALUES (NULL, '"+str(cmd[0])+"', '"+str(cmd[1])+"', "+"date('now'))")
cur.execute("""INSERT INTO tblcommand VALUES (NULL, ?, ?, date("now"));""", cmd)
debug("I: INSERT INTO tblcommand VALUES (NULL, '"+str(cmd[0])+"', '"+str(cmd[1])+"', "+"', '"+str(cmd[2])+"', "+"date('now'))")
cur.execute("""INSERT INTO tblcommand VALUES (NULL, ?, ?, ?, date("now"));""", cmd)
conn.commit()
ok("Added Rows :"+str(cur.rowcount))
return cur.lastrowid
Expand All @@ -270,8 +270,8 @@ def dbInsertCmd(conn, cmds):
cur = conn.cursor()
if options.debug:
for cmd in cmds:
debug("I: INSERT INTO tblcommand VALUES (NULL, '"+str(cmd[0])+"', '"+str(cmd[1])+"', "+"date('now'))")
cur.executemany('INSERT INTO tblcommand VALUES (NULL, ?, ?, date("now"));', cmds)
debug("I: INSERT INTO tblcommand VALUES (NULL, '"+str(cmd[0])+"', '"+str(cmd[1])+"', "+"', '"+str(cmd[2])+"', "+"date('now'))")
cur.executemany('INSERT INTO tblcommand VALUES (NULL, ?, ?, ?, date("now"));', cmds)
conn.commit()
ok("Added Rows :" + str(cur.rowcount))

Expand All @@ -293,8 +293,9 @@ def Insert(conn):
while not (cmd == '' or cmd == 'EOC'):
cmd = raw_input("Enter your command : ")
cmt = raw_input("Enter you comment : ")
author = raw_input("Enter Author : ")
if cmd not in ('', 'EOC'):
cmds.append((cmd, cmt))
cmds.append((cmd, cmt, author))
dbInsertCmd(conn, cmds)
elif options.insert is 'r':
refs = []
Expand Down Expand Up @@ -405,6 +406,7 @@ def PrintThing(ret_cmd):
print "Comment : "+str(ret_cmd[2])
print "Tags : "+str(ret_cmd[4])
print "Date Added : "+str(ret_cmd[3])
print "Added By : "+str(ret_cmd[6])
print "References\n__________\n"+str(ret_cmd[5].replace(',', '\n'))
print "++++++++++++++++++++++++++++++\n"
elif options.printer is 'p':
Expand All @@ -419,7 +421,7 @@ def PrintThing(ret_cmd):
print str(ret_cmd[5].replace(',', '\n'))
elif options.printer is 'P':
table_data = [\
["Command ID ", str(ret_cmd[0])],
["Added By " + str(ret_cmd[6]),"Cmd ID : " + str(ret_cmd[0])],
["Command ", str(ret_cmd[1])],
["Comment ", str(ret_cmd[2])],
["Tags ", str(ret_cmd[4]).replace(',', '\n')],
Expand All @@ -428,7 +430,7 @@ def PrintThing(ret_cmd):
]
table = AsciiTable(table_data)
max_width = table.column_max_width(1)
wrapped_string = '\n'.join(wrap(ret_cmd[1], max_width))+"\n"
wrapped_string = '\n'.join(wrap(str(ret_cmd[1]), max_width))+"\n"
table.table_data[1][1] = wrapped_string
print table.table
else:
Expand Down
Loading

0 comments on commit 5dac0ff

Please sign in to comment.