module
comment "#!/usr/bin/env python"
comment "# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovi"...
import_statement
import "import"
dotted_name
identifier "json"
import_statement
import "import"
dotted_name
identifier "os"
import_statement
import "import"
dotted_name
identifier "sys"
import_from_statement
from "from"
dotted_name
identifier "textwrap"
import "import"
dotted_name
identifier "TextWrapper"
import_from_statement
from "from"
dotted_name
identifier "calibre"
. "."
identifier "db"
. "."
identifier "cli"
. "."
identifier "utils"
import "import"
dotted_name
identifier "str_width"
import_from_statement
from "from"
dotted_name
identifier "calibre"
. "."
identifier "ebooks"
. "."
identifier "metadata"
import "import"
dotted_name
identifier "authors_to_string"
import_from_statement
from "from"
dotted_name
identifier "calibre"
. "."
identifier "utils"
. "."
identifier "date"
import "import"
dotted_name
identifier "isoformat"
import_from_statement
from "from"
dotted_name
identifier "polyglot"
. "."
identifier "builtins"
import "import"
dotted_name
identifier "as_bytes"
expression_statement
assignment
identifier "readonly"
= "="
true "True"
expression_statement
assignment
identifier "version"
= "="
integer "0"
comment "# change this if you change signature of implementation()"
expression_statement (+106 nodes collapsed)
function_definition (+71 nodes collapsed)
function_definition (+27 nodes collapsed)
function_definition
def "def"
identifier "implementation"
parameters (+21 nodes collapsed)
: ":"
block
expression_statement
assignment
identifier "is_remote"
= "="
comparison_operator
identifier "notify_changes"
is not
is "is"
not "not"
none "None"
if_statement
if "if"
identifier "is_remote"
: ":"
comment "# templates allow arbitrary code execution via python templa"...
comment "# could possibly disallow only python templates but that is "...
comment "# than I feel like doing for this, so simply ignore template"...
comment "# connections."
block
expression_statement
assignment
identifier "template"
= "="
none "None"
expression_statement
assignment
identifier "formatter"
= "="
none "None"
with_statement
with "with"
with_clause
with_item
attribute
identifier "db"
. "."
identifier "safe_read_lock"
: ":"
block
expression_statement
assignment
identifier "fm"
= "="
attribute
identifier "db"
. "."
identifier "field_metadata"
expression_statement
assignment
identifier "afields"
= "="
binary_operator
call
identifier "set"
argument_list
( "("
identifier "FIELDS"
) ")"
| "|"
set
{ "{"
string
string_start "'"
string_content "id"
string_end "'"
} "}"
for_statement (+36 nodes collapsed)
if_statement (+38 nodes collapsed)
expression_statement
assignment
identifier "sort_by"
= "="
boolean_operator
identifier "sort_by"
or "or"
string
string_start "'"
string_content "id"
string_end "'"
expression_statement
assignment
identifier "sort_fields"
= "="
call
attribute
identifier "sort_by"
. "."
identifier "split"
argument_list
( "("
string
string_start "'"
string_content ","
string_end "'"
) ")"
for_statement (+27 nodes collapsed)
expression_statement (+51 nodes collapsed)
if_statement (+53 nodes collapsed)
if_statement
if "if"
identifier "search_text"
: ":"
block
expression_statement
assignment
identifier "book_ids"
= "="
call
attribute
identifier "db"
. "."
identifier "multisort"
argument_list
( "("
identifier "sort_spec"
, ","
keyword_argument
identifier "ids_to_sort"
= "="
call
attribute
identifier "db"
. "."
identifier "search"
argument_list
( "("
identifier "search_text"
) ")"
) ")"
else_clause
else "else"
: ":"
block
expression_statement
assignment
identifier "book_ids"
= "="
call
attribute
identifier "db"
. "."
identifier "multisort"
argument_list
( "("
identifier "sort_spec"
) ")"
if_statement (+21 nodes collapsed)
expression_statement
assignment
identifier "data"
= "="
dictionary
{ "{"
} "}"
expression_statement
assignment
identifier "metadata"
= "="
dictionary
{ "{"
} "}"
for_statement (+423 nodes collapsed)
return_statement (+36 nodes collapsed)
function_definition (+379 nodes collapsed)
function_definition (+103 nodes collapsed)
function_definition (+157 nodes collapsed)
function_definition (+1142 nodes collapsed)
function_definition (+620 nodes collapsed)
function_definition (+176 nodes collapsed)