Github user kaknikhil commented on a diff in the pull request:

    https://github.com/apache/madlib/pull/271#discussion_r191587596
  
    --- Diff: src/madpack/madpack.py ---
    @@ -131,10 +141,73 @@ def _get_relative_maddir(maddir, port):
             return maddir
     # 
------------------------------------------------------------------------------
     
    +def _cleanup_comments_in_sqlfile(output_filename, upgrade):
    +    """
    +    @brief Remove comments in the sql script
    +    """
    +    if not upgrade:
    +        with open(output_filename, 'r+') as output_filehandle:
    +            full_sql = output_filehandle.read()
    +            pattern = 
re.compile(r"""(/\*(.|[\r\n])*?\*/)|(--(.*|[\r\n]))""")
    +            res = ''
    +            lines = re.split(r'[\r\n]+', full_sql)
    +            for line in lines:
    +                tmp = line
    +                if not tmp.strip().startswith("E'"):
    +                    line = re.sub(pattern, '', line)
    +                res += line + '\n'
    +            full_sql = res.strip()
    +            full_sql = re.sub(pattern, '', full_sql).strip()
    +        # Re-write the cleaned-up sql to a new file. Python does not let us
    --- End diff --
    
    can we move the new file creation and the renaming logic to a different 
function? This way the function will have a single responsibility of just 
cleaning the input.
    



---

Reply via email to