|
1 | 1 | from email.message import Message |
2 | 2 | from typing import ( |
3 | | - TYPE_CHECKING, |
4 | | - List, |
5 | | - Optional, |
6 | | - Union, |
7 | | - SupportsInt, |
8 | | - Text |
| 3 | + Optional |
9 | 4 | ) |
10 | 5 |
|
11 | 6 | from sifter.grammar.command import Command |
12 | | -from sifter.grammar.command_list import CommandList |
13 | 7 | from sifter.validators.stringlist import StringList |
14 | 8 | from sifter.grammar.state import EvaluationState |
15 | 9 | from sifter.grammar.actions import Actions |
16 | 10 |
|
17 | | -if TYPE_CHECKING: |
18 | | - from sifter.grammar.tag import Tag as TagGrammar |
19 | | - from sifter.grammar.string import String |
20 | | - from sifter.grammar.test import Test |
21 | | - |
22 | 11 |
|
23 | 12 | # section 4.1 |
24 | 13 | class CommandFileInto(Command): |
25 | 14 |
|
26 | 15 | RULE_IDENTIFIER = 'FILEINTO' |
27 | 16 | POSITIONAL_ARGS = [StringList(length=1)] |
28 | 17 |
|
29 | | - def __init__( |
30 | | - self, |
31 | | - arguments: Optional[List[Union['TagGrammar', SupportsInt, List[Union[Text, 'String']]]]] = None, |
32 | | - tests: Optional[List['Test']] = None, |
33 | | - block: Optional[CommandList] = None |
34 | | - ) -> None: |
35 | | - super().__init__(arguments, tests, block) |
36 | | - self.file_dest = self.positional_args[0] |
37 | | - |
38 | 18 | def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]: |
| 19 | + file_dest = self.positional_args[0] |
| 20 | + |
39 | 21 | state.check_required_extension('fileinto', 'FILEINTO') |
40 | | - state.actions.append('fileinto', self.file_dest) # type: ignore |
| 22 | + state.actions.append('fileinto', file_dest) # type: ignore |
41 | 23 | state.actions.cancel_implicit_keep() |
42 | 24 | return None |
43 | 25 |
|
|
0 commit comments