Exemplo n.º 1
0
 def test_b(self):
     self.lob = LoB()
     assert len(self.lob.getPage(
         'asaskjkfsdf:2:2:2:33')) == self.lob.length_of_page, len(
             self.lob.getPage('asasrkrtjfsdf:2:2:2:33'))
     assert 'hello kitty' == self.lob.toText(
         int(self.lob.int2base(self.lob.stringToNumber('hello kitty'), 36),
             36))
Exemplo n.º 2
0
 def loadPages(self):
     address = self.str_key.split(':')
     hex_addr = address[0]
     wall = address[1]
     shelf = address[2]
     volume = address[3].zfill(2)
     key_str = hex_addr + ':' + wall + ':' + shelf + ':' + volume + ':'
     for i in range(0, LoB.number_of_page + 1):
         key = key_str + str(i)
         self.pages.append(LoB().getPage(key))
         print(key)
Exemplo n.º 3
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 20 16:10:42 2019

@author: lu
"""

from library_of_babel import LoB
import random
import string
import matplotlib.pyplot as plt
import numpy as np
lob = LoB()

keyword = "trash"
address = lob.search(keyword)
print address
page = lob.getPage(address)

index = page.find(keyword)
print page[index:index + len(keyword) + 10]

keyword = "garbage"
address = lob.search(keyword)
#print address
page = lob.getPage(address)
index = page.find(keyword)
#print page[index:index+len(keyword)+10]

babelString = ""
Exemplo n.º 4
0
 def printPage(self):
     return LoB().printPage(self.hex_addr + ':' + str(self.wall) + ':' +
                            str(self.shelf) + ':' + str(self.volume) + ':' +
                            str(self.page))
Exemplo n.º 5
0
 def setTitle(self):
     self.title = LoB.getTitle(self.str_key)
Exemplo n.º 6
0
def _runtitlesearch(args):
    search_str = LoB().text_prep(args.titlesearch)
    print(LoB().searchTitle(search_str))
Exemplo n.º 7
0
def _runonlysearch(args):
    search_str = LoB().text_prep(args.onlysearch)
    only_key_str = LoB().search(search_str.ljust(LoB().length_of_page))
    LoB().printPage(only_key_str)
Exemplo n.º 8
0
def _runsearch(args):
    search_str = LoB().text_prep(args.search)
    key_str = LoB().search(LoB().text_prep(search_str))
    LoB().printPage(key_str)
Exemplo n.º 9
0
def _runcheckout(args):
    LoB().printPage(args.checkout)
Exemplo n.º 10
0
 def test_a(self):
     self.lob = LoB()
     assert self.lob.stringToNumber('a') == 0, self.lob.stringToNumber('a')
     assert self.lob.stringToNumber('ba') == 29, self.lob.stringToNumber(
         'ba')
Exemplo n.º 11
0
class LoBTest(unittest.TestCase):
    def test_a(self):
        self.lob = LoB()
        assert self.lob.stringToNumber('a') == 0, self.lob.stringToNumber('a')
        assert self.lob.stringToNumber('ba') == 29, self.lob.stringToNumber(
            'ba')

    def test_b(self):
        self.lob = LoB()
        assert len(self.lob.getPage(
            'asaskjkfsdf:2:2:2:33')) == self.lob.length_of_page, len(
                self.lob.getPage('asasrkrtjfsdf:2:2:2:33'))
        assert 'hello kitty' == self.lob.toText(
            int(self.lob.int2base(self.lob.stringToNumber('hello kitty'), 36),
                36))

    def test_c(self):
        self.lob = LoB()
        assert self.lob.int2base(4, 36) == '4', self.lob.int2base(4, 36)
        assert self.lob.int2base(10, 36) == 'A', self.lob.int2base(10, 36)

    def test_d(self):
        self.lob = LoB()
        test_string = '.................................................'
        assert test_string in self.lob.getPage(self.lob.search(test_string))

    def test_e(self):
        self.lob = LoB()
        print('')
        self.lob.printPage('HELLO:0:0:0:0')
Exemplo n.º 12
0
 def test_e(self):
     self.lob = LoB()
     print('')
     self.lob.printPage('HELLO:0:0:0:0')
Exemplo n.º 13
0
 def test_d(self):
     self.lob = LoB()
     test_string = '.................................................'
     assert test_string in self.lob.getPage(self.lob.search(test_string))
Exemplo n.º 14
0
 def test_c(self):
     self.lob = LoB()
     assert self.lob.int2base(4, 36) == '4', self.lob.int2base(4, 36)
     assert self.lob.int2base(10, 36) == 'A', self.lob.int2base(10, 36)