Skip to content

Commit

Permalink
Add some conditions to condition parser
Browse files Browse the repository at this point in the history
CLoses #49, #62.
  • Loading branch information
jerrymakesjelly committed Feb 28, 2020
1 parent e5d5c56 commit 0e08ffb
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 1 deletion.
14 changes: 13 additions & 1 deletion autoremovetorrents/conditionparser.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import ply.yacc as yacc
from . import logger
from .conditionlexer import ConditionLexer
from .condition.avgdownloadspeed import AverageDownloadSpeedCondition
from .condition.avguploadspeed import AverageUploadSpeedCondition
from .condition.base import Comparer
from .condition.connectedleecher import ConnectedLeecherCondition
from .condition.connectedseeder import ConnectedSeederCondition
from .condition.createtime import CreateTimeCondition
from .condition.downloadspeed import DownloadSpeedCondition
from .condition.lastactivity import LastActivityCondition
from .condition.leecher import LeecherCondition
from .condition.ratio import RatioCondition
from .condition.seeder import SeederCondition
from .condition.seedingtime import SeedingTimeCondition
from .condition.size import SizeCondition
from .condition.uploadspeed import UploadSpeedCondition
from .conditionlexer import ConditionLexer
from .exception.nosuchcondition import NoSuchCondition
from .exception.syntaxerror import ConditionSyntaxError

class ConditionParser(object):
# Condition Map (as constant)
_condition_map = {
'average_downloadspeed': AverageDownloadSpeedCondition,
'average_uploadspeed': AverageUploadSpeedCondition,
'connected_leecher': ConnectedLeecherCondition,
'connected_seeder': ConnectedSeederCondition,
'create_time': CreateTimeCondition,
'download_speed': DownloadSpeedCondition,
'last_activity': LastActivityCondition,
'leecher': LeecherCondition,
'ratio': RatioCondition,
'seeder': SeederCondition,
'seeding_time': SeedingTimeCondition,
'size': SizeCondition,
'upload_speed': UploadSpeedCondition,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test:
remove: average_downloadspeed > 9800
remove:
- Torrent - 13
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
remove: average_downloadspeed < 500
remove:
- Torrent - 1
- Torrent - 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
remove: average_uploadspeed > 900
remove:
- Torrent - 15
- Torrent - 16
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
remove: average_uploadspeed < 100
remove:
- Torrent - 1
- Torrent - 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test:
remove: connected_leecher > 100
remove:
- Torrent - 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test:
remove: connected_leecher < 1
remove:
- Torrent - 3
- Torrent - 4
- Torrent - 7
- Torrent - 9
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
remove: connected_seeder > 0
remove:
- Torrent - 1
- Torrent - 12
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test:
remove: connected_seeder < 1
remove:
- Torrent - 2
- Torrent - 3
- Torrent - 4
- Torrent - 5
- Torrent - 6
- Torrent - 7
- Torrent - 8
- Torrent - 9
- Torrent - 10
- Torrent - 11
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test:
remove: leecher > 100
remove:
- Torrent - 1
10 changes: 10 additions & 0 deletions pytest/test_strategies/cases/remove_conditions/test_leecher_lt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test:
remove: leecher < 10
remove:
- Torrent - 4
- Torrent - 5
- Torrent - 7
- Torrent - 8
- Torrent - 9
- Torrent - 13
- Torrent - 14
14 changes: 14 additions & 0 deletions pytest/test_strategies/cases/remove_conditions/test_seeder_gt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
test:
remove: seeder > 1
remove:
- Torrent - 3
- Torrent - 4
- Torrent - 5
- Torrent - 6
- Torrent - 7
- Torrent - 8
- Torrent - 9
- Torrent - 10
- Torrent - 13
- Torrent - 14
- Torrent - 16
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test:
remove: seeder < 2
remove:
- Torrent - 1
- Torrent - 2
- Torrent - 11
- Torrent - 12
- Torrent - 15

0 comments on commit 0e08ffb

Please sign in to comment.