2012-05-09 12:14:25 +02:00
|
|
|
# coding: utf-8
|
|
|
|
#
|
2013-04-05 14:15:56 +02:00
|
|
|
# Copyright © 2012-2013 Ejwa Software. All rights reserved.
|
2012-05-09 12:14:25 +02:00
|
|
|
#
|
|
|
|
# This file is part of gitinspector.
|
|
|
|
#
|
|
|
|
# gitinspector is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# gitinspector is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-05-06 11:44:27 +02:00
|
|
|
__comment_begining__ = {"java": "/*", "c": "/*", "cpp": "/*", "h": "/*", "hpp": "/*", "html": "<!--", "py": "\"\"\"",
|
|
|
|
"glsl": "/*", "rb": "=begin", "js": "/*", "sql": "/*", "xml": "<!--"}
|
2012-05-09 12:14:25 +02:00
|
|
|
|
2013-05-06 11:44:27 +02:00
|
|
|
__comment_end__ = {"java": "*/", "c": "*/", "cpp": "*/", "h": "*/", "hpp": "*/", "html": "-->", "py": "\"\"\"",
|
|
|
|
"glsl": "*/", "rb": "=end", "js": "*/", "sql": "*/", "xml": "-->"}
|
2012-05-09 12:14:25 +02:00
|
|
|
|
2013-05-06 11:36:04 +02:00
|
|
|
__comment__ = {"java": "//", "c": "//", "cpp": "//", "h": "//", "hpp": "//", "pl": "#", "py": "#", "glsl": "//",
|
2012-05-09 12:14:25 +02:00
|
|
|
"rb": "#", "js": "//", "sql": "--"}
|
|
|
|
|
2012-05-16 01:49:23 +02:00
|
|
|
def is_comment(extension, string):
|
2012-05-16 04:14:48 +02:00
|
|
|
if __comment_begining__.get(extension, None) != None and string.strip().startswith(__comment_begining__[extension]):
|
2012-05-16 01:49:23 +02:00
|
|
|
return True
|
2012-05-16 04:14:48 +02:00
|
|
|
if __comment_end__.get(extension, None) != None and string.strip().endswith(__comment_end__[extension]):
|
2012-05-16 01:49:23 +02:00
|
|
|
return True
|
|
|
|
if __comment__.get(extension, None) != None and string.strip().startswith(__comment__[extension]):
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def has_comment_begining(extension, string):
|
2012-05-16 04:14:48 +02:00
|
|
|
if __comment_begining__.get(extension, None) != None and string.find(__comment_end__[extension], 2) == -1:
|
2012-05-16 01:49:23 +02:00
|
|
|
return string.find(__comment_begining__[extension]) != -1
|
2012-05-09 12:14:25 +02:00
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
2012-05-16 01:49:23 +02:00
|
|
|
def has_comment_end(extension, string):
|
2012-05-09 12:14:25 +02:00
|
|
|
if __comment_end__.get(extension, None) != None:
|
2012-05-16 01:49:23 +02:00
|
|
|
return string.find(__comment_end__[extension]) != -1
|
2012-05-09 12:14:25 +02:00
|
|
|
else:
|
|
|
|
return False
|