-
Notifications
You must be signed in to change notification settings - Fork 260
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
Fix for issue #676: title field not seem to be working with JSON profile #736
Conversation
…g with JSON profile
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.
Verified on Ubuntu 22.04, it works correct, the tab has it's title. Thank you for contributing!
However there are several points remaining unclear for me.
The function from_json()
accepts two arguments layout_name
and json_name
(default None
). As i understood the purpose of json_name
if to distinguish the name of property in layout from the actual key provided in JSON. Can they be different anyway? In your implementation there aren't calls from_json()
passing json_name
as an agrument (so json_name
would equal to layout_name
all the time). Does json_name
really matter?
Also i'm a bit confused about using __setitem__()
instead of children[parent + "." + str(order)][layout_name] = layoutjson[json_name]
.
I'd suggest the next implementation:
def build_terminal_layout(self, layoutjson, children, parent, order):
dbg ('Building a terminal from json: %s' % layoutjson)
children[parent + "." + str(order)] = {
'type': 'Terminal',
'order': order,
'parent': parent,
'profile': self.profile_to_use
}
for item in ('command', 'title'):
if item in layoutjson:
children[parent + "." + str(order)][item] = layoutjson[item]
or even like this (a bit prettier as for me):
def build_terminal_layout(self, layoutjson, children, parent, order):
dbg ('Building a terminal from json: %s' % layoutjson)
child_conf = {
'type': 'Terminal',
'order': order,
'parent': parent,
'profile': self.profile_to_use
}
for item in ('command', 'title'):
if item in layoutjson:
child_conf[item] = layoutjson[item]
children[".".join([parent, str(order)])] = child_conf
(I've checked the code above, it works correctly)
Please, let me know if i'm wrong and we should consider cases when the name in a layout conf and the actual JSON key (meaning json_name
really matters).
Thanks for the review, From my point of view it's a matter of design but the setitem function sets the element in the dictionary. So I don’t really understand, why do you prefer square brackets? |
Sounds reasonable. As for
(Python 3.8.10 \n[GCC 9.4.0]) Not to mention it's essentially less readable form of doing the same thing. Similar points are described at this topic on SO. Futhermore, Python's special method
(Python 3.8.10 \n[GCC 9.4.0]) |
0001-Fix-for-issue-676-title-field-not-seem-to-be-working.patch |
@rkashinin thanks for the update! You can just upload a new commit in a top of the current. Then it's going to be automatically updated here, in the current PR.
(Note: the argument "origin" in 4th step may be different depending on which settings are in your .git/config file; to clarify you can run Alternatively you can create a new pull request, of course, it's up to you, choose the easier option :) Hope this help! |
Thanks for your advice, |
No description provided.