politylink


Namepolitylink JSON
Version 0.1.40 PyPI version JSON
download
home_pagehttps://politylink.jp
Summary
upload_time2020-11-17 07:37:24
maintainer
docs_urlNone
authorMitsuki Usui
requires_python>=3.6.1,<4.0.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## インストール
```
pip install politylink
```

## 使い方

### GraphQLClient

PolityLinkの[GraphQLエンドポイント](https://graphql.politylink.jp/)にアクセスするためのGraphQLClientが用意されています。
```
from politylink.graphql.client import GraphQLClient
client = GraphQLClient()
```

`exec`メソッドを使えば任意のGraphQLクエリを実行することができます。
```
query = """
query {
  Bill(filter: {submittedDate: {year: 2020, month: 1, day: 20}}) {
    name
  }
}
"""
client.exec(query)
```
2020年1月20日に提出された3つの法律案の名前が得られるはずです。
```
{'data': {'Bill': [{'name': '特定複合観光施設区域の整備の推進に関する法律及び特定複合観光施設区域整備法を廃止する法律案'},
   {'name': '地方交付税法及び特別会計に関する法律の一部を改正する法律案'},
   {'name': '平成三十年度歳入歳出の決算上の剰余金の処理の特例に関する法律案'}]}}
```

GraphQLClientは[sgglc](https://github.com/profusion/sgqlc)のラッパークラスであり、クエリをコードで組み立てることも可能です。例えば上のクエリを組み立てると以下のようになります。
```
from politylink.graphql.schema import Query, _BillFilter, _Neo4jDateTimeInput
from sgqlc.operation import Operation

op = Operation(Query)
bill_filter = _BillFilter(None)
bill_filter.submitted_date = _Neo4jDateTimeInput(year=2020, month=1, day=20)
bills = op.bill(filter=bill_filter)
bills.name()
client.exec(op)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://politylink.jp",
    "name": "politylink",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.1,<4.0.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mitsuki Usui",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/34/49/db8cce627af1eaa380677eb42bf57ec0f79ac6ca7621f459710551bcbc87/politylink-0.1.40.tar.gz",
    "platform": "",
    "description": "## \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n```\npip install politylink\n```\n\n## \u4f7f\u3044\u65b9\n\n### GraphQLClient\n\nPolityLink\u306e[GraphQL\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8](https://graphql.politylink.jp/)\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306eGraphQLClient\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\n```\nfrom politylink.graphql.client import GraphQLClient\nclient = GraphQLClient()\n```\n\n`exec`\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3048\u3070\u4efb\u610f\u306eGraphQL\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n```\nquery = \"\"\"\nquery {\n  Bill(filter: {submittedDate: {year: 2020, month: 1, day: 20}}) {\n    name\n  }\n}\n\"\"\"\nclient.exec(query)\n```\n2020\u5e741\u670820\u65e5\u306b\u63d0\u51fa\u3055\u308c\u305f3\u3064\u306e\u6cd5\u5f8b\u6848\u306e\u540d\u524d\u304c\u5f97\u3089\u308c\u308b\u306f\u305a\u3067\u3059\u3002\n```\n{'data': {'Bill': [{'name': '\u7279\u5b9a\u8907\u5408\u89b3\u5149\u65bd\u8a2d\u533a\u57df\u306e\u6574\u5099\u306e\u63a8\u9032\u306b\u95a2\u3059\u308b\u6cd5\u5f8b\u53ca\u3073\u7279\u5b9a\u8907\u5408\u89b3\u5149\u65bd\u8a2d\u533a\u57df\u6574\u5099\u6cd5\u3092\u5ec3\u6b62\u3059\u308b\u6cd5\u5f8b\u6848'},\n   {'name': '\u5730\u65b9\u4ea4\u4ed8\u7a0e\u6cd5\u53ca\u3073\u7279\u5225\u4f1a\u8a08\u306b\u95a2\u3059\u308b\u6cd5\u5f8b\u306e\u4e00\u90e8\u3092\u6539\u6b63\u3059\u308b\u6cd5\u5f8b\u6848'},\n   {'name': '\u5e73\u6210\u4e09\u5341\u5e74\u5ea6\u6b73\u5165\u6b73\u51fa\u306e\u6c7a\u7b97\u4e0a\u306e\u5270\u4f59\u91d1\u306e\u51e6\u7406\u306e\u7279\u4f8b\u306b\u95a2\u3059\u308b\u6cd5\u5f8b\u6848'}]}}\n```\n\nGraphQLClient\u306f[sgglc](https://github.com/profusion/sgqlc)\u306e\u30e9\u30c3\u30d1\u30fc\u30af\u30e9\u30b9\u3067\u3042\u308a\u3001\u30af\u30a8\u30ea\u3092\u30b3\u30fc\u30c9\u3067\u7d44\u307f\u7acb\u3066\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\u4f8b\u3048\u3070\u4e0a\u306e\u30af\u30a8\u30ea\u3092\u7d44\u307f\u7acb\u3066\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\n```\nfrom politylink.graphql.schema import Query, _BillFilter, _Neo4jDateTimeInput\nfrom sgqlc.operation import Operation\n\nop = Operation(Query)\nbill_filter = _BillFilter(None)\nbill_filter.submitted_date = _Neo4jDateTimeInput(year=2020, month=1, day=20)\nbills = op.bill(filter=bill_filter)\nbills.name()\nclient.exec(op)\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.40",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "f7dc95f2f1087706f89d6885f89166e6",
                "sha256": "8a52f59eab448ffb71627a813b568afd80e2b63985db56368f9c6cde4ef108f0"
            },
            "downloads": -1,
            "filename": "politylink-0.1.40-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7dc95f2f1087706f89d6885f89166e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.1,<4.0.0",
            "size": 30609,
            "upload_time": "2020-11-17T07:37:23",
            "upload_time_iso_8601": "2020-11-17T07:37:23.101301Z",
            "url": "https://files.pythonhosted.org/packages/08/47/4bdb221717bb821cb47407ca201b7988c1b51766aec97927a37b6cf618cf/politylink-0.1.40-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "7d9157f3986f595202d937c3c0382ada",
                "sha256": "4321663ed4d7c37e9d8687457b5e0cfd395eb8355002f26dd82f7016d569ab11"
            },
            "downloads": -1,
            "filename": "politylink-0.1.40.tar.gz",
            "has_sig": false,
            "md5_digest": "7d9157f3986f595202d937c3c0382ada",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.1,<4.0.0",
            "size": 29021,
            "upload_time": "2020-11-17T07:37:24",
            "upload_time_iso_8601": "2020-11-17T07:37:24.802160Z",
            "url": "https://files.pythonhosted.org/packages/34/49/db8cce627af1eaa380677eb42bf57ec0f79ac6ca7621f459710551bcbc87/politylink-0.1.40.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-17 07:37:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "politylink"
}
        
Elapsed time: 0.17480s