-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPyCiteAPAFree.py
154 lines (147 loc) · 5.34 KB
/
PyCiteAPAFree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""Does APA Citations for Journals, Newspapers, and books and websites"""
def apa():
"""Picks what type of work is being cited"""
document_type = raw_input('Are you citing a website, a newspaper, a book,'\
' or a journal? ')
print""
document_type = document_type.lower()
if document_type == 'website':
website()
elif document_type == 'newspaper':
newspaper()
elif document_type == 'book':
book()
elif document_type == 'journal':
journal()
else:
print "Please choose a website, a newspaper, a book, or a journal"
apa()
def print_m(citation):
"""helper function to print to file and to console"""
print "Your citation is: "
print ""
print citation
file_for_citation = open('references.odt', 'a')
file_for_citation.write(citation + '\n')
file_for_citation.write('')
def year():
"""Defines the year of the work"""
year_of_work = raw_input("What year was this published, followed by the"\
"month and date. Enter n.d if unknown ")
print""
return "(%s) " % (year_of_work)
def title():
"""Recieves and formats the title"""
title_of_work = raw_input("What is the title of the work? ")
print""
title_first = title_of_work[0].upper()
title_rest = title_of_work[1:].lower()
title_full = title_first + title_rest
return "%s. " % (title_full)
def info():
"""Formats the author info, and joins it with the year and title"""
author_list = []
starting_point = 1
amount_authors = raw_input("How many authors are there? Select 1-4. ")
print''
amount_authors = int(amount_authors)
if amount_authors >= 1 and amount_authors <= 4:
while starting_point <= amount_authors:
author_first = raw_input("What is the author's first name? ")
author_last = raw_input("What is the author's last name? ")
print''
author_last = author_last[0].upper() + author_last[1:].lower()
author_first = author_first[0].upper()
author_full = "%s, %s. " % (author_last, author_first)
author_list.append(author_full)
starting_point += 1
author_cite = "".join(author_list)
else:
print "You need to enter a number between 1 and 4"
print ''
info()
return author_cite + title() + year()
def website():
"""Website citations"""
retrieved_from = raw_input("What is the address of the website? ")
print''
date = raw_input("What day did you visit this site? ")
print''
retrieved_from = "Retrieved %s from %s" % (date, retrieved_from)
citation = info() + retrieved_from
print_m(citation)
exit_messages()
def newspaper():
"""Newspaper Citations"""
publisher = raw_input("What is the name of the publishing company? ")
print''
page = raw_input("What page(s) did you find the article on? ")
print ''
publisher = ("%s, pp. %s.") % (publisher, page)
electronic = raw_input("Was this retrieved from a website? y/n ")
print ''
electronic = electronic.lower()
if electronic == 'y':
site = raw_input('What is the website you found it on? ')
print ''
date = raw_input("What day did you last visit this site? ")
print ''
site = "Retrieved %s from %s" % (date, site)
else:
site = " "
citation = info() + publisher + site
print_m(citation)
exit_messages()
def book():
"""Book citations"""
location = raw_input('Where was the book published? ')
print''
location = location[0].upper() + location[1:].lower()
location = "%s: " % (location)
publisher = raw_input("What is the name of the publishing company? ")
print''
publisher = publisher[0].upper() + publisher[1:].lower()
publisher = "%s." % (publisher)
citation = info() + location + publisher
print_m(citation)
exit_messages()
def journal():
"""Journal Citation"""
journal_name = raw_input('What is the name of the journal? ')
journal_name = journal_name[0].upper() + journal_name[1]
print ''
volume = raw_input('What volume number is it? ')
print ''
pages = raw_input('What is the page range of the article? ')
print ''
doi = raw_input("What is the DOI number? ")
print ''
web = raw_input('Was it found on a website? y/n ')
web = web.lower()
if web == "y":
site = raw_input('What website was it found on? ')
date = raw_input("What day did you visit it? ")
web_and_date = " Retrieved from: %s on %s " % (site, date)
else:
web_and_date = " "
journal_name = " %s, %s, %s. doi: %s." % (journal_name, volume, pages, doi)
citation = info() + journal_name + web_and_date
print_m(citation)
exit_messages()
def exit_messages():
"""messages displayed after the citation"""
print ""
print "Your file can be found in the document references.odt"
print""
print "To copy from here, right click the title bar, highlight over the"\
"edit item and select mark. Highlight the citation and hit enter on"\
"your keyboard. Your citation is now ready for use"
print ""
more = raw_input('Would you like to PyCite another item? y/n ')
if more.lower() == "y":
apa()
else:
print "Goodbye"
exit()
print "Welcome to PyCite APA Free Edition"
apa()