benten proposal

目的

  • 課題番号の検索を行います。

Warning

事前にログイン認証を行う必要があります。

概要

  • 認証時のアカウントでアクセスできる課題番号リストが取得できます。

利用例

  • Help
$ benten.py proposal -h
usage: benten proposal [-h] [--begindate [BEGINDATE]]
                       [--enddate [ENDDATE]] [--facility [FACILITY]]

optional arguments:
  -h, --help            show this help message and exit
  --begindate [BEGINDATE], -b [BEGINDATE]
                        begindate
  --enddate [ENDDATE], -e [ENDDATE]
                        enddate
  --facility [FACILITY], -f [FACILITY]
                        facility
  • 課題番号リスト取得
$ benten.py proposal
### benten proposal ###
[Repository::authorize] access_token = 579773811dc7401ea1307c99d2a88a82
==> response
{
    "list":[
        "2014S0000"
     ]
}

Pythonモジュールとの対応

#!/usr/bin/env python
'''
  example: proposal

  usage: python benten_proposal.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: proposal")
parser.add_argument("--begindate", "-b", nargs="?", help="begindate")
parser.add_argument("--enddate", "-e", nargs="?", help="enddate")
parser.add_argument("--facility", "-f", nargs="?", help="facility")

args = parser.parse_args()

begindate = args.begindate
enddate = args.enddate
facility = args.facility

v = {}
if begindate is not None:
    v["begindate"] = begindate
if enddate is not None:
    v["enddate"] = enddate
if facility is not None:
    v["facility"] = facility

repo = benten_client.Repository() 

logger.debug("# set access token")

repo.authorize(benten_client.access_token())

logger.debug("# benten proposal")

ret_dict = repo.proposal.post(**v)

benten_client.log("==> response")
benten_client.out_json(ret_dict)