-
Notifications
You must be signed in to change notification settings - Fork 110
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
Feature/optional files #181
Conversation
@@ -176,6 +181,23 @@ | |||
:vars vars | |||
:opts (if-not method opts (merge (:opts method) opts))))) | |||
|
|||
(defn- make-input-stats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the case for generating these structures at parse time (similar to the "two-copies" approach Artem suggested in his comment about this feature), but honestly the parser code confuses me so I did this here.
We'd save a couple extra checks for existence, but the change will be more extensive as inputs will now be this map instead of just a string, and everything has to handle that. It's your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the parser already does too much stuff unrelated to parsing. It shouldn't be reading the filesystem to decide what is meant by the stuff it parses. So where you've put this looks right to me.
@@ -176,6 +181,17 @@ | |||
:vars vars | |||
:opts (if-not method opts (merge (:opts method) opts))))) | |||
|
|||
(defn- existing-and-empty-inputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return a map like {:existing (...) :empty (...)}
, so that it will be clearer at the usage site what's going on.
Overall looks pretty good to me. |
@@ -106,8 +106,13 @@ | |||
it. This is safe to do since it's the default filesystem, | |||
but it gives us a bit easier compatibility with existing tools." | |||
[filename] | |||
(let [n (dfs/normalized-path filename)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chen-factual What do you think about a function that wraps functions so that they correctly handle optional inputs? Like instead of making normalize-filename-for-run
and similar functions call parser/modify-filename
themselves, you could just rename the old definition to normalize-filename-for-run*
, and then (def normalize-filename-for-run (wrap-optional-handling normalize-filename-for-run*))
or whatever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a pretty awesome idea. I'll go ahead and pop that in there when I make my modifications for your review comments.
I'll probably do this late night tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, I thought about this some more. Why would you ever NOT want a function to correctly handle optional files? Why even have a normalize-filename-for-run*
that fails for optional files?
Also in the case of functions like parser/add-prefix
there there are other arguments besides a file name, this wrapping breaks down as we have no way of telling which argument is the file name.
I'm open to improving this in another way if you have any other ideas though.
Applied as b18cc24. |
For #179
@amalloy
Please review? I basically guessed where things are supposed to go (changes in core.clj and parser.clj), I expect you to ding me pretty hard on organization.
I also didn't test thoroughly beyond basic functionality (i.e. up-tree, down-tree, etc etc). If you can give some direction there that'd be cool.
Test Drakefile, one missing file, two existing ones.
Shell