-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
333c209
commit ca3e5de
Showing
6 changed files
with
78 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
import os | ||
from core.data import rockPATH | ||
|
||
|
||
class Excluder: | ||
|
||
def __init__(self) -> None: | ||
self.__excluded_modules = [] | ||
|
||
def excludeA(self, moduleName): | ||
# Exclude only one module | ||
if moduleName not in self.__excluded_modules: | ||
moduleName += '.py' if not moduleName.endswith('.py') else str() | ||
self.__excluded_modules.append(moduleName) | ||
|
||
def excludeL(self, modules): | ||
# Exclude list of modules | ||
if not isinstance(modules, list): | ||
raise TypeError("excludeL takes a list") | ||
|
||
for module in modules: | ||
self.excludeA(module) | ||
|
||
def excludeAll(self): | ||
# Exclude all of modules | ||
modules = list() | ||
path = os.path.join(rockPATH(), "modules") | ||
files = os.listdir(path) | ||
for file in files: | ||
if file.endswith('.py'): | ||
modules.append(file) | ||
|
||
self.excludeL(modules) | ||
|
||
def include(self, moduleName): | ||
# Include one module | ||
moduleName += '.py' if not moduleName.endswith('.py') else str() | ||
self.__excluded_modules.remove(moduleName) | ||
|
||
def includeA(self, moduleName): | ||
# Include one module, with excluding all modules | ||
self.excludeAll() | ||
self.include(moduleName) | ||
|
||
def includeL(self, modules): | ||
# Include list of modules, with excluding all another modules | ||
if not isinstance(modules, list): | ||
raise TypeError("includeL takes a list") | ||
|
||
self.excludeAll() | ||
|
||
for module in modules: | ||
self.include(module) | ||
|
||
def excluded(self, moduleName): | ||
# check if module excluded | ||
return moduleName in self.__excluded_modules | ||
|
||
def included(self, moduleName): | ||
# check if module included | ||
return not self.excluded(moduleName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters