In [1]:
from gitenberg.util import tenprintcover

title = "Computational and Inferential Thinking"
subtitle = 'The Foundations of Data Science'
author = "Ani Adhikari and John DeNero"
try:
    cover_image = tenprintcover.draw(title, subtitle, author)
except OSError:
    print "OSError, probably Cairo not installed."
filename = '/Documents/gitenberg/tencover.png'
try:
    with open(filename, "wb") as f:
        cover_image.save(f)
except FileNotFoundError:
    print("Error opening target file " + filename)

In [3]:
import csv
import re
from gitenberg.util.catalog import repo_for_pgid
from gitenberg.util import tenprintcover
from gitenberg.metadata.pandata import Pandata
                
with open('/Documents/gitenberg/worksfromgit.txt','r') as f:
    for vals in csv.reader(f,dialect=csv.excel_tab):
        pg_id = int(vals[0])
        ed_id = int(vals[1])
        cover = vals[2]
        repo = repo_for_pgid[pg_id]
        #pandata = Pandata('https://github.com/GITenberg/{}/raw/master/metadata.yaml'.format(repo))
        pandata = Pandata('/Documents/gitenberg/library/The-Lane-That-Had-No-Turning-Volume-1_6237/metadata.yaml')
        #print pandata.covers
        print pandata.metadata['title']
        try:
            #print u'{}\t{}\t{}'.format(pandata.title_no_subtitle, pandata.subtitle, pandata.authors_short))
            cover_image = tenprintcover.draw(pandata.title_no_subtitle, pandata.subtitle, pandata.authors_short())
        except OSError:
            print "OSError, probably Cairo not installed."
        #filename = '/Users/eric/github/local/{}/cover{}.png'.format(pandata._repo, pg_id)
        filename = '/Documents/gitenberg/10print/cover{}.png'.format( pg_id)
        try:
            with open(filename, "wb") as f:
                cover_image.save(f)
        except IOError:
            print("Error opening target file " + filename)
        #mdfilename = '/Users/eric/github/local/{}/metadata.yaml'.format(pandata._repo)
        #mdfilename = '/Documents/gitenberg/metadata{}.yaml'.format(pandata._repo)
        #pandata.metadata['covers']=[{"image_path": "cover.png", "cover_type":"generated"}]
        #pandata.dump_file(mdfilename)
        if pg_id > 200:
            break


The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1
The Lane That Had No Turning, Volume 1

In [1]:
split_title('Robbery under Arms\
A Story of Life and Adventure in the Bush and in the Australian Goldfields')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-6a7bf76d73ec> in <module>()
----> 1 split_title('Robbery under ArmsA Story of Life and Adventure in the Bush and in the Australian Goldfields')

NameError: name 'split_title' is not defined

In [15]:
from gitenberg.travis import repo_metadata
repo_metadata()


Out[15]:
{'author': 'Parker, Gilbert',
 'author_for_calibre': 'Parker, Gilbert',
 'cover': 'cover.png',
 'repo_name': 'At-the-Sign-of-the-Eagle_6218',
 'title': 'At the Sign of the Eagle',
 'version': '0.1.1'}

In [12]:
import cairocffi as cairo
from gitenberg.util import tenprintcover
test = tenprintcover.Image(100,100)
(font) = 'Noto Sans CJK SC', (10,cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
test.text('text', 20, 10, 50, 10, tenprintcover.Image.colorRGB(50, 50, 50), font)
test.


<gitenberg.util.tenprintcover.Image object at 0x10b45df10>

In [5]:
import unicodedata
for char in u'粉妝樓41-50回':
    print ord(char) >= 0x4E00


True
True
True
False
False
False
False
False
True

In [2]:
import re
from gitenberg.util.catalog import get_repo_name

print get_repo_name('51118')


51118

In [24]:
from gitenberg.local_repo import LocalRepo
lr = LocalRepo('/Documents/gitenberg/library/51118')
lr.git.__dict__


Out[24]:
{'_bare': False,
 '_working_tree_dir': '/Documents/gitenberg/library/51118',
 'git': <git.cmd.Git at 0x10b350d50>,
 'git_dir': '/Documents/gitenberg/library/51118/.git',
 'odb': <git.db.GitCmdObjectDB at 0x10b386d50>,
 'working_dir': '/Documents/gitenberg/library/51118'}

In [23]:
import os
img_exts = ('jpg', 'jpeg', 'png', 'gif')

covers = []
repo_path = '/Documents/gitenberg/library/51118'
for root, dirs, files in os.walk(repo_path):
    files = [f for f in files if not f[0] == '.']
    dirs[:] = [d for d in dirs if not d[0] == '.']
    covers = covers + [os.path.join(root,f)[len(repo_path)+1:] for f in files if (
                'cover' in f and f.lower().split('.')[-1] in img_exts
            )]
print covers


['51118-h/images/cover.jpg']

In [14]:
import semver
semver.bump_patch('1')


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-03c6d939bb21> in <module>()
      1 import semver
----> 2 semver.bump_patch('1')

/Users/eric/.virtualenvs/igitberg/lib/python2.7/site-packages/semver.pyc in bump_patch(version)
    118 
    119 def bump_patch(version):
--> 120     verinfo = parse(version)
    121     return format_version(verinfo['major'], verinfo['minor'], verinfo['patch'] + 1)

/Users/eric/.virtualenvs/igitberg/lib/python2.7/site-packages/semver.pyc in parse(version)
     19     match = _REGEX.match(version)
     20     if match is None:
---> 21         raise ValueError('%s is not valid SemVer string' % version)
     22 
     23     verinfo = match.groupdict()

ValueError: 1 is not valid SemVer string

In [ ]: