The Gaudi Framework  master (37c0b60a)
update_version.FileUpdater Class Reference

Public Member Functions

def __init__ (self, str filename, Iterable[Union[ReplacementRule, tuple[str, str]]] rules)
 
tuple[str, list[str], list[str]] __call__ (self, Fields fields)
 

Public Attributes

 filename
 
 rules
 

Private Member Functions

str _apply_rules (self, str line, Fields fields)
 

Detailed Description

Definition at line 102 of file update_version.py.

Constructor & Destructor Documentation

◆ __init__()

def update_version.FileUpdater.__init__ (   self,
str  filename,
Iterable[Union[ReplacementRule, tuple[str, str]]]   rules 
)

Definition at line 103 of file update_version.py.

103  def __init__(
104  self, filename: str, rules: Iterable[Union[ReplacementRule, tuple[str, str]]]
105  ):
106  self.filename = filename
107  self.rules = [
108  r if isinstance(r, ReplacementRule) else ReplacementRule(*r) for r in rules
109  ]
110 

Member Function Documentation

◆ __call__()

tuple[str, list[str], list[str]] update_version.FileUpdater.__call__ (   self,
Fields  fields 
)

Definition at line 116 of file update_version.py.

116  def __call__(self, fields: Fields) -> tuple[str, list[str], list[str]]:
117  with open(self.filename) as f:
118  old = f.readlines()
119  return self.filename, old, [self._apply_rules(line, fields) for line in old]
120 
121 

◆ _apply_rules()

str update_version.FileUpdater._apply_rules (   self,
str  line,
Fields  fields 
)
private

Definition at line 111 of file update_version.py.

111  def _apply_rules(self, line: str, fields: Fields) -> str:
112  for rule in self.rules:
113  line = rule(line, fields)
114  return line
115 

Member Data Documentation

◆ filename

update_version.FileUpdater.filename

Definition at line 104 of file update_version.py.

◆ rules

update_version.FileUpdater.rules

Definition at line 105 of file update_version.py.


The documentation for this class was generated from the following file: