benten directories
目的
- ディレクトリ検索を行います。
Warning
事前にログイン認証を行う必要があります。
概要
- 認証時のアカウントでアクセスが許可されたデータのみ情報を取得できます。
- 登録時間で時間範囲の指定ができます。
- クエリで検索ができます。
利用例
- Help
$ benten.py directories -h usage: benten directories [-h] [--begindate [BEGINDATE]] [--enddate [ENDDATE]] [--query [QUERY]] [--size [SIZE]] [--begin_from [BEGIN_FROM]] [--flag_own] optional arguments: -h, --help show this help message and exit --begindate [BEGINDATE], -b [BEGINDATE] begindate --enddate [ENDDATE], -e [ENDDATE] enddate --query [QUERY], -q [QUERY] query --size [SIZE] search size --begin_from [BEGIN_FROM] id to begin search --flag_own, -o output with own file_list
- 時間指定での検索
$ benten.py directories -b "2018-04-01 00:00:00" -e "2019-04-01 00:00:00" ### benten directories ### [Repository::authorize] access_token = 0b513fb250d9456a8f900533bd91aeda ==> response { "total_count":1, "size":0, "begin_from":0, "register_name_list":[ "/SPring-8/BL14B2/data2/temp/Cu-K_Cu-foil_Si111_50ms_120613" ], "directory_list":[ "/SPring-8/BL14B2/data2/temp", "/SPring-8/BL14B2/data2/temp/Cu-K_Cu-foil_Si111_50ms_120613" ] }
- クエリでの検索例 (1)
$ benten.py directories -q Cu ### benten directories ### [Repository::authorize] access_token = 0b513fb250d9456a8f900533bd91aeda ==> response { "total_count":1, "size":0, "begin_from":0, "register_name_list":[ "/SPring-8/BL14B2/data2/temp/Cu-K_Cu-foil_Si111_50ms_120613" ], "directory_list":[ "/SPring-8/BL14B2/data2/temp", "/SPring-8/BL14B2/data2/temp/Cu-K_Cu-foil_Si111_50ms_120613" ] }
- クエリでの検索例 (2)
$ benten.py directories -q "Cu AND @subject@proposal_number:2014S0000" (benten) C:\Users\matumot>python.exe C:\Users\matumot\Miniconda3\envs\benten\Scripts\\benten.py directories -q "sel:Cu AND subject_proposal_number:2014S0000" ### benten directories ### [Repository::authorize] access_token = 0b513fb250d9456a8f900533bd91aeda ==> response { "total_count":1, "size":0, "begin_from":0, "register_name_list":[ "/SPring-8/BL14B2/data2/temp/Cu-K_Cu-foil_Si111_50ms_120613" ], "directory_list":[ "/SPring-8/BL14B2/data2/temp", "/SPring-8/BL14B2/data2/temp/Cu-K_Cu-foil_Si111_50ms_120613" ] }
Pythonモジュールとの対応
- benten_client.rest_data.Directories を利用
- 利用例 (example/benten_directories.pyから)
#!/usr/bin/env python ''' example: directories usage: python benten_direcories.py ... ''' import benten_client import argparse from logging import getLogger, StreamHandler, DEBUG logger = getLogger(__name__) handler = StreamHandler() handler.setLevel(DEBUG) logger.setLevel(DEBUG) logger.addHandler(handler) logger.propagate = False # ... parameters parser = argparse.ArgumentParser(description="example: directories") parser.add_argument("--begindate", "-b", nargs="?", help="begindate") parser.add_argument("--enddate", "-e", nargs="?", help="enddate") parser.add_argument("--query", "-q", nargs="?", help="query") parser.add_argument("--size", nargs="?", help="search size") parser.add_argument("--begin_from", nargs="?", help="id to begin search") parser.add_argument("--flag_own", "-o", action="store_const", const=1, help="output with own file_list") args = parser.parse_args() begindate = args.begindate enddate = args.enddate query = args.query size = args.size begin_from = args.begin_from flag_own = args.flag_own v = {} if begindate is not None: v["begindate"] = begindate if enddate is not None: v["enddate"] = enddate if query is not None: v["query"] = query if size is not None: v["size"] = size if begin_from is not None: v["begin_from"] = begin_from if flag_own is not None: v["flag_own"] = flag_own repo = benten_client.Repository() logger.debug("# set access token") repo.authorize(benten_client.access_token()) logger.debug("# benten directories") ret_dict = repo.data.directories.post(**v) benten_client.log("==> response") benten_client.out_json(ret_dict)