Skip to content

ngdb.entry

Norton guide entry loading and holding code.

MAX_LINE_LENGTH module-attribute

MAX_LINE_LENGTH = 1024

Maximum size of a line we'll look for in a guide.

Entry

Entry(guide)

Norton Guide database entry class.

Parameters:

Name Type Description Default

guide

GuideReader

The reader object for the guide.

required

has_next property

has_next

Is there a next entry?

has_previous property

has_previous

Is there a previous entry?

has_see_also property

has_see_also

Does this entry have any see-also items?

lines property

lines

The lines of text in the entry.

next property

next

The location of the next entry.

offset property

offset

The file offset of this entry.

parent property

parent

Returns the parent entry information.

previous property

previous

The location of the previous entry.

size property

size

The size of the entry in bytes.

type_id property

type_id

The numeric ID of the type of entry.

__len__

__len__()

The number of lines in the entry.

Returns:

Type Description
int

The number of lines.

__repr__

__repr__()

Returns a string representation of the object.

Returns:

Type Description
str

The name of the type of entry.

__rich__

__rich__()

Support being printed in a Rich-enhanced REPL.

Returns:

Type Description
str

Rich-friendly test.

__str__

__str__()

Return the text of the entry as a single string.

Returns:

Type Description
str

The entry's text.

load classmethod

load(guide)

Load the entry at the current position in the guide.

Parameters:

Name Type Description Default

guide

GuideReader

The reader object for the guide.

required

Returns:

Type Description
Entry

The correct type of entry object.

Raises:

Type Description
UnknownEntryType

Indicates that the entry type is unknown.

loads classmethod

loads(entry_type)

Decorator for defining which class handles which entry type.

Parameters:

Name Type Description Default

entry_type

EntryType

The ID of the entry type being handled.

required

Returns:

Type Description
Callable[[type[Entry]], type[Entry]]

The decorator wrapper.

Example
@Entry.loads(EntryType.SHORT)
class Short(Entry):
    ...

EntryParent

EntryParent(guide)

Class to load and hold the parent information for an entry.

Parameters:

Name Type Description Default

guide

GuideReader

The reader object for the guide.

required

has_line property

has_line

Does this entry have a parent entry line that points to it?

has_menu property

has_menu

Is there a menu related to this entry?

has_prompt property

has_prompt

Is there a menu prompt related to this entry?

line property

line

The line in the parent entry that point to this entry.

If there is no parent line this will be -1. But also see has_line for a test for a parent entry line.

menu property

menu

The menu that relates to this entry.

If there is no menu, this will be -1. But also see has_menu to test if there is a related menu.

offset property

offset

The offset of the parent entry, if there is one.

prompt property

prompt

The menu prompt related to this entry.

If there is no menu prompt, this will be -1. But also see has_prompt to test if there is a related menu prompt.

__bool__

__bool__()

Is there a parent entry?

Returns:

Type Description
bool

True if there is, False if not.

Long

Long(guide)

Bases: Entry

Long Norton Guide database entry.

Parameters:

Name Type Description Default

guide

GuideReader

The reader object for the guide.

required

see_also property

see_also

The see-also information for this entry.

__getitem__

__getitem__(line)

Get a line from the entry.

Parameters:

Name Type Description Default

line

int

The lint to get.

required

Returns:

Type Description
str

The line.

__iter__

__iter__()

The lines in the entry.

Returns:

Type Description
Iterator[str]

An iterator of strings that are the lines in the entry.

Short

Short(guide)

Bases: Entry

Short Norton Guide database entry.

Parameters:

Name Type Description Default

guide

GuideReader

The reader object for the guide.

required

offsets property

offsets

The offsets for each of the lines in the entry.

__getitem__

__getitem__(line)

Get a line and its offset.

Parameters:

Name Type Description Default

line

int

The line to get the link information for.

required

Returns:

Type Description
Link

The link associated with that line.

__iter__

__iter__()

The lines in the entry along with the offsets into the guide.

Returns:

Type Description
Iterator[Link]

An iterator of link data.