ngdb.guide
Defines the class for opening and managing a Norton Guide database.
EOFResult
module-attribute
EOFResult = TypeVar('EOFResult')
Return type of a method decorated with @not_eof
.
NortonGuide
NortonGuide(guide)
Norton Guide database wrapper class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str | Path
|
The guide to open. |
required |
CREDIT_LENGTH
class-attribute
instance-attribute
CREDIT_LENGTH = 66
The length of a line in the credits.
MAGIC
class-attribute
instance-attribute
MAGIC = {'EH': 'Expert Help', 'NG': 'Norton Guide'}
Lookup for valid database magic markers.
TITLE_LENGTH
class-attribute
instance-attribute
TITLE_LENGTH = 40
The length of a title in the header.
credits
property
credits
The credits for the guide.
eof
property
eof
Are we at the end of the guide?
is_a
property
is_a
Is the guide actually a Norton Guide database?
is_open
property
is_open
Is the guide open?
made_with
property
made_with
The name of the tool that was used to make the guide.
magic
property
magic
The magic value for the guide.
This tells us if the file is likely a Norton Guide database or not.
It's always a two-character string and, normally, is NG
.
However, if the guide was made for Expert Help, it could be EH
.
menu_count
property
menu_count
The count of menu options in the guide.
menus
property
menus
The menus for the guide.
path
property
path
The path to the guide.
title
property
title
The title of the guide.
__del__
__del__()
Ensure we close the handle to the guide if we're deleted.
__enter__
__enter__()
Handle entry to context.
__exit__
__exit__(*_)
Handle exit from context.
__iter__
__iter__()
Allow iterating through every entry in the guide.
Yields:
Type | Description |
---|---|
Short | Long
|
Raises:
Type | Description |
---|---|
UnknownEntryType
|
If an unknown type of entry is encountered. |
__repr__
__repr__()
The string representation of the guide.
Returns:
Type | Description |
---|---|
str
|
A string representation of the guide object. |
__str__
__str__()
The string representation of the guide.
Returns:
Type | Description |
---|---|
str
|
The guide's full path/file name as a string. |
close
close()
Close the guide, if it's open.
Note
Closing the guide when it isn't open is a non-op. It's always safe to make this call.
goto
goto(pos)
load
load()
maybe
staticmethod
maybe(candidate)
Does the given file look like it might be a Norton Guide?
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Path
|
The file to consider. |
required |
Returns:
Type | Description |
---|---|
bool
|
Notes
The content of the file is not looked at here, just the name
of the file. This means it can be used as a fast initial filter.
To see if a file is really a Norton Guide open it with
NortonGuide
and check
is_a
.
Also keep in mind that even the existence of the file isn't taken into account.
not_eof
not_eof(meth)
Decorator to ensure a guide isn't at EOF before executing a method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Callable[..., EOFResult]
|
The method fo protect. |
required |
Returns:
Type | Description |
---|---|
Callable[..., EOFResult]
|
The guard. |
This decorator is used as part of NortonGuide
, to
decorate functions that should test for being
eof
before the work of the method is done. If
the guide is eof
NGEOF
will be raised.