3333
3434"""firebird.lib.gstat - Module for work with Firebird gstat output
3535
36-
3736"""
3837
3938from __future__ import annotations
124123items_fill = ['0 - 19%' , '20 - 39%' , '40 - 59%' , '60 - 79%' , '80 - 99%' ]
125124
126125class DbAttribute (Enum ):
127- "Database attributes stored in header page clumplets."
126+ """Database attributes stored in header page clumplets.
127+ """
128128 WRITE = 'force write'
129129 NO_RESERVE = 'no reserve'
130130 NO_SHARED_CACHE = 'shared cache disabled'
@@ -139,7 +139,8 @@ class DbAttribute(Enum):
139139
140140@dataclass (frozen = True )
141141class FillDistribution :
142- "Data/Index page fill distribution"
142+ """Data/Index page fill distribution.
143+ """
143144 d20 : int
144145 d40 : int
145146 d60 : int
@@ -148,7 +149,8 @@ class FillDistribution:
148149
149150@dataclass (frozen = True )
150151class Encryption :
151- "Page encryption status"
152+ """Page encryption status.
153+ """
152154 pages : int
153155 encrypted : int
154156 unencrypted : int
@@ -163,11 +165,13 @@ class _ParserState:
163165 step : int = 0
164166
165167def empty_str (value : str ) -> bool :
166- "Return True if string is empty (whitespace don't count) or None"
168+ """Return True if string is empty (whitespace don't count) or None.
169+ """
167170 return True if value is None else value .strip () == ''
168171
169172class StatTable :
170- "Statisctics for single database table."
173+ """Statisctics for single database table.
174+ """
171175 def __init__ (self ):
172176 #: Table name
173177 self .name : str = None
@@ -237,7 +241,8 @@ def __init__(self):
237241 self .level_2 : int = None
238242
239243class StatIndex :
240- "Statisctics for single database index."
244+ """Statisctics for single database index.
245+ """
241246 def __init__ (self , table ):
242247 #: wekref.proxy: Proxy to parent `.StatTable`
243248 self .table : weakref .ProxyType = weakref .proxy (table )
@@ -276,7 +281,8 @@ def __init__(self, table):
276281 self .ratio : float = None
277282
278283class StatDatabase :
279- """Firebird database statistics (produced by gstat)."""
284+ """Firebird database statistics (produced by gstat).
285+ """
280286 def __init__ (self ):
281287 #: GSTAT version
282288 self .gstat_version : int = None
@@ -552,26 +558,30 @@ def __parse_encryption(self, line: str) -> None:
552558 else :
553559 raise Error (f'Unknown encryption information (line { self .__line_no } )' )
554560 def has_table_stats (self ) -> bool :
555- """Return True if instance contains information about tables.
561+ """Returns True if instance contains information about tables.
556562
557563 .. important::
558564
559- This is not the same as check for empty :data:`tables` list. When gstat is run with `-i` without
560- `- d` option, :data:`tables` list contains instances that does not have any other information about table
561- but table name and its indices.
562- """
565+ This is not the same as check for empty :data:`tables` list. When gstat is run
566+ with `-i` without `- d` option, :data:`tables` list contains instances that does
567+ not have any other information about table but table name and its indices.
568+ """
563569 return self .tables [0 ].primary_pointer_page is not None if len (self .tables ) > 0 else False
564570 def has_row_stats (self ) -> bool :
565- "Return True if instance contains information about table rows."
571+ """Returns True if instance contains information about table rows.
572+ """
566573 return self .has_table_stats () and self .tables [0 ].avg_version_length is not None
567574 def has_index_stats (self ) -> bool :
568- "Return True if instance contains information about indices."
575+ """Returns True if instance contains information about indices.
576+ """
569577 return self .indices [0 ].depth is not None if len (self .indices ) > 0 else False
570578 def has_encryption_stats (self ) -> bool :
571- "Return True if instance contains information about database encryption."
579+ """Returns True if instance contains information about database encryption.
580+ """
572581 return self .encrypted_data_pages is not None
573582 def has_system (self ) -> bool :
574- "Return True if instance contains information about system tables."
583+ """Returns True if instance contains information about system tables.
584+ """
575585 return self .tables .contains ("item.name.startswith('RDB$DATABASE')" )
576586 def parse (self , lines : Iterable [str ]) -> None :
577587 """Parses gstat output.
@@ -666,9 +676,11 @@ def push(self, line: Union[str, Sentinel]) -> None:
666676 self .__parse_index (line )
667677 @property
668678 def tables (self ) -> DataList [StatTable ]:
669- "`~firebird.base.collections.DataList` of `.StatTable` instances"
679+ """`~firebird.base.collections.DataList` of `.StatTable` instances.
680+ """
670681 return self .__tables
671682 @property
672683 def indices (self ) -> DataList [StatIndex ]:
673- "`~firebird.base.collections.DataList` of `StatIndex` instances"
684+ """`~firebird.base.collections.DataList` of `StatIndex` instances.
685+ """
674686 return self .__indices
0 commit comments