bookish package¶
Subpackages¶
Submodules¶
bookish.coloring module¶
-
class
bookish.coloring.
Ansi
¶ Bases:
object
-
black
= '\x1b[30m'¶
-
black_back
= '\x1b[40m'¶
-
blue
= '\x1b[34m'¶
-
blue_back
= '\x1b[44m'¶
-
bright
= '\x1b[1m'¶
-
cyan
= '\x1b[36m'¶
-
cyan_back
= '\x1b[46m'¶
-
dim
= '\x1b[2m'¶
-
green
= '\x1b[32m'¶
-
green_back
= '\x1b[42m'¶
-
magenta
= '\x1b[35m'¶
-
magenta_back
= '\x1b[45m'¶
-
normal
= '\x1b[22m'¶
-
red
= '\x1b[31m'¶
-
red_back
= '\x1b[41m'¶
-
reset
= '\x1b[39m'¶
-
reset_all
= '\x1b[0m'¶
-
reset_back
= '\x1b[49m'¶
-
white
= '\x1b[37m'¶
-
white_back
= '\x1b[47m'¶
-
yellow
= '\x1b[33m'¶
-
yellow_back
= '\x1b[43m'¶
-
-
class
bookish.coloring.
CustomHtmlFormatter
(hl_lines=None)¶ Bases:
pygments.formatters.html.HtmlFormatter
-
wrap
(source, outfile)¶ Wrap the
source
, which is a generator yielding individual lines, in custom generators. See docstring for format. Can be overridden.
-
-
bookish.coloring.
code_chars
(code)¶
-
bookish.coloring.
cstring
(code, string)¶
-
bookish.coloring.
format_block
(block, lexername=None, lexer=None, pre=False)¶
-
bookish.coloring.
format_string
(source, lexername=None, lexer=None, look='', hl_lines=None, pre=False)¶
-
bookish.coloring.
lexer_for
(name)¶
bookish.compat module¶
-
bookish.compat.
array_frombytes
(arry, bs)¶
-
bookish.compat.
array_tobytes
(arry)¶
-
bookish.compat.
b
(s)¶
-
bookish.compat.
byte
(num)¶
-
bookish.compat.
config_get
(config, section, name, fallback=None)¶
-
bookish.compat.
config_getboolean
(config, section, name, fallback=False)¶
-
bookish.compat.
config_getint
(config, section, name, fallback=0)¶
-
bookish.compat.
htmlescape
(s, quote=True)¶
-
bookish.compat.
indent
(text, prefix, predicate=None)¶ Adds ‘prefix’ to the beginning of selected lines in ‘text’.
If ‘predicate’ is provided, ‘prefix’ will only be added to the lines where ‘predicate(line)’ is True. If ‘predicate’ is not provided, it will default to adding ‘prefix’ to all non-empty lines that do not consist solely of whitespace characters.
-
bookish.compat.
iteritems
(o)¶
-
bookish.compat.
iterkeys
(o)¶
-
bookish.compat.
itervalues
(o)¶
-
bookish.compat.
memoryview_
(source, offset=None, length=None)¶
-
bookish.compat.
next
(o)¶
-
bookish.compat.
u
(s)¶
-
bookish.compat.
with_metaclass
(meta, base=<type 'object'>)¶
bookish.config module¶
-
class
bookish.config.
DefaultConfig
¶ Bases:
object
-
AUTOSAVE
= True¶
-
AUTOSAVE_SECONDS
= 10¶
-
BACKGROUND_INDEXING_INTERVAL
= 60¶
-
CACHE_DIR
= './cache'¶
-
CATEGORIES
= ''¶
-
CHECKPOINT_MAX
= 10¶
-
DEBUG
= False¶
-
DEFAULT_LANGUAGE
= 'en'¶
-
DEFAULT_LOCALE
= 'en_US'¶
-
DOCUMENTS
= []¶
-
EDITABLE
= False¶
-
EDIT_STORE
= None¶
-
ENABLE_BACKGROUND_INDEXING
= False¶
-
EXTRA_DOCUMENTS
= []¶
-
ICON_144
= '/images/logos/logo_144.png'¶
-
ICON_32
= '/images/logos/logo_32.png'¶
-
INDEX_DIR
= './index'¶
-
INDEX_PAGE_NAME
= 'index'¶
-
PAGES_CLASS
= 'wikipages.WikiPages'¶
-
PYGMENTS_CSS
= '/static/css/pygments/brightcolor.css'¶
-
SCSS_ASSET_DIR
= '/static/scss/'¶
-
SEARCHABLES
¶ Used by autodoc_mock_imports.
-
SEARCH_SHORTCUTS
= []¶
-
SEARCH_TEMPLATE
= '/templates/results.jinja2'¶
-
SECRET_KEY
= 'dummy'¶
-
SUPPORT_DOCUMENTS
= [{'source': 'C:\\Program Files\\Side Effects Software\\Houdini 17.0.439\\houdini\\python2.7libs\\bookish\\templates', 'type': 'mount', 'target': '/templates'}, {'source': 'C:\\Program Files\\Side Effects Software\\Houdini 17.0.439\\houdini\\python2.7libs\\bookish\\grammars', 'type': 'mount', 'target': '/grammars'}, {'source': 'C:\\Program Files\\Side Effects Software\\Houdini 17.0.439\\houdini\\python2.7libs\\bookish\\static', 'static': True, 'type': 'mount', 'target': '/static'}]¶
-
TEMPLATE
= '/templates/page.jinja2'¶
-
TEXTIFY_CLASS
¶ alias of
bookish.text.textify.TextifierBase
-
WIKI_EXT
= '.txt'¶
-
WIKI_STYLE
= '/templates/wiki.jinja2'¶
-
-
class
bookish.config.
TestConfig
¶ Bases:
bookish.config.DefaultConfig
-
DEBUG
= True¶
-
-
bookish.config.
expandpath
(path)¶
bookish.flaskapp module¶
-
exception
bookish.flaskapp.
NotModified
(description=None, response=None)¶ Bases:
werkzeug.exceptions.HTTPException
An HTTP “304 Not Modified” response.
-
code
= 304¶
-
get_response
(environment)¶ Get a response object. If one was passed to the exception it’s returned directly.
Parameters: environ – the optional environ for the request. This can be used to modify the response depending on how the request looked like. Returns: a Response
object or a subclass thereof.
-
-
bookish.flaskapp.
after_request
(response)¶
-
bookish.flaskapp.
before_request
()¶
-
bookish.flaskapp.
debug_search
(path)¶
-
bookish.flaskapp.
debug_textify
(path)¶
-
bookish.flaskapp.
debug_tooltip
(path)¶
-
bookish.flaskapp.
debug_wiki_structure
(path)¶
-
bookish.flaskapp.
delete_wiki
()¶
-
bookish.flaskapp.
directory_list
(pages, dirpath)¶
-
bookish.flaskapp.
directory_page
(pages, dirpath)¶ Renders a simple template to show the files in a directory.
-
bookish.flaskapp.
edit_wiki
(path)¶
-
bookish.flaskapp.
field_contents
(name)¶
-
bookish.flaskapp.
format_code
(source, lexername=None, pre=False)¶
-
bookish.flaskapp.
get_indexer
(app=None)¶
-
bookish.flaskapp.
get_request_language
(pages, path)¶ Get the human language from a flask request
-
bookish.flaskapp.
get_request_userid
()¶
-
bookish.flaskapp.
get_store
(app=None)¶
-
bookish.flaskapp.
get_textifier
()¶
-
bookish.flaskapp.
get_wikipages
(app=None)¶
-
bookish.flaskapp.
icon_list
()¶
-
bookish.flaskapp.
internal_error
(exception)¶
-
bookish.flaskapp.
is_unconditional
()¶ Returns True if the given flask request is unconditional (that is, cannot be served from a cache).
-
bookish.flaskapp.
list_checkpoints
()¶
-
bookish.flaskapp.
list_dir
()¶
-
bookish.flaskapp.
list_wiki_forms
()¶
-
bookish.flaskapp.
load_checkpoint
()¶
-
bookish.flaskapp.
load_example
()¶
-
bookish.flaskapp.
load_wiki
()¶
-
bookish.flaskapp.
move_wiki
()¶
-
bookish.flaskapp.
new_dir
()¶
-
bookish.flaskapp.
null_rel
(x)¶
-
bookish.flaskapp.
page_not_found
(exception)¶
-
bookish.flaskapp.
preview_wiki
()¶
-
bookish.flaskapp.
save_wiki
()¶
-
bookish.flaskapp.
search_page
()¶
-
bookish.flaskapp.
send_file_partial
(path, conditional)¶ Simple wrapper around send_file which handles HTTP 206 Partial Content (byte ranges) TODO: handle all send_file args, mirror send_file’s error handling (if it has any)
-
bookish.flaskapp.
show
(path)¶
-
bookish.flaskapp.
tag_page
(tag)¶
-
bookish.flaskapp.
teardown
(exception)¶
-
bookish.flaskapp.
toc_page
(path)¶
-
bookish.flaskapp.
update_index
()¶
bookish.flasksupport module¶
-
class
bookish.flasksupport.
BgIndex
(app)¶ Bases:
object
-
do_reindex
()¶
-
reindex
()¶
-
schedule_next
()¶
-
start_indexer
()¶
-
stop_indexing
()¶
-
-
class
bookish.flasksupport.
Scss
(app)¶ Bases:
object
-
compile_scss
(path)¶
-
find_scss
(partials=False)¶
-
import_hook
(path)¶
-
out_of_date
(path)¶
-
output_path
(path)¶
-
partials_have_changed
()¶
-
recompile_all
()¶
-
set_hooks
()¶
-
update_scss
()¶
-
-
bookish.flasksupport.
setup
(app)¶
-
bookish.flasksupport.
setup_config
(app, config_obj=None, config_file=None)¶
-
bookish.flasksupport.
setup_logging
(app)¶
-
bookish.flasksupport.
setup_template_globals
(app)¶
-
bookish.flasksupport.
setup_template_loader
(app)¶
bookish.functions module¶
-
class
bookish.functions.
Missing
¶ Bases:
object
-
bookish.functions.
attr
(block, name, default=None)¶
-
bookish.functions.
block_id
(block)¶
-
bookish.functions.
build_toc
(docroot, basepath=None, block=None, i=0, depth=0, maxdepth=99)¶
-
bookish.functions.
collapse
(body, types=())¶
-
bookish.functions.
engroup
(blocks)¶
-
bookish.functions.
find_all_breadth
(obj, with_text=False)¶
-
bookish.functions.
find_all_depth
(obj)¶
-
bookish.functions.
find_by_attr
(top, name, value)¶
-
bookish.functions.
find_by_type
(top, typename)¶
-
bookish.functions.
find_headings
(block, depth=1, types=('h', 'section'))¶
-
bookish.functions.
find_id
(top, value)¶
-
bookish.functions.
find_items
(block, itemtype='item')¶
-
bookish.functions.
find_links
(block)¶
-
bookish.functions.
find_spans_of_type
(text, typename)¶
-
bookish.functions.
find_title
(block)¶
-
bookish.functions.
find_with_attr
(top, name)¶
-
bookish.functions.
first
(obj)¶
-
bookish.functions.
first_by_attr
(top, name, value)¶
-
bookish.functions.
first_of_type
(top, typename)¶
-
bookish.functions.
first_span_of_type
(text, typename)¶
-
bookish.functions.
first_subblock_of_type
(body, typename)¶
-
bookish.functions.
first_subblock_string
(block)¶
-
bookish.functions.
first_subblock_text
(block)¶
-
bookish.functions.
has_option
(s, key)¶
-
bookish.functions.
icon_ref
(val)¶
-
bookish.functions.
last
(obj)¶
-
bookish.functions.
next_table_cell
(block)¶
-
bookish.functions.
random_id
()¶
-
bookish.functions.
random_name
(length=5)¶
-
bookish.functions.
remove_subblocks
(body, exclude)¶
-
bookish.functions.
retain_subblocks
(body, include)¶
-
bookish.functions.
slugify
(text, lower=True)¶
-
bookish.functions.
sort
(obj, key=None)¶
-
bookish.functions.
string
(obj, before=None, after=None)¶ Converts the kinds of things you might get in a template to unicode. If it’s a string, returns the string. If it’s a list, recursively calls string() on the contents and joins them. If it’s a dictionary with a “text” key, calls string() on that. Otherwise, returns str(obj).
-
bookish.functions.
subblock_by_id
(body, idstring)¶
-
bookish.functions.
subblocks_of_type
(body, typename)¶
-
bookish.functions.
subblocks_summary
(block)¶
-
bookish.functions.
text_replace
(text, target, replacement)¶
-
bookish.functions.
thing
(x)¶
-
bookish.functions.
topattr
(block, name, default=None)¶
bookish.i18n module¶
-
bookish.i18n.
is_language_supported
(language, supported_languages)¶
-
bookish.i18n.
language_detection
()¶ Select the right language
- CookieLanguageMiddleware : Look at the cookie if exists
- HttpAcceptLanguageMiddleware : Look at the browser language settings
- DefaultLanguageMiddleware : Come back to english
-
bookish.i18n.
normalize_language_name
(language)¶ Attempts to normalize language names (e.g.
en_us
,en-US
, etc.) to a lowercase, hyphenated form (en-us
).
-
bookish.i18n.
parse_accept_lang_header
(lang_string)¶ Parses the lang_string, which is the body of an HTTP Accept-Language header, and returns a list of (lang, q-value), ordered by ‘q’ values.
Any format errors in lang_string results in an empty list being returned.
-
bookish.i18n.
parse_http_accept_language
(header_string, available_langs)¶
bookish.paths module¶
-
bookish.paths.
barename
(path)¶ Returns the base name of the file named by the path, with any extension removed. If the resource is a directory, the base name is the empty string (“”).
>>> basename("/a/b.txt") "b" >>> basename("/a/b") "b" >>> basename("/a/b/") ""
-
bookish.paths.
basename
(path)¶ Returns the base name of the file named by the path. If the resource is a directory, the base name is the empty string (“”).
>>> basename("/a/b") "b" >>> basename("/a/b/") ""
-
bookish.paths.
basepath
(path)¶ Removes the extension from the end of a path.
-
bookish.paths.
directory
(path)¶ If the given path is a directory resource (ends with a slash), this returns the path unchanged. If it’s a file resource, returns the path of the file’s parent directory.
>>> parent("/a/b/") "/a/b/" >>> parent("/a/b") "/a/"
-
bookish.paths.
extension
(path)¶ Returns the “extension” part of the base name of a resource path.
>>> extension("/a/b/foo.bar") "bar" >>> extension("/a/b/foo") "" >>> extension("/a/b/foo.") ""
-
bookish.paths.
is_abs
(path)¶
-
bookish.paths.
join
(basepath, relpath)¶ Joins two path strings intelligently. If the first path specifies a file, the second path will be joined to the first path’s directory.
>>> join("/a/b", "c") "/a/b/c" >>> join("/a/b/c", "d") "/a/b/d" >>> join("/a/b/c/", "../d") "/a/b/d"
-
bookish.paths.
norm_parts
(path, out=None)¶ Returns a list of the normalized parts of the given path string. This means that special names such as “.” and “..” are applied, and multiple adjacent slashes are replaced with a single slash.
>>> norm_parts("/a/b//c/../d") ["/", "a/", "b/", "d"]
-
bookish.paths.
normalize
(path)¶ Returns a normalized version of the given path string. This means that special names such as “.” and “..” are applied, and multiple adjacent slashes are replaced with a single slash.
>>> normalize("/a/b//c/../d") "/a/b/d"
-
bookish.paths.
normalize_abs
(path)¶ Like normalize() but raises an error if the given path is not absolute.
-
bookish.paths.
parent
(path)¶ Returns the parent directory path of the given resource.
>>> parent("/a/b/c") "/a/" >>> parent("/a/b/") "/a/" >>> parent("/") "/"
-
bookish.paths.
parts
(path)¶ Yields the parts of the given path string:
>>> list(parts("/a/b/c"))
[“/”, “a/”, “b/”, “c”]
-
bookish.paths.
relativize
(basepath, targetpath)¶ Returns a relative path from the “base” resource to the “target” resource.
>>> relativize("/a/b", "c") "c" >>> relativize("/a/b/c", "/a/b/d/e") "d/e" >>> relativize("/a/b/c", "/d/e/f") "../../d/e/f"
-
bookish.paths.
split_dirpath
(path)¶ Returns the parent path and the file name of a resource path.
>>> split_dirpath("/a/b/foo.bar") ("/a/b/", "foo.bar")
-
bookish.paths.
split_extension
(path)¶ Returns the base part and the extension part of the base name of a resource path.
>>> split_extension("/a/b/foo.bar") ("foo", "bar")
-
bookish.paths.
split_fragment
(path)¶ Returns the path and the fragment of a path/fragment combo.
>>> split_fragment("/a/b/foo#bar") ("/a/b/foo", "#bar")
-
bookish.paths.
split_path_parts
(path)¶ Returns a list of the names in the path.
>>> split_path_parts("/a/b/c") ["a", "b", "c"]
-
bookish.paths.
strip_extension
(name)¶ Removes any extension from the given string.
bookish.search module¶
Used by autodoc_mock_imports.
bookish.stores module¶
-
class
bookish.stores.
CommonLang
(child)¶ Bases:
bookish.stores.WrappingStore
Projects root directories into all languages.
-
class
bookish.stores.
DictionaryStore
(dictionary, writable=False, config=None)¶ Bases:
bookish.stores.Store
Presents a dictionary mapping path strings to bytes objects as a page store.
Supports the
list_all(path)
method but does not support directories (list_dir
always returns[]
andis_dir
always returns False).Does not support last modified times (
last_modified
always returns 0).-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
make_dir
(path, create_intermediate=False)¶ Creates a new directory at the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
writable
(path)¶ Returns True if the given path can be created/overwritten.
-
write_file
(path, bytestring)¶
-
-
class
bookish.stores.
FileStore
(dirpath, config=None)¶ Bases:
bookish.stores.Store
Represents a directory in the filesystem.
-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
file_path
(path)¶ Returns the filesystem equivalent of the given virtual path, if it has one, otherwise None.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_dir
(path)¶ Lists the file names under the given path.
-
make_dir
(path, create_intermediate=False)¶ Creates a new directory at the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
writable
(path)¶ Returns True if the given path can be created/overwritten.
-
-
class
bookish.stores.
HideStore
(child)¶ Bases:
bookish.stores.WrappingStore
Calls a function to check whether a given file exists. If the function returns True, the file is retrieved from the wrapped store.
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
exists
(path)¶ Returns True if the given path exists in this store.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
list_all
(path='/')¶
-
-
class
bookish.stores.
MountStore
(child, prefix)¶ Bases:
bookish.stores.WrappingStore
Mounts a child store at a “sub-directory”, for use in an OverlayStore.
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
exists
(path)¶ Returns True if the given path exists in this store.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
-
class
bookish.stores.
OverlayStore
(*stores)¶ Bases:
bookish.stores.Store
Overlays the contents of a number of sub-stores. When the methods are called with a path, this store tries its sub-stores in order, and fulfills the request using the first sub-store found that contains the path.
-
append
(store)¶
-
close
()¶
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
extend
(stores)¶
-
file_path
(path)¶ Returns the filesystem equivalent of the given virtual path, if it has one, otherwise None.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
make_dir
(path, create_intermediate=False)¶ Creates a new directory at the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
set_config
(config)¶
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
store_for
(path)¶
-
writable
(path)¶ Returns True if the given path can be created/overwritten.
-
write_file
(path, bytestring)¶
-
-
exception
bookish.stores.
ResourceNotFoundError
¶ Bases:
exceptions.Exception
-
class
bookish.stores.
Store
(config=None)¶ Bases:
object
Base class for page storage objects.
-
close
()¶
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
file_path
(path)¶ Returns the filesystem equivalent of the given virtual path, if it has one, otherwise None.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
make_dir
(path, create_intermediate=False)¶ Creates a new directory at the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
set_config
(config)¶
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
store_for
(path)¶
-
writable
(path)¶ Returns True if the given path can be created/overwritten.
-
write_file
(path, bytestring)¶
-
-
class
bookish.stores.
StringStore
(config=None)¶ Bases:
bookish.stores.Store
Base class for stores that more naturally return generate strings than file-like objects
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
delete
(path)¶ Deletes the underlying file for the given path.
-
exists
(path)¶ Returns True if the given path exists in this store.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
-
class
bookish.stores.
SubStore
(child, prefix)¶ Bases:
bookish.stores.WrappingStore
“Extracts” a “sub-directory” of a child store and presents it as a top-level store.
-
class
bookish.stores.
WrappingStore
(child)¶ Bases:
bookish.stores.Store
Base class for PageStore implementations that wrap “child” stores.
-
close
()¶
-
config
¶
-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
file_path
(path)¶ Returns the filesystem equivalent of the given virtual path, if it has one, otherwise None.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
make_dir
(path, create_intermediate=False)¶ Creates a new directory at the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
set_config
(config)¶
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
writable
(path)¶ Returns True if the given path can be created/overwritten.
-
-
class
bookish.stores.
ZipStore
(zipfilepath, config=None)¶ Bases:
bookish.stores.Store
Represents the files inside a zip archive.
-
close
()¶
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='r')¶ Returns a file-like object for reading the given path.
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
zipinfo
(path)¶
-
static
zipname
(path)¶
-
-
class
bookish.stores.
ZipTree
(dirpath, config=None)¶ Bases:
bookish.stores.Store
Looks for a zip file corresponding to the first part of a path, and if it finds one, looks inside that zip file for the rest of the path. This essentially makes zip files at the root level look like directories.
-
close
()¶
-
content
(path, encoding='utf8')¶ Convenience method to return the string content of the file at the given path.
Parameters: encoding – the name of the encoding to use to decode the file’s bytes. Default is
"utf8"
. If you useencoding=None
themethod returns the raw bytestring.
-
delete
(path)¶ Deletes the underlying file for the given path.
-
etag
(path)¶
-
exists
(path)¶ Returns True if the given path exists in this store.
-
is_dir
(path)¶ Returns True if the given path represents a directory in this store.
-
last_modified
(path)¶ Returns a datetime object
-
list_all
(path='/')¶
-
list_dir
(path)¶ Lists the file names under the given path.
-
move
(path, newpath)¶ Moves the underlying file to the new path.
-
open
(path, mode='rb')¶ Returns a file-like object for reading the given path.
-
size
(path)¶ Returns the size (in bytes) of the file at the given path.
-
-
bookish.stores.
expandpath
(path)¶
-
bookish.stores.
file_etag
(fpath)¶
-
bookish.stores.
store_from_spec
(spec)¶
-
bookish.stores.
utc_offset
()¶
bookish.testing module¶
-
bookish.testing.
find_missing
(pages, images=True, links=True, prefix='/', callback=None)¶
bookish.util module¶
-
class
bookish.util.
Context
(m=None, parent=None)¶ Bases:
object
-
first
()¶
-
get
(key, default=None)¶
-
has_keys
()¶
-
items
(seen=None)¶
-
keys
()¶
-
push
(m=None)¶
-
top
()¶
-
update
(m)¶
-
values
()¶
-
-
class
bookish.util.
DbLruCache
(maxsize=100)¶ Bases:
object
Double-barrel least-recently-used cache decorator. This is a simple LRU algorithm that keeps a primary and secondary dict. Keys are checked in the primary dict, and then the secondary. Once the primary dict fills up, the secondary dict is cleared and the two dicts are swapped.
Keys must be hashable.
-
get
(key)¶
-
put
(key, value)¶
-
-
class
bookish.util.
TempDB
¶ Bases:
object
-
class
bookish.util.
TempDir
¶ Bases:
object
-
bookish.util.
builtin_grammar
(name)¶
-
bookish.util.
class_from_name
(name, namespace=None, classdict=None)¶
-
bookish.util.
decode_named_entity
(name)¶
-
bookish.util.
dump_tree
(block, stream=None, tab=0)¶
-
bookish.util.
dumps_tree
(block)¶
-
bookish.util.
file_paths
(dirpath, include=None, exclude=None, callback=None)¶
-
bookish.util.
find_object
(name, blacklist=None, whitelist=None)¶ Imports and returns an object given a fully qualified name.
>>> find_object("whoosh.analysis.StopFilter") <class 'whoosh.analysis.StopFilter'>
-
bookish.util.
flatten_text
(obj)¶ Returns a string containing just the string values from the given “text” list. The function recursively descends into “text” keys found on non-string spans in the list.
-
bookish.util.
get_prefixed_paths
(pages, prefix)¶
-
bookish.util.
join_text
(text)¶ Joins adjacent strings in a “text” list together. This function recursively descends into “text” keys found on non-string spans in the list.
-
bookish.util.
json_file
(filename)¶
-
bookish.util.
make_id
(name)¶
-
bookish.util.
make_rel_fn
(basepath, index_page_name)¶
-
bookish.util.
memoize
(f)¶
-
bookish.util.
normalize_text
(tx)¶
-
bookish.util.
normalize_ws
(s)¶
-
bookish.util.
object_from_item
(config, section, option, cls=None, namespace=None, classdict=None)¶
-
bookish.util.
objects_from_items
(items, namespace=None, classdict=None)¶
-
bookish.util.
pyliteral
(value, fallback_to_string=False)¶
-
bookish.util.
random_id
(length=10)¶
-
bookish.util.
timing
(*args, **kwds)¶