Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WaterHyacinthInNANHU committed Sep 10, 2021
0 parents commit 4bcf1fc
Show file tree
Hide file tree
Showing 28 changed files with 5,207 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test*
activate_env.bat
dblpSearch.bat
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/Tools.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
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.
7 changes: 7 additions & 0 deletions config/__init__.py
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)

Binary file added config/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
35 changes: 35 additions & 0 deletions dblpSearch.py
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)

47 changes: 47 additions & 0 deletions html_builder/__init__.py
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")
Binary file added html_builder/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Loading

0 comments on commit 4bcf1fc

Please sign in to comment.