-
Notifications
You must be signed in to change notification settings - Fork 11
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
Added conditional_before_commands #51
base: master
Are you sure you want to change the base?
Changes from all commits
4543df7
4543b57
825a00b
a52e5e6
352e179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -70,8 +70,8 @@ def init_from_yaml(self, yaml_data): | |||||||
"""Initialize config directly by an already loaded yaml structure.""" | ||||||||
|
||||||||
self.__yaml_data = yaml_data | ||||||||
self._parse_common() | ||||||||
self._parse_parameters() | ||||||||
self._parse_common() | ||||||||
self._parse_windows() | ||||||||
|
||||||||
def run(self, parent_server: libtmux.Server, debug=False): | ||||||||
|
@@ -101,11 +101,30 @@ def _parse_common(self): | |||||||
if "common" in self.__yaml_data and self.__yaml_data["common"]: | ||||||||
common = self.__yaml_data["common"] | ||||||||
if "before_commands" in common and common["before_commands"]: | ||||||||
self._before_commands = common["before_commands"] | ||||||||
# self._before_commands = common["before_commands"] | ||||||||
self._parse_before_commands(common["before_commands"]) | ||||||||
Comment on lines
+104
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to keep old code around.
Suggested change
|
||||||||
|
||||||||
if "default_window" in common and common["default_window"]: | ||||||||
self._default_window = common["default_window"] | ||||||||
|
||||||||
def _parse_before_commands(self, commands): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is parsing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, we could also extend this to the normal commands but I'll need to have a closer look at that Sorry for all the editing I got confused :D |
||||||||
command_list = [] | ||||||||
for command in commands: | ||||||||
if isinstance(command, str): | ||||||||
command_list.append(command) | ||||||||
elif isinstance(command, dict): | ||||||||
conditional_param = command.get("if") | ||||||||
print(conditional_param) | ||||||||
if conditional_param not in self._parameters: | ||||||||
print( | ||||||||
"Skipping command because parameter " | ||||||||
+ conditional_param | ||||||||
+ " was not found." | ||||||||
) | ||||||||
elif self._parameters[conditional_param]: | ||||||||
command_list.append(command.get("command")) | ||||||||
self._before_commands = command_list | ||||||||
|
||||||||
def _parse_overwrites(self, data_string): | ||||||||
"""Separates a comma-separated list of foo=val1,bar=val2 into a dictionary.""" | ||||||||
if data_string is None: | ||||||||
|
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, a more descriptive name would be good, so it is clear that the name is an arbitrary example, rather than a functionality. E.g.
print_additional_intro
.