MCPcopy Index your code
hub / github.com/dbcli/pgcli / remove_beginning_comments

Function remove_beginning_comments

pgcli/pgexecute.py:27–40  ·  view source on GitHub ↗
(command)

Source from the content-addressed store, hash-verified

25
26
27def remove_beginning_comments(command):
28 # Regular expression pattern to match comments
29 pattern = r"^(/\*.*?\*/|--.*?)(?:\n|$)"
30
31 # Find and remove all comments from the beginning
32 cleaned_command = command
33 comments = []
34 match = re.match(pattern, cleaned_command, re.DOTALL)
35 while match:
36 comments.append(match.group())
37 cleaned_command = cleaned_command[len(match.group()) :].lstrip()
38 match = re.match(pattern, cleaned_command, re.DOTALL)
39
40 return [cleaned_command, comments]
41
42
43def register_typecasters(connection):

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected