(看) Kan: To Read

Kan is book search utility so you spend less time searching and more time reading.

Quickstart Guide

(看) Kan: To Read

Build Status GitHub version PyPI version Documentation Status

Kan is book search utility so you spend less time searching and more time reading.

Installation

Install from PyPi

$ pip install kan

From Source

To get the latest version to try out, clone the github repo.

$ git clone https://github.com/jjangsangy/kan.git

Use setup.py to install

# For Python 2.x Install
$ python setup.py install

# For Python 3.x
$ python3 setup.py install

Usage

# Print Out Help Instructions
$ kan -h
Usage: kan [-h] [-v] [--title name] [--author name] [--max n]
           [--subject topic] [--language code]
           {title,isbn,author} ...

Kan helps you find the book

positional arguments:
  {title,isbn,author}  Search by
    title              Book title
    isbn               ISBN code
    author             Book author

optional arguments:
  -h, --help           show this help message and exit
  -v, --version        show program's version number and exit
  --title name         Title of the book
  --author name        Name of the author
  --max n              Maximum results to get per query: default=10, max=40
  --subject topic      Specify subject matter by category
  --language code      Restrict the search results to those with a certain
                       language code

Simplest way is to search for book by title. By default, you’ll get the top 3 matches.

$ kan title 'Fifty Shades'
Title: Fifty Shades of Grey
Author: E L James
ISBN_13: 9781448149452

Title: Fifty Shades Darker
Author: E. L. James
ISBN_10: 0385537689

Title: Fifty Shades Freed
Author: E L James
ISBN: N/A

Search more generally and tweak your search parameters.

$ kan --language ko --max 5 author 'J. K. Rowling' --top
Title: 해리포터와마법사의돌
Author: J. K. Rowling, 김혜원
OTHER: OCLC:226262132

Title: 해리포터와혼혈왕자
Author: J. K. Rowling, 최인자
OTHER: OCLC:226262119

Title: 해리포터와비밀의방
Author: J. K. Rowling, 김혜원
OTHER: OCLC:226262164

Title: 해리포터와불의잔
Author: 조앤 K. 롤링, 김혜원
ISBN_10: 8983920955

Title: 해리포터와죽음의성물
Author: J. K. Rowling, 최인자
ISBN_10: 898392067X

API Documentation

API Module Referece

Abstract base classes complement duck-typing by providing a way to define interfaces when other techniques like hasattr() would be clumsy or subtly wrong (for example with magic methods). ABCs introduce virtual subclasses, which are classes that don’t inherit from a class but are still recognized by isinstance() and issubclass(); see the abc module documentation. Python comes with many built-in ABCs for data structures (in the collections.abc module), numbers (in the numbers module), streams (in the io module), import finders and loaders (in the importlib.abc module). You can create your own ABCs with the abc module.

AbstractBaseClass

Unlike Java abstract methods, these abstract methods may have an implementation. This implementation can be called via the super() mechanism from the class that overrides it. This could be useful as an end-point for a super-call in a framework that uses cooperative multiple-inheritance.

class kan.AbstractBaseAPIClient

AbstractBaseAPIClient that specifies the abstractmethods necessary to propertly be handled. The AbstractBaseClass defines a minimal set of methods that establish the characteristic behavior for the APIClient.

Code that discriminates based on Abstract methods can trust that those methods will always be present.

connect()

Makes connection to the backend API and handles any exceptions.

reader

Reads content.

Return text:str
url

Routes to proper destination URL and proper encoding schemes.

Return url:str

Implementations

class kan.GoogleBooksAPIClient(title='', author='', max_results=10, start_index=0, language_code='', fields=())

Implements the AbstractBaseAPIClient and talks to the google books api for querying and finding books.

Parameters:
  • title – str
  • author – str
  • max_results – int
  • start_index – int
  • language_code – str
  • fields – tuple
Return self:

GoogleBooksAPIClient

connect(agent='Python')

Context manager for HTTP Connection state and ensures proper handling of network sockets, sends a GET request.

Exception is raised at the yield statement.

Yield request:FileIO<Socket>
json

Serializes json text stream into python dictionary.

Return dict:json
reader

Reads raw text from the connection stream. Ensures proper exception handling.

Return bytes:request

Models

class kan.Book(*args, **kwargs)

Front end user model

Parameters:
  • title – str
  • author – str
  • max_results – int
  • start_index – int
  • language_code – str
  • fields – tuple

Front End

kan.main()

Main program entry point

kan.command_line()

Parses users command line arguments and returns the namespace containing parsed values.

Notes

Release History

0.0.2

  • Bug fixes and speed improvements. More compact interface
  • Book models update
  • Completed Backend API for Google Books
  • Added verbose flag

0.0.1

  • Bug Fixes
  • Improved loadtime by applying fieldstring parameter at url creation.
  • Added Subparser
  • Allow search using ISBN

0.0.0

  • Initial registration and release on pypi
  • Built command line parser
  • Basic Client Interface and Implementation for Google Books
  • Added support for optional search arguments

TODO:

__main__.py

  • Decouple Book interface and implementation

models.py

  • Handle display operations here rather than in main

structures.py

  • Simplify API call using filters

Indices and tables