fab.parse package#

exception fab.parse.ParseException#

Bases: Exception

class fab.parse.AnalysedFile(fpath, file_hash=None)#

Bases: ABC

Analysis results for a single file. Abstract base class.

Parameters:
  • fpath (Union[str, Path]) – The path of the file which was analysed.

  • file_hash (Optional[int]) – The checksum of the file which was analysed. If omitted, Fab will evaluate lazily. (default: None)

If not provided, the self.file_hash property is lazily evaluated in case the file does not yet exist.

property file_hash: int#
to_dict()#

Create a dict representing the object.

The dict may be written to json, so can’t contain sets. Lists are sorted for reproducibility in testing.

Return type:

Dict[str, Any]

classmethod from_dict(d)#
save(fpath)#
classmethod load(fpath)#
classmethod field_names()#

Defines the order in which we want fields to appear in str or repr strings.

Calling this helps to ensure any lazy attributes are evaluated before use, e.g when constructing a string representation of the instance, or generating a hash value.

class fab.parse.EmptySourceFile(fpath)#

Bases: AnalysedFile

An analysis result for a file which resulted in an empty parse tree.

Parameters:

fpath (Union[str, Path]) – The path of the file which was analysed.

classmethod from_dict(d)#

Submodules#