-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test* | ||
activate_env.bat | ||
dblpSearch.bat |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 MingXuan Yan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import json | ||
from os.path import dirname, abspath, join | ||
|
||
root = dirname(dirname(abspath(__file__))) | ||
with open(join(root, 'settings.json')) as f: | ||
settings = json.load(f) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import scraps.dblpSearcher as db | ||
import html_builder as hbuild | ||
import os | ||
import webbrowser | ||
from config import settings | ||
|
||
# load parameters | ||
CONFERENCES = settings['conferences'] | ||
NUMBER_PER_CONFERENCE = int(settings['number_per_conference']) | ||
NUMBER_PER_SEARCH = int(settings['number_per_search']) | ||
|
||
# init output file | ||
SAVE_PATH = 'output/dblp_output.html' | ||
SAVE_FULL_PATH = '{}/{}'.format(os.path.dirname(os.path.realpath(__file__)), SAVE_PATH) | ||
SAVE_FULL_PATH = SAVE_FULL_PATH.replace('\\', '/') | ||
print(SAVE_FULL_PATH) | ||
target = "file:///{}".format(SAVE_FULL_PATH) | ||
|
||
# search | ||
while True: | ||
terms = input("Search for: ") | ||
while True: | ||
mode = input("Search by conferences? [y/n]:") | ||
if mode == 'y': | ||
info = db.search_by_conference(terms, CONFERENCES, NUMBER_PER_CONFERENCE) | ||
break | ||
elif mode == 'n': | ||
info = db.search(terms, NUMBER_PER_SEARCH) | ||
break | ||
else: | ||
continue | ||
info = db.sort_by_year(info) | ||
hbuild.save_as_html(info, SAVE_PATH, heading=terms) | ||
webbrowser.open('file://' + SAVE_FULL_PATH) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import dominate | ||
from dominate.tags import * | ||
from utils.logging import * | ||
from utils.path import * | ||
from config import settings | ||
|
||
|
||
def save_as_html(info, path, heading=None): | ||
""" | ||
save a list of <info> elements as html file | ||
:param info: a list of dictionaries containing attributes of all entries | ||
:param path: path to output html file | ||
:param heading: a string as the title of the html page | ||
:return: | ||
""" | ||
doc = dominate.document(title='dblp searching results') | ||
with doc: | ||
if heading is not None: | ||
h1(str(heading)) | ||
h3(str(len(info)) + ' results') | ||
|
||
for _ in range(len(info)): | ||
info_entry(settings['entry_style'], info[_]) | ||
# li(a(info[_]['year'] + ', ' + info[_]['venue'] + ': ' + info[_]['title'], href=info[_]['ee'])) | ||
|
||
mkdir(path_parent(path)) | ||
with open(path, 'w', encoding='utf-8') as f: | ||
f.write(str(doc)) | ||
log(STD_INFO + 'Successfully saved to ' + path) | ||
|
||
|
||
def info_entry(style_, info): | ||
if style_['style'] == 'default': | ||
li(a(info['year'] + ', ' + info['venue'] + ': ' + info['title'], href=info['ee']) | ||
, style="line-height:{}px".format(style_['line_height'])) | ||
elif style_['style'] == 'rainbow': | ||
li( | ||
span(info['year'], style="color:{};".format(style_['rainbow_color']['year'])), | ||
" ", | ||
span(info['venue'], style="color:{};".format(style_['rainbow_color']['venue'])), | ||
" ", | ||
span(info['title'], style="color:{};".format(style_['rainbow_color']['title'])), | ||
" ", | ||
a("paper", href=info['ee']) | ||
, style="line-height:{}px".format(style_['line_height'])) | ||
else: | ||
raise ValueError("unknown entry type") |