-
Notifications
You must be signed in to change notification settings - Fork 14
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
Write and test BlockNode, ListNode #73
Conversation
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
==========================================
+ Coverage 88.34% 91.54% +3.19%
==========================================
Files 7 6 -1
Lines 678 627 -51
==========================================
- Hits 599 574 -25
+ Misses 79 53 -26
Continue to review full report at Codecov.
|
db18f4a
to
9aed274
Compare
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.
Thank you! Looks good, my main concerns are:
- Do we really need
ContentsNode
abstraction? - I guess I am not yet understanding specialized parser suite creation frequency - it would be great to have it reusable as much as possible
WDYT?
apacheconfig/wloader.py
Outdated
""" | ||
|
||
|
||
class ContentsNode(Node): |
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.
How much ContentsNode
is different from BlockNode
? I can imagine, structurally, having BlockNode
everywhere (root, intermediate nodes) and ItemNode
& BlockNode
in it.
My understanding is that with ContentsNode
we will have them scoped like:
ContentsNode
(root) -> BlockNode
-> ContentsNode
-> BlockNode
-> ItemNode
So I am wondering if we can always treat BlockNode
as a "container", where ItemNode
would always be a leaf scalar e.g.:
BlockNode
(root) -> BlockNode
-> ItemNode
WDYT?
@sydneyli I assume this PR is not blocked on me, presently. ;-) |
Yep, it's back to me! Hoping to get to this today. |
Re: ContentsNode vs BlockNode: It's a good point. I do see what you mean that ContentsNode vs BlockNode are really only unique in that contents has no tag, and effectively acts as a root node (or as a child of BlockNode), and BlockNode is intermediary. Here are the things that make the two different:
Having these (particularly the tag manipulation) separated by class type seems useful. What if we have BlockNode subclass a generic ContentsNode, and maybe rename them something like |
That sounds like a legit design to me. Alternatively to subclassing, may be we could have an abstract or a base class declaring the interfaces and/or common implementation, then In other words:
or
The mix-in piece would be there to keep abstract class defining just the interfaces, not any common code. On the other hand, that's not strictly required with Python customs, AFAIK. WDYT? |
Subclassing might make things a bit simpler here, since BlockNode has a lot of unique functionality over RootNode, but not the other way around. That is, the set of things RootNode should be able to do is actually a subset of the things BlockNode can do. EDIT: This was a pretty straightforward change, so I tried it out in the most recent commit. Let me know what you think, or if you might prefer having an abstract class. Also, naming is still hard, so will take recommendations there :) |
Also remove exported *Node objects from __init__ since we don't necessarily want to expose those constructors.
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.
Looks awesome to me!
I have a handful of nits for your considerations.
apacheconfig/wloader.py
Outdated
|
||
@property | ||
def arguments(self): | ||
"""Returns arguments for this block as a literal string. |
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.
literal string
- is it in Apache config syntax?
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.
Nope-- removed to just say "string".
Thanks for the review! I did a pass on the documentation. EDIT: Did a pass on error handling. Unicode support might be a larger undertaking, so I opened #85 ! |
(Just a note in case you missed-- this and the unicode PR are good for another round when you get the chance!) |
Hey, and thank you for the ping! I am not always sure at which point it's back to me (I am checking out the PRs from occasionally), so explicit communication is good! |
Every AST should have a :class:`apacheconfig.ListNode` at its root. A | ||
:class:`apacheconfig.ListNode` or :class:`apacheconfig.BlockNode` can have | ||
other :class:`apacheconfig.BlockNode`s and | ||
:class:`apacheconfig.LeafASTNode`s as children. |
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.
nit: Is it deliberate to have AST in abstract and leaf, but not in other class names?
root should be a ListNode. To construct from a raw string, use the | ||
`parse` factory function. The default __init__ constructor expects data | ||
from the internal apacheconfig parser. | ||
Every configuration file's root should be a ListNode. |
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.
nit: hyperlink ListNode
?
Let's merge this PR - I think it's good enough and I do not want to block you. I've left a couple of nits for your consideration (I am never short of nits). If you consider them worth addressing, I guess you could just push a quick PR. Also, perhaps at some point we should have a CHANGELOG entry explaining this undertaking. I am just not sure at which PR in the chain it's would be best to note. Thank you! |
Thanks @etingof -- appreciate it! I agree with your notes on consistency between the namings, so i'll push a PR for that soon. |
From interface described in #49, depends on #72. Should be rebased/merged when #72 lands.