Skip to content

Commit

Permalink
add url and doi features
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderSales committed Dec 15, 2023
1 parent df49287 commit 177e00f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
35 changes: 35 additions & 0 deletions lines/doi.py
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions lines/url.py
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 20 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 177e00f

Please sign in to comment.