Browse Source

Merge pull request #3 from joyeusenoelle/dev

Add beginnings of citation input; minor changes
master
Noëlle Anthony 5 years ago
parent
commit
4e1f06564e
No account linked to committer's email address
1 changed files with 29 additions and 3 deletions
  1. 29
    3
      pyris.py

+ 29
- 3
pyris.py View File



def getAuthors(self): def getAuthors(self):
astr = "" astr = ""
for author in self.authors:
astr += "A1 - {}\n".format(author)
for author in self.authors.values():
astr += "AU - {}\n".format(author)
return astr return astr


def addType(self, ctype): def addType(self, ctype):
self.date.info = "" if info == None else info self.date.info = "" if info == None else info


def getDate(self): def getDate(self):
return "CY - {}/{}/{}/{}\n".format(self.date.year, self.date.month, self.date.day, self.date.info)
return "PY - {}/{}/{}/{}\n".format(self.date.year, self.date.month, self.date.day, self.date.info)




class CiteList: class CiteList:
self.contents = f.read() self.contents = f.read()
self.outfile = self.fn + ".ris" self.outfile = self.fn + ".ris"


def loadCitations(self):
""" Create citations from self.content.
Input: each citation in EndNote format begins with ^PT
and ends with ^ER
There's a blank line between records that can be discarded
"""
lines = self.contents.split("\n")
cite = Citation()
authors = False
title = False
sTitle = ""
for line in lines:
if line == "PT J":
cite.addType("JOUR")
if line[:2] == "AF": # we're on authors
authors = True
cite.addAuthor(line[3:])
elif authors and line[:2] == " ": # another author
cite.addAuthor(line[3:])
elif authors:
authors = False
if line[:2] == "TI": # we're on the title
title = True
cite.addTitle(line[])


def toString(self): def toString(self):
rstr = "Current infile: {}.{}".format(self.fn, self.ext) rstr = "Current infile: {}.{}".format(self.fn, self.ext)
rstr += "\n" rstr += "\n"

Loading…
Cancel
Save