def h_qterm2j_doc(cls): logger = HenriqueLogger.func_level2logger(cls.h_qterm2j_doc, logging.DEBUG) j_doc_list = list(TradegoodDocument.j_doc_iter_all()) jpath = TradegoodDocument.jpath_names() h_list = [{ cls._query2qterm(name): j_doc } for j_doc in j_doc_list for name_list_lang in jdown(j_doc, jpath).values() for name in name_list_lang] logger.debug({ "h_list": iter2duplicate_list( lmap(lambda h: iter2singleton(h.keys()), h_list)), "jpath": jpath, "j_doc_list[0]": j_doc_list[0], "query[0]": jdown(j_doc_list[0], jpath) }) qterm_list_duplicate = iter2duplicate_list( map(lambda h: iter2singleton(h.keys()), h_list)) h_list_clean = lfilter( lambda h: iter2singleton(h.keys()) not in qterm_list_duplicate, h_list) h = merge_dicts(h_list_clean, vwrite=vwrite_no_duplicate_key) return h
def str2entity_list(cls, str_in): m_list = list(cls.pattern().finditer(str_in)) entity_list = [merge_dicts([EntityTool.F.match2h(m), EntityTool.F.type2h(cls.NAME), ]) for m in m_list] return entity_list
def match2h(cls, m): span = MatchToolkit.match2span(m) text = MatchToolkit.match2text(m) l = [ cls.span2h(span), cls.text2h(text), cls.value2h(text), ] return merge_dicts(l)
def creds_gdoc_id2metadata( cls, creds, gdoc_id, options=None, ): str_SCOPE = "drive.readonly" service = build('drive', 'v3', http=creds.authorize(Http())) h = merge_dicts([ { "fileId": gdoc_id, }, options, ]) b = service.files().get(**h).execute() return b
def googledocument_id2metadata( gdoc_id, options=None, ): # add creds # ?load google port https://asdfasdfa """Shows basic usage of the Sheets API. Prints values from a sample spreadsheet. """ # username_GOOGLE = "foxytrixy.bot" str_SCOPE = "drive.readonly" creds = username_scope2creds(USERNAME_GOOGLE_FOXYTRIXY_BOT, str_SCOPE) service = build('drive', 'v3', http=creds.authorize(Http())) h = merge_dicts([ { "fileId": gdoc_id, }, options, ]) b = service.files().get(**h).execute() #s = b.decode('utf-8') return b