Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def foo(bar):
- return bar * 2
- # def foo(bar):
- # return bar * 2
- $<
- lines = $PLUMA_SELECTED_TEXT.split("n");
- output = "";
- for line in lines:
- output += "#" + line + "n";
- return output
- >
- $<
- selected_txt = $PLUMA_SELECTED_TEXT
- output = ""
- for line in selected_txt.split("n"):
- line = "#" + line
- output = output + line+ "n"
- return output
- >
- from requests import post # cursor currently here or this line selected
- from collections import defaultdict
- #from requests import post
- from collections import defaultdict
- #from requests import post # both lines selected
- from collections import defaultdict
- from requests import post # both lines selected
- #from collections import defaultdict
- $<
- lines = $PLUMA_SELECTED_TEXT.split("n")
- if lines == ['']:
- # Already commented line ...
- if $PLUMA_CURRENT_LINE.startswith("#"):
- return $PLUMA_CURRENT_LINE[1:]
- else: # ... then uncomment it
- return "#" + $PLUMA_CURRENT_LINE
- else:
- output = "";
- for line in lines:
- if line.startswith("#"):
- output += line[1:] + "n"
- else:
- output += "#" + line + "n"
- return output.rstrip()
- >
- $<
- import re
- def get_lines():
- selected = $PLUMA_SELECTED_TEXT
- if selected:
- return selected
- else:
- return $PLUMA_CURRENT_LINE
- def toggle(selected_txt):
- lines = []
- for line in selected_txt.split("n"):
- if not line:
- lines.append(line)
- continue
- try:
- spaces, content = re.findall(r'^s+|.+', line)
- except:
- spaces = ""
- content = line
- if content.startswith("#"):
- lines.append("{}{}".format(spaces, content[1:]))
- else:
- lines.append("{}#{}".format(spaces, content))
- return "n".join(lines)
- return toggle(get_lines())
- >
Add Comment
Please, Sign In to add comment