File: filter.py

package info (click to toggle)
trash-cli 0.24.5.26-0.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,972 kB
  • sloc: python: 9,789; sh: 121; makefile: 11
file content (13 lines) | stat: -rw-r--r-- 399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
# Copyright (C) 2011-2021 Andrea Francia Bereguardo(PV) Italy
import fnmatch
import os


class Filter:
    def __init__(self, pattern):
        self.pattern = pattern

    def matches(self, original_location):
        basename = os.path.basename(original_location)
        subject = original_location if self.pattern[0] == '/' else basename
        return fnmatch.fnmatchcase(subject, self.pattern)