pathex.expressions.expression module

Expressions abstract base class

Module

pathex.expressions.expression


class Expression[source]

Bases: abc.ABC

Expressions abstract base class.

In PathEx objects of any other kind different from Expression are interpreted as an identity terminal expression. Expression is meant to grouping those kind of expressions that has a special meaning and to provide general methods and Python operator overloading.

get_eager_generator(self, machine: pathex.generation.machines.machine.Machine | None = None, word_type: type[T] = ListWrapper, complete_words: bool = True) Generator[T, None, None][source]

Gives a generator of CollectionWrapper object that represent the words generated by the expression.

This method is meant as a handy shortcut for words_generator(self, machine, word_type, complete_words).

machine is The machine to be used to interpret the expression. If it is None then an instance of ExtendedMachineCompalphabet will be used. Defaults to None.

word_type is a CollectionWrapper subtype that will be the type of collection to be used to represent words. Defaults to ListWrapper.

complete_words is a flag indicating if only complete words are to be given. Defaults to True.

get_generator(machine: pathex.generation.machines.machine.Machine | None = None) WordsGenerator[source]

Gives a WordsGenerator with default values for the actual expression.

This method is meant as a handy shortcut for WordsGenerator(expression, machine).

machine is the machine to be used to interpret the expression. If it is None then an instance of ExtendedMachineCompalphabet will be used. Defaults to None.

get_language(language_type: type[T] = SetWrapper, machine: pathex.generation.machines.machine.Machine | None = None, word_type: type[CollectionWrapper] = ListWrapper, complete_words: bool = True) T[source]

Gives a CollectionWrapper object that contains CollectionWrapper objects that represent the words generated by the expression.

language_type is a subtype of CollectionWrapper that will be used as the type of the object to be returned. Defaults to SetWrapper.

machine is the machine to be used to interpret the expression. If it is None then an instance of ExtendedMachineCompalphabet will be used. Defaults to None.

word_type is a CollectionWrapper subtype that will be the type of collection to be used to represent words. Defaults to ListWrapper.

complete_words is a flag indicating if only complete words are to be given. Defaults to True.