diff --git a/lines/doi.py b/lines/doi.py new file mode 100644 index 0000000..7aca4bd --- /dev/null +++ b/lines/doi.py @@ -0,0 +1,35 @@ +def doi(): + """ + encapsulate author program in a + function + """ + # imports + + import nltk + import re + + # file + + f_name="BibTex.bib" + + def opener(f_name): + file = open(f_name, 'r', encoding="utf8") + return file + + file=opener(f_name) + + # end prep + + endline='' + file = opener(f_name) + for line in file: + if (re.search('^doi',line)): + starter=line + line=line.lstrip('doi = {') + line=line.rstrip('},\n') + + endline=line + # print(endline) + return endline +# author=author() +# print(author) \ No newline at end of file diff --git a/lines/url.py b/lines/url.py new file mode 100644 index 0000000..661c1b8 --- /dev/null +++ b/lines/url.py @@ -0,0 +1,35 @@ +def url(): + """ + encapsulate author program in a + function + """ + # imports + + import nltk + import re + + # file + + f_name="BibTex.bib" + + def opener(f_name): + file = open(f_name, 'r', encoding="utf8") + return file + + file=opener(f_name) + + # end prep + + endline='' + file = opener(f_name) + for line in file: + if (re.search('^url',line)): + starter=line + line=line.lstrip('url = {') + line=line.rstrip('},\n') + + endline=line + # print(endline) + return endline +# author=author() +# print(author) \ No newline at end of file diff --git a/main.py b/main.py index f15491d..4bfc276 100644 --- a/main.py +++ b/main.py @@ -70,6 +70,25 @@ pages=pages.pages() + +# __________________________________ + +import lines + +from lines import url + +url=url.url() + + +# __________________________________ + +import lines + +from lines import doi + +doi=doi.doi() + + # __________________________________ import date @@ -78,6 +97,6 @@ # __________________________________ -reference = author + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + '[accessed: ' + date + '].' +reference = author + ' (' + year + ') ' + '\'' + title + '\'' + ',' + ' ' + journal + ',' + ' ' + volume + '(' + number + ')' + ' ' + 'pp. ' + pages + ', ' + 'available: ' + doi + ' / ' + url + ' [accessed: ' + date + '].' print(reference)