Freeciv-3.3: generate_packets.ScriptConfig Class Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions
generate_packets.ScriptConfig Class Reference

## Public Member Functions

| __init__ (self, "typing.Sequence[str] | None" args=None)
| log_verbose (self, *args)
typing.Iterator[typing.TextIO] | open_write (self, "str | Path" path, "str | None" wrap_header=None, bool cplusplus=True)
typing.Iterator[typing.TextIO] | lazy_overwrite_open (self, "str | Path" path, str suffix=".tmp")

## Static Public Member Functions

argparse.ArgumentParser | get_argparser ()

## Static Public Attributes

str | def_paths : "list[Path]"
str | common_header_path : "Path | None"
str | common_impl_path : "Path | None"
str | server_header_path : "Path | None"
str | server_impl_path : "Path | None"
str | client_header_path : "Path | None"
str | client_impl_path : "Path | None"
bool | verbose
bool | lazy_overwrite
bool | gen_stats
str | log_macro : "str | None"
bool | fold_bool

## Protected Member Functions

"Path | None" | _root_path (self)
Path | _relative_path (self, Path path)
Path | _script_path (self)
| _write_disclaimer (self, typing.TextIO f)
typing.Iterator[None] | _wrap_header (self, typing.TextIO file, str header_name)
typing.Iterator[None] | _wrap_cplusplus (self, typing.TextIO file)

## Detailed Description

    Contains configuration info for the script's execution, along with
    functions closely tied to that configuration

Definition at line 54 of file generate_packets.py.

## Constructor & Destructor Documentation

## ◆ __init__()

generate_packets.ScriptConfig.__init__ | ( |  | self,
|  | "typing.Sequence[str] | None" | args = `None`
| ) |  |

Definition at line 181 of file generate_packets.py.

## Member Function Documentation

## ◆ _relative_path()

Path generate_packets.ScriptConfig._relative_path | ( |  | self,
|  | Path | path
| ) |  |

protected

    Find the relative path from the Freeciv root to the given path.
    Return the path unmodified if it's outside the Freeciv root, or if
    the Freeciv root could not be found.

Definition at line 199 of file generate_packets.py.

## ◆ _root_path()

"Path | None" generate_packets.ScriptConfig._root_path | ( |  | self | ) |

protected

    Root Freeciv path, if we can find it.

Definition at line 190 of file generate_packets.py.

## ◆ _script_path()

Path generate_packets.ScriptConfig._script_path | ( |  | self | ) |

protected

    Relative path of the executed script. Under normal circumstances,
    this will be common/generate_packets.py, but it may differ when this
    module is imported from another script.

Definition at line 212 of file generate_packets.py.

## ◆ _wrap_cplusplus()

typing.Iterator[None] generate_packets.ScriptConfig._wrap_cplusplus | ( |  | self,
|  | typing.TextIO | file
| ) |  |

protected

    Add code for `extern "C" {}` wrapping

Definition at line 254 of file generate_packets.py.

## ◆ _wrap_header()

typing.Iterator[None] generate_packets.ScriptConfig._wrap_header | ( |  | self,
|  | typing.TextIO | file,
|  | str | header_name
| ) |  |

protected

    Add multiple inclusion protection to the given file

Definition at line 237 of file generate_packets.py.

## ◆ _write_disclaimer()

generate_packets.ScriptConfig._write_disclaimer | ( |  | self,
|  | typing.TextIO | f
| ) |  |

protected

Definition at line 218 of file generate_packets.py.

## ◆ get_argparser()

argparse.ArgumentParser generate_packets.ScriptConfig.get_argparser | ( |  | ) |

static

    Construct an argument parser for a packet generation script

Definition at line 94 of file generate_packets.py.

## ◆ lazy_overwrite_open()

typing.Iterator[typing.TextIO] generate_packets.ScriptConfig.lazy_overwrite_open | ( |  | self,
|  | "str | Path" | path,
|  | str | suffix = `".tmp"`
| ) |  |

    Open a file for writing, but only actually overwrite it if the new
    content differs from the old content.

    This creates a temporary file by appending the given suffix to the given
    file path. In the event of an error, this temporary file might remain in
    the target file's directory.

Definition at line 297 of file generate_packets.py.

## ◆ log_verbose()

generate_packets.ScriptConfig.log_verbose | ( |  | self,
|  | * | args
| ) |  |

    Print the given arguments iff verbose logging is enabled

Definition at line 184 of file generate_packets.py.

## ◆ open_write()

typing.Iterator[typing.TextIO] generate_packets.ScriptConfig.open_write | ( |  | self,
|  | "str | Path" | path,
|  | "str | None" | wrap_header = `None`,
|  | bool | cplusplus = `True`
| ) |  |

    Open a file for writing and write disclaimer.

    If enabled, lazily overwrites the given file.
    If wrap_header is given, add multiple inclusion protection; if
    cplusplus is also given (default), also add code for `extern "C"`
    wrapping.

Definition at line 271 of file generate_packets.py.

## Field Documentation

## ◆ client_header_path

str generate_packets.ScriptConfig.client_header_path : "Path | None"

static

Definition at line 72 of file generate_packets.py.

## ◆ client_impl_path

str generate_packets.ScriptConfig.client_impl_path : "Path | None"

static

Definition at line 75 of file generate_packets.py.

## ◆ common_header_path

str generate_packets.ScriptConfig.common_header_path : "Path | None"

static

Definition at line 60 of file generate_packets.py.

## ◆ common_impl_path

str generate_packets.ScriptConfig.common_impl_path : "Path | None"

static

Definition at line 63 of file generate_packets.py.

## ◆ def_paths

str generate_packets.ScriptConfig.def_paths : "list[Path]"

static

Definition at line 58 of file generate_packets.py.

## ◆ fold_bool

bool generate_packets.ScriptConfig.fold_bool

static

Definition at line 90 of file generate_packets.py.

## ◆ gen_stats

bool generate_packets.ScriptConfig.gen_stats

static

Definition at line 84 of file generate_packets.py.

## ◆ lazy_overwrite

bool generate_packets.ScriptConfig.lazy_overwrite

static

Definition at line 81 of file generate_packets.py.

## ◆ log_macro

str generate_packets.ScriptConfig.log_macro : "str | None"

static

Definition at line 86 of file generate_packets.py.

## ◆ server_header_path

str generate_packets.ScriptConfig.server_header_path : "Path | None"

static

Definition at line 66 of file generate_packets.py.

## ◆ server_impl_path

str generate_packets.ScriptConfig.server_impl_path : "Path | None"

static

Definition at line 69 of file generate_packets.py.

## ◆ verbose

bool generate_packets.ScriptConfig.verbose

static

Definition at line 79 of file generate_packets.py.