def noorlib_scr(url: str, date_format: str = '%Y-%m-%d') -> tuple: """Create the response namedtuple.""" dictionary = bibtex_parse(get_bibtex(url)) dictionary['date_format'] = date_format # risr = get_ris(url)[1] # dictionary = risr.parse(ris)[1] return dict_to_sfn_cit_ref(dictionary)
def noorlib_sfn_cit_ref(url: str, date_format: str = '%Y-%m-%d') -> tuple: """Create the response namedtuple.""" dictionary = bibtex_parse(get_bibtex(url)) dictionary['date_format'] = date_format # risr = get_ris(url)[1] # dictionary = risr.parse(ris)[1] return dict_to_sfn_cit_ref(dictionary)
def isbn_scr(isbn_container_str: str, pure: bool = False, date_format: str = '%Y-%m-%d') -> tuple: """Create the response namedtuple.""" if pure: isbn = isbn_container_str else: # search for isbn13 m = ISBN13_SEARCH(isbn_container_str) if m is not None: isbn = m[0] else: # search for isbn10 m = ISBN10_SEARCH(isbn_container_str) isbn = m[0] iranian_isbn = isbn_info(isbn) == 'Iran' if iranian_isbn is True: ketabir_result_list = [] ketabir_thread = Thread(target=ketabir_thread_target, args=(isbn, ketabir_result_list)) ketabir_thread.start() citoid_result_list = [] citoid_thread = Thread(target=citoid_thread_target, args=(isbn, citoid_result_list)) citoid_thread.start() ottobib_bibtex = ottobib(isbn) if ottobib_bibtex: otto_dict = bibtex_parse(ottobib_bibtex) else: otto_dict = None if iranian_isbn is True: # noinspection PyUnboundLocalVariable ketabir_thread.join() # noinspection PyUnboundLocalVariable if ketabir_result_list: # noinspection PyUnboundLocalVariable ketabir_dict = ketabir_result_list[0] else: ketabir_dict = None dictionary = choose_dict(ketabir_dict, otto_dict) else: dictionary = otto_dict citoid_thread.join() if citoid_result_list: dictionary['oclc'] = citoid_result_list[0]['oclc'] dictionary['date_format'] = date_format if 'language' not in dictionary: dictionary['language'] = classify(dictionary['title'])[0] return dict_to_sfn_cit_ref(dictionary)
def jstor_scr(url: str, date_format: str = '%Y-%m-%d') -> tuple: open_access = [] thread = Thread(target=is_open_access, args=(url, open_access)) thread.start() id_ = urlparse(url).path.rpartition('/')[2] bibtex = request('https://www.jstor.org/citation/text/' + id_).content.decode('utf8') dictionary = bibtex_parse(bibtex) dictionary['jstor'] = id_ dictionary['date_format'] = date_format thread.join() if open_access: dictionary['jstor-access'] = 'free' return dict_to_sfn_cit_ref(dictionary)
def noormags_sfn_cit_ref(url: str, date_format: str = '%Y-%m-%d') -> tuple: """Create the response namedtuple.""" ris_collection = {} ris_thread = Thread(target=ris_fetcher_thread, args=(url, ris_collection)) ris_thread.start() dictionary = bibtex_parse(get_bibtex(url)) dictionary['date_format'] = date_format # language parameter needs to be taken from RIS # other information are more accurate in bibtex # for example: http://www.noormags.ir/view/fa/articlepage/104040 # "IS - 1" is wrong in RIS but "number = { 45 }," is correct in bibtex ris_thread.join() dictionary.update(ris_collection) return dict_to_sfn_cit_ref(dictionary)
def isbn_sfn_cit_ref( isbn_container_str: str, pure: bool = False, date_format: str = '%Y-%m-%d' ) -> tuple: """Create the response namedtuple.""" if pure: isbn = isbn_container_str else: # search for isbn13 m = ISBN13_SEARCH(isbn_container_str) if m: isbn = m[0] else: # search for isbn10 m = ISBN10_SEARCH(isbn_container_str) isbn = m[0] ketabir_result_list = [] ketabir_thread = Thread( target=ketabir_thread_target, args=(isbn, ketabir_result_list)) ketabir_thread.start() citoid_result_list = [] citoid_thread = Thread( target=citoid_thread_target, args=(isbn, citoid_result_list)) citoid_thread.start() ottobib_bibtex = ottobib(isbn) if ottobib_bibtex: otto_dict = bibtex_parse(ottobib_bibtex) else: otto_dict = None ketabir_thread.join() if ketabir_result_list: ketabir_dict = ketabir_result_list[0] else: ketabir_dict = None dictionary = choose_dict(ketabir_dict, otto_dict) citoid_thread.join() if citoid_result_list: dictionary['oclc'] = citoid_result_list[0]['oclc'] dictionary['date_format'] = date_format if 'language' not in dictionary: dictionary['language'] = classify(dictionary['title'])[0] return dict_to_sfn_cit_ref(dictionary)