regluit/notebooks/fix_build_3550.ipynb

185 lines
3.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"http://jenkins.unglueit.com/job/regluit/3550/console\n",
"\n",
"looking for book to replace the problematic one"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from regluit.experimental import bookdata\n",
"from regluit.core import isbn"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from regluit.core import bookloader\n",
"\n",
"#edition = bookloader.add_by_isbn('9789571349268')\n",
"#assert edition.work.language == 'zh-TW'\n",
"\n",
"edition = bookloader.add_by_isbn('9787544706919')\n",
"assert edition.work.language == 'zh-CN'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"r = bookloader.get_google_isbn_results('9787544706919')\n",
"r"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print r['items'][0]['volumeInfo']['title']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"item = r['items'][0]\n",
"info = item['accessInfo']\n",
"(item['id'], item.keys() , item)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def google_info(r):\n",
" if r is not None:\n",
" item = r['items'][0]\n",
" return {\n",
" 'id': item['id'], \n",
" 'title': item['volumeInfo']['title'], \n",
" 'lang': item['volumeInfo']['language'], \n",
" 'identifiers': item['volumeInfo']['industryIdentifiers']\n",
" }\n",
" else:\n",
" return {}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"google_info(r)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from itertools import islice\n",
"\n",
"results = []\n",
"\n",
"for isbn_ in islice(bookdata.thingisbn('9789571349268'),None):\n",
" r = bookloader.get_google_isbn_results(isbn_)\n",
" print (isbn_, google_info(r))\n",
" results.append((isbn_, google_info(r)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"len(results)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"for (isbn_, result) in results:\n",
" print (isbn_, result.get('lang'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"k = isbn.ISBN('7544706915')\n",
"k.to_string()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}