(self, sql)
Parse SQL meta-comments.
Parse SQL meta-comments.
Parse SQL meta - comments .
def parse_sql(self, sql):
        """Parse SQL meta-comments."""

        cur_key = None
        cur_continued = False
        lineno = 1
        for nr, ln in enumerate(sql.splitlines()):
            lineno = nr+1

            # skip empty lines
            ln = ln.strip()
            if not ln:
                continue

            # stop at non-comment
            if ln[:2] != '--':
                break

            # parse only meta-comments
            if ln[:len(META_PREFIX)] != META_PREFIX:
                continue

            # cut prefix, skip empty comments
            ln = ln[len(META_PREFIX):].strip()
            if not ln:
                continue

            # continuation of previous key
            if cur_continued:
                # collect values
                for v in ln.split(','):
                    v = v.strip()
                    if not v:
                        continue
                    self.add_value(cur_key, v)

                # does this key continue?
                if ln[-1] != ',':
                    cur_key = None
                    cur_continued = False

                # go to next line
                continue
            
            # parse key
            pos = ln.find(':')
            if pos < 0:
                continue
            k = ln[:pos].strip()

            # collect values
            for v in ln[pos+1:].split(','):
                v = v.strip()
                if not v:
                    continue
                self.add_value(k, v)

            # check if current key values will continue
            if ln[-1] == ',':
                cur_key = k
                cur_continued = True
            else:
                cur_key = None
                cur_continued = False
def parse_sql ( self , sql ) : cur_key = None cur_continued = False lineno = 1 for nr , ln in enumerate ( sql . splitlines ( ) ) : lineno = nr + 1 # skip empty lines ln = ln . strip ( ) if not ln : continue # stop at non-comment if ln [ : 2 ] != '--' : break # parse only meta-comments if ln [ : len ( META_PREFIX ) ] != META_PREFIX : continue # cut prefix, skip empty comments ln = ln [ len ( META_PREFIX ) : ] . strip ( ) if not ln : continue # continuation of previous key if cur_continued : # collect values for v in ln . split ( ',' ) : v = v . strip ( ) if not v : continue self . add_value ( cur_key , v ) # does this key continue? if ln [ - 1 ] != ',' : cur_key = None cur_continued = False # go to next line continue # parse key pos = ln . find ( ':' ) if pos < 0 : continue k = ln [ : pos ] . strip ( ) # collect values for v in ln [ pos + 1 : ] . split ( ',' ) : v = v . strip ( ) if not v : continue self . add_value ( k , v ) # check if current key values will continue if ln [ - 1 ] == ',' : cur_key = k cur_continued = True else : cur_key = None cur_continued = False