Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #/home/clockworkpc/bin/casetagcreator.py
- # Released under a GPLv3 Licence by Clockwork PC 2012
- # www.clockworkpc.com.au
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- import os
- import glob
- import fnmatch
- import fileinput
- import re
- import sys
- import datetime
- masterCaseFile = (os.getenv("HOME")+"/Dropbox/Deakin/Tiddlywiki/TiddlyTags/MasterFiles/master_tiddlycases.txt")
- os.system("touch " + "'" + masterCaseFile + "'")
- now = datetime.datetime.now()
- nowstring = str(now.strftime("%Y%m%d%H%M"))
- def caseTagGenerator():
- caseTagFile = (os.getenv("HOME")+"/Dropbox/Deakin/Tiddlywiki/TiddlyTags/CaseTags/caseTags_for_" + tiddlyCase + ".txt")
- os.system("touch " + "'" + caseTagFile + "'")
- running = True
- while running:
- caseTagQ = raw_input("Enter a case tag: ")
- if caseTagQ != "":
- caseTag = "[[" + caseTagQ + "]]"
- f = open(caseTagFile, "a")
- f.write(caseTag + " ")
- f.close()
- else:
- running=False
- with open(caseTagFile) as myfile:
- caseTags = (list(myfile)[-1])
- print caseTags
- global caseTags
- def caseInfoSheet():
- global tiddlyCase
- global caseJudge
- print ""
- now1 = datetime.datetime.now()
- #print str(now1.strftime("%Y%m%d%H%M"))
- print ""
- caseParty1 = raw_input("Enter the name of the first party: ")
- print ""
- caseParty2 = raw_input("Enter the name of the second party: ")
- print ""
- caseYear = raw_input("Enter the year only (no brackets): ")
- print ""
- caseYearQ = raw_input("""
- Which brackets?
- 1. Round brackets?
- 2. Square brackets?
- Enter your selection: """)
- print ""
- caseCitation = raw_input("Enter the case citation: ")
- print ""
- caseParagraph = raw_input("Enter the case paragraph, number only: ")
- print ""
- caseJudge = raw_input("Enter the name of the judge or justice, e.g. Kirby J or Kirby and Hughes JJ: ")
- print ""
- textBookPage = raw_input("What page number in the textbook does this citation appear on? ")
- now2 = datetime.datetime.now()
- #print str(now2.strftime("%Y%m%d%H%M"))
- print ""
- if caseJudge == "":
- if caseYearQ == "1":
- tiddlyCase = caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation
- tiddlyCaseP = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- tiddlyCasePP = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]] at " + caseParagraph + " (on page " + textBookPage + ")"
- tiddlyCasePPJ = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]] at " + caseParagraph + " (on page " + textBookPage + ")"
- f = open(masterCaseFile, "a")
- f.write(tiddlyCasePPJ + '\n')
- f.close()
- elif caseYearQ == "2":
- tiddlyCase = caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation
- tiddlyCaseP = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- tiddlyCasePP = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]] at " + caseParagraph + " (on page " + textBookPage + ")"
- tiddlyCasePPJ = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]] at " + caseParagraph + " (on page " + textBookPage + ")"
- f = open(masterCaseFile, "a")
- f.write(tiddlyCasePPJ + '\n')
- f.close()
- elif caseParagraph == "":
- if caseYearQ == "1":
- tiddlyCase = caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation
- tiddlyCaseP = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- tiddlyCasePPJ = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- f = open(masterCaseFile, "a")
- f.write(tiddlyCasePPJ + '\n')
- f.close()
- elif caseYearQ == "2":
- tiddlyCase = caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation
- tiddlyCaseP = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- tiddlyCasePPJ = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- f = open(masterCaseFile, "a")
- f.write(tiddlyCasePPJ + '\n')
- f.close()
- else:
- if caseYearQ == "1":
- tiddlyCase = caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation
- tiddlyCaseP = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- tiddlyCasePP = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]] at " + caseParagraph + " (on page " + textBookPage + ")"
- tiddlyCasePPJ = "*[[" + caseParty1 + " v " + caseParty2 + " (" + caseYear + ") " + caseCitation + "]] at " + caseParagraph + " per [[" + caseJudge + "]] (on page " + textBookPage + ")"
- f = open(masterCaseFile, "a")
- f.write(tiddlyCasePPJ + '\n')
- f.close()
- elif caseYearQ == "2":
- tiddlyCase = caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation
- tiddlyCaseP = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]]" + " (on page " + textBookPage + ")"
- tiddlyCasePP = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]] at " + caseParagraph + " (on page " + textBookPage + ")"
- tiddlyCasePPJ = "*[[" + caseParty1 + " v " + caseParty2 + " [" + caseYear + "] " + caseCitation + "]] at " + caseParagraph + " per [[" + caseJudge + "]] (on page " + textBookPage + ")"
- f = open(masterCaseFile, "a")
- f.write(tiddlyCasePPJ + '\n')
- f.close()
- print tiddlyCasePPJ
- global tiddlyCasePPJ
- global tiddlyCase
- def caseJudgeFileGenerator():
- caseJudgeFolder = (os.getenv("HOME")+"/Dropbox/Deakin/Tiddlywiki/TiddlyTags/TiddlyJudges/")
- caseJudgeFile = (os.getenv("HOME")+"/Dropbox/Deakin/Tiddlywiki/TiddlyTags/TiddlyJudges/" + caseJudge + ".txt")
- os.system("touch " + "'" + "'" + caseJudgeFile + "'")
- g = open(caseJudgeFile, "a")
- g.write("<div title=" + '"' + caseJudge + '"' + ' modifier="TheCriticalG" created="' + str(now.strftime("%Y%m%d%H%M")) + '" modified=2"' + str(now.strftime("%Y%m%d%H%M")) + '" tags="' + caseTags + '"changecount="2">' + '\n' + "<pre>" + tiddlyCase + "</pre>" + '\n' + "</div>" + '\n')
- def caseNotesGenerator():
- global caseComment
- caseNoteFolder = (os.getenv("HOME")+"/Dropbox/Deakin/Tiddlywiki/TiddlyTags/CaseNotes/")
- caseNoteFile = caseNoteFolder + tiddlyCase
- caseNoteQ = raw_input("Enter the relevant principle or note: ")
- os.system("touch " + "'" + caseNoteFile + "'")
- running=True
- while running:
- if caseNoteQ != "":
- caseNote = caseNoteQ + ":" + '\n' + tiddlyCasePPJ
- h = open(caseNoteFile, "a")
- h.write("<div title=" + '"' + tiddlyCase + '"' + ' modifier="TheCriticalG" created="' + str(now.strftime("%Y%m%d%H%M")) + '" modified=2"' + str(now.strftime("%Y%m%d%H%M")) + '" tags="' + caseTags + '"changecount="2">' + '\n' + "<pre>" + caseNote + "</pre>" + '\n' + "</div>" + '\n')
- h.close()
- running=False
- else:
- running=False
- def advancedcaseJudgeFileGenerator():
- global caseJudgeFile
- if caseJudge != "":
- for file in os.listdir(caseJudgeFolder):
- if not fnmatch.fnmatch(file, caseJudgeFile):
- os.system("touch " + "'" + caseJudgeFile + "'")
- g = open(caseJudgeFile, "a")
- g.write("<div title=" + '"' + caseJudge + '"' + ' modifier="TheCriticalG" created="' + str(now.strftime("%Y%m%d%H%M")) + '" modified=2"' + str(now.strftime("%Y%m%d%H%M")) + '" tags="' + caseTags + '"changecount="2">' + '\n' + "<pre>" + tiddlyCaseP + "</pre>" + '\n' + "</div>" + '\n')
- elif fnmatch.fnmatch(file, JudgeFile):
- for file in os.listdir(caseJudgeFolder):
- if fnmatch.fnmatch(file, caseJudgeFile):
- foundFile = caseJudgeFolder + fnmatch.fnmatch(file, caseJudgeFile)
- for line in fileinput.input([foundFile], inplace=1):
- line = line.replace("</div>", tiddlyCaseP + '\n' + "</div>")
- print line,
- for line in fileinput.input([foundFile], inplace=1):
- line = line.replace('" changecount', ' ' + caseTags +'"' + " changecount")
- print line,
- def newCaseTest():
- newCaseQ = (raw_input("""
- Do you want to add another case?
- 1. Yes
- 2. No
- Enter your selection: """))
- if newCaseQ == 2:
- running = False
- os.system("clear")
- running = True
- while running:
- caseInfoSheet()
- caseTagGenerator()
- caseJudgeFileGenerator()
- caseNotesGenerator()
- newCaseTest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement