def main(itemfile): """ Delete specified items on HVL-A2.0 by myHvlAlib library Read the items from the file. Arguments: itemfile: The path of file that contains item IDs(string) Return: None """ hvla = myhvlalib.myHvlA() with open(itemfile, 'r', encoding='utf-8') as f: lines = f.readlines() for i, line in enumerate(lines, 1): line = line.rstrip("\r\n") # Ref. https://docs.python.org/3/library/functions.html#print print("({0:>3}/{1:>3}) Deleting {2} ... ".format(i, len(lines), line), end='', flush=True) removeResultCode = hvla.remove(line) if removeResultCode == 0: print('SUCCESS') elif removeResultCode == 1: print('UNKNOWN (timeout)') elif removeResultCode == 2: print('FAILED (HTTPError)') elif removeResultCode == 3: print('FAILED (URLError)') print('Sleeping in 10 seconds ... ', end='', flush=True) time.sleep(10) print('Done')
def main(itemfile): """ Delete specified items on HVL-A2.0 by myHvlAlib library Read the items from the file. Arguments: itemfile: The path of file that contains item IDs(string) Return: None """ hvla = myhvlalib.myHvlA() with open(itemfile, "r", encoding="utf-8") as f: lines = f.readlines() for i, line in enumerate(lines, 1): line = line.rstrip("\r\n") # Ref. https://docs.python.org/3/library/functions.html#print print("({0:>3}/{1:>3}) Deleting {2} ... ".format(i, len(lines), line), end="", flush=True) removeResultCode = hvla.remove(line) if removeResultCode == 0: print("SUCCESS") elif removeResultCode == 1: print("UNKNOWN (timeout)") elif removeResultCode == 2: print("FAILED (HTTPError)") elif removeResultCode == 3: print("FAILED (URLError)") print("Sleeping in 10 seconds ... ", end="", flush=True) time.sleep(10) print("Done")
def main(id): """ Retrive all items on specified folder from HVL-A2.0 Output item ID/title/date/profile/url as CSV format Arguments: id: Item ID(string) Ex. FS-4 Return: None """ hvla = myhvlalib.myHvlA() # 3rd argument, '0', requires all items by browse API jsonDic = hvla.browse(id, '0', '0') results = jsonDic['results'] result_keys = ['id', 'title', 'date', 'profile', 'url'] print('no,' + ','.join(result_keys)) for i, result in enumerate(results, 1): output = str(i) for result_key in result_keys: output = output + ',' + result[result_key] print(output)
def main(id): """ Retrive all items on specified folder from HVL-A2.0 Output item ID/title/date/profile/url as CSV format Arguments: id: Item ID(string) Ex. FS-4 Return: None """ hvla = myhvlalib.myHvlA() # 3rd argument, '0', requires all items by browse API jsonDic = hvla.browse(id, '0', '0') results = jsonDic['results'] result_keys = [ 'id', 'title', 'date', 'profile', 'url' ] print('no,' + ','.join(result_keys)) for i, result in enumerate(results, 1): output = str(i) for result_key in result_keys: output = output + ',' + result[result_key] print(output)