Skip to content

Graph Config

Logseq Graph Class.

Classes:

Name Description
ConfigEdns

Configuration EDN files for the Logseq analyzer.

LogseqConfigEDN

A simple EDN parser that converts EDN data into Python data structures.

Functions:

Name Description
loads

Parse an EDN-formatted string and return the corresponding Python data structure.

tokenize

Yield EDN tokens, skipping comments, whitespace, and commas.

get_edn_from_file

Initialize the LogseqGraphConfig from a file.

get_default_logseq_config

Get the default Logseq configuration.

get_target_dirs

Get the target directories for Logseq.

get_ns_sep

Get the namespace separator based on the configuration.

get_page_title_format

Get the page title format from the configuration.

get_file_name_format

Get the file name format from the configuration.

get_prop_pages_enabled

Check if property pages are enabled in the configuration.

ConfigEdns(config: dict[str, Any] = dict(), default_edn: dict[str, Any] = dict(), user_edn: dict[str, Any] = dict(), global_edn: dict[str, Any] = dict()) dataclass

Configuration EDN files for the Logseq analyzer.

Attributes:

Name Type Description
report dict[ConfigEdnReport, Any]

Generate a report of the configuration EDN files.

report: dict[ConfigEdnReport, Any] property

Generate a report of the configuration EDN files.

LogseqConfigEDN(tokens_gen: InitVar[Generator[str, Any]], tokens: list[str] = list(), tok_map: dict[str, Any] = dict(), pos: int = 0) dataclass

A simple EDN parser that converts EDN data into Python data structures.

Methods:

Name Description
__post_init__

Initialize the token map for parsing EDN structures.

peek

Return the next token without advancing the position.

next

Return the next token and advance the position.

parse

Parse the entire EDN input and return the resulting Python object.

parse_value

Parse a single EDN value.

parse_map

Parse a map (dictionary) from EDN.

parse_vector

Parse a vector (list) from EDN.

parse_list

Parse a list from EDN.

parse_set

Parse a set from EDN.

parse_string

Parse a string from EDN.

parse_literal

Parse a literal value from EDN.

is_number

Check if the token is a valid number (integer or float).

parse_number

Parse a number (integer or float) from EDN.

parse_keyword

Parse a keyword from EDN.

parse_symbol

Parse a symbol from EDN.

__post_init__(tokens_gen: Generator[str, Any]) -> None

Initialize the token map for parsing EDN structures.

peek() -> EDNToken | None

Return the next token without advancing the position.

next() -> EDNToken | None

Return the next token and advance the position.

parse() -> EDNToken

Parse the entire EDN input and return the resulting Python object.

parse_value() -> EDNToken

Parse a single EDN value.

parse_map() -> dict

Parse a map (dictionary) from EDN.

parse_vector() -> list

Parse a vector (list) from EDN.

parse_list() -> list

Parse a list from EDN.

parse_set() -> set

Parse a set from EDN.

parse_string() -> EDNToken

Parse a string from EDN.

parse_literal() -> None | bool

Parse a literal value from EDN.

is_number(tok: Any, number_regex: re.Pattern = NUMBER_REGEX) -> bool

Check if the token is a valid number (integer or float).

parse_number() -> float | int

Parse a number (integer or float) from EDN.

parse_keyword() -> EDNToken | None

Parse a keyword from EDN.

parse_symbol() -> EDNToken | None

Parse a symbol from EDN.

loads(edn_str: str) -> EDNToken

Parse an EDN-formatted string and return the corresponding Python data structure.

Parameters:

Name Type Description Default
edn_str str

The EDN string to parse.

required

Returns:

Name Type Description
EDNToken EDNToken

The parsed Python data structure.

tokenize(edn_str: str) -> Generator[str, Any]

Yield EDN tokens, skipping comments, whitespace, and commas.

Comments start with ';' and run to end-of-line. Commas are treated as whitespace per EDN spec.

Parameters:

Name Type Description Default
edn_str str

The EDN string to tokenize.

required

Yields:

Name Type Description
str str

The next token in the EDN string.

get_edn_from_file(path: Path) -> EDNToken

Initialize the LogseqGraphConfig from a file.

Parameters:

Name Type Description Default
path Path

The path to the config file.

required

get_default_logseq_config() -> dict[str, Any]

Get the default Logseq configuration.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: The default Logseq configuration.

get_target_dirs(config: dict[str, Any]) -> dict[str, str]

Get the target directories for Logseq.

Parameters:

Name Type Description Default
config dict[str, Any]

The configuration dictionary.

required

Returns:

Type Description
dict[str, str]

dict[str, str]: A dictionary containing the target directories.

get_ns_sep(config: dict[str, Any]) -> str

Get the namespace separator based on the configuration.

get_page_title_format(config: dict[str, Any]) -> str

Get the page title format from the configuration.

get_file_name_format(config: dict[str, Any]) -> str

Get the file name format from the configuration.

get_prop_pages_enabled(config: dict[str, Any]) -> bool

Check if property pages are enabled in the configuration.