Freeciv-3.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
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 ()
 

Data Fields

 def_paths
 
 common_header_path
 
 common_impl_path
 
 server_header_path
 
 server_impl_path
 
 client_header_path
 
 client_impl_path
 
 verbose
 
 lazy_overwrite
 
 gen_stats
 
 log_macro
 
 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)
 

Protected Attributes

 _script_path
 

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 146 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 204 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 195 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 217 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 259 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 242 of file generate_packets.py.

◆ _write_disclaimer()

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

Definition at line 223 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 59 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 302 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 189 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 276 of file generate_packets.py.

Field Documentation

◆ _script_path

generate_packets.ScriptConfig._script_path
protected

Definition at line 228 of file generate_packets.py.

◆ client_header_path

generate_packets.ScriptConfig.client_header_path

Definition at line 166 of file generate_packets.py.

◆ client_impl_path

generate_packets.ScriptConfig.client_impl_path

Definition at line 169 of file generate_packets.py.

◆ common_header_path

generate_packets.ScriptConfig.common_header_path

Definition at line 154 of file generate_packets.py.

◆ common_impl_path

generate_packets.ScriptConfig.common_impl_path

Definition at line 157 of file generate_packets.py.

◆ def_paths

generate_packets.ScriptConfig.def_paths

Definition at line 151 of file generate_packets.py.

◆ fold_bool

generate_packets.ScriptConfig.fold_bool

Definition at line 184 of file generate_packets.py.

◆ gen_stats

generate_packets.ScriptConfig.gen_stats

Definition at line 178 of file generate_packets.py.

◆ lazy_overwrite

generate_packets.ScriptConfig.lazy_overwrite

Definition at line 175 of file generate_packets.py.

◆ log_macro

generate_packets.ScriptConfig.log_macro

Definition at line 180 of file generate_packets.py.

◆ server_header_path

generate_packets.ScriptConfig.server_header_path

Definition at line 160 of file generate_packets.py.

◆ server_impl_path

generate_packets.ScriptConfig.server_impl_path

Definition at line 163 of file generate_packets.py.

◆ verbose

generate_packets.ScriptConfig.verbose

Definition at line 173 of file generate_packets.py.