-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib50.files returns all files when arg is empty list #10
Comments
Okay, on further testing, a
or even
also results in
the above YAML results in
is |
The default is include everything (similarly to .gitignore) as per: Line 134 in 3005b61
You should be able to exclude just README.md with:
|
Yep, what Jelle said. This ensures that our promise that a minimal |
I see, I presume this is what you were alluding to when you proposed I blacklist
for lab50, so that all files are excluded by default? Else, for labs with not just |
That would make the default case meaningless though, which I guess is:
As all files are then excluded. Rather, and for this I should probably pick up on #8, I'd expect the default behavior to be: include everything via In the case of excluding more than including, anyone can just invert the logic by prepeding |
Hm, but many/most labs will likely end up having checks. So I'm not sure we're optimizing for the common case here? With
copied into the sandbox by default. Indeed, odds are you just want one file (e.g., Can/should we add a flag to |
However, the interface is pretty bad right now, let me see if I can find some time tomorrow to work on this. I envision you would end up doing something like this: # Read .cs50.yaml
with open(".cs50.yaml") as f:
content = f.read()
# Configure a config loader
loader = lib50.Loader("lab50")
loader.scope("files", "closed", "opened", default="exclude")
# Load
parsed_yaml = loader.load(content)
# Manipulate the patterns specified in .cs50.yaml
file_patterns = [lib50.TaggedValue("exclude", "*")] + parsed_yaml["files"]
# Tell lib50.files how to treat the custom tags
included, excluded = lib50.files(file_patterns, include_tags = ["opened", "closed"], exclude_tags = ["exclude"]) ps. Should it be |
Working prototype with: pip install git+https://github.com/cs50/lib50.git@develop import lib50
# Init loader
loader = lib50.config.Loader("lab50")
# Allow only values under files to be tagged with open, close, exclude
loader.scope("files", "open", "close", "exclude")
# Load
with open(".cs50.yaml") as f:
config = loader.load(f.read())
# Prepend !exclude "*"
config["files"] = [lib50.config.TaggedValue("*", "!exclude")] + config["files"]
# Tell lib50.files how to treat the custom tags
included, excluded = lib50.files(config["files"],
include_tags=[],
exclude_tags=["exclude"],
require_tags=["open", "close"]) You can opt to use |
Below seems to return all files of the form
/some/path/*
rather than nothing?The text was updated successfully, but these errors were encountered: