SF.net SVN: geany:[4682] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Feb 21 13:23:56 UTC 2010


Revision: 4682
          http://geany.svn.sourceforge.net/geany/?rev=4682&view=rev
Author:   eht16
Date:     2010-02-21 13:23:55 +0000 (Sun, 21 Feb 2010)

Log Message:
-----------
Replace tabs by spaces.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/scripts/create_py_tags.py

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-02-21 13:22:29 UTC (rev 4681)
+++ trunk/ChangeLog	2010-02-21 13:23:55 UTC (rev 4682)
@@ -2,6 +2,7 @@
 
  * scripts/create_py_tags.py:
    Minor fixes.
+   Replace tabs by spaces.
 
 
 2010-02-20 Dominic Hopf <dmaphy(at)googlemail(dot)com>

Modified: trunk/scripts/create_py_tags.py
===================================================================
--- trunk/scripts/create_py_tags.py	2010-02-21 13:22:29 UTC (rev 4681)
+++ trunk/scripts/create_py_tags.py	2010-02-21 13:23:55 UTC (rev 4682)
@@ -36,168 +36,168 @@
 
 class Parser:
 
-	#----------------------------------------------------------------------
-	def __init__(self):
-		self.tags = {}
-		self.re_matcher = re.compile(tag_regexp)
+    #----------------------------------------------------------------------
+    def __init__(self):
+        self.tags = {}
+        self.re_matcher = re.compile(tag_regexp)
 
-	#----------------------------------------------------------------------
-	def _get_superclass(self, _object):
-		"""
-		Python class base-finder
-		(found on http://mail.python.org/pipermail/python-list/2002-November/173949.html)
+    #----------------------------------------------------------------------
+    def _get_superclass(self, _object):
+        """
+        Python class base-finder
+        (found on http://mail.python.org/pipermail/python-list/2002-November/173949.html)
 
-		@param _object (object)
-		@return superclass (object)
-		"""
-		try:
-			#~ TODO print inspect.getmro(c)
-			if type(_object) == types.ClassType:
-				return _object.__bases__[0].__name__
-			else:
-				return _object.__mro__[1].__name__
-		except IndexError:
-			return ''
+        @param _object (object)
+        @return superclass (object)
+        """
+        try:
+            #~ TODO print inspect.getmro(c)
+            if type(_object) == types.ClassType:
+                return _object.__bases__[0].__name__
+            else:
+                return _object.__mro__[1].__name__
+        except IndexError:
+            return ''
 
-	#----------------------------------------------------------------------
-	def _formatargspec(self, args, varargs=None, varkw=None, defaults=None,
-					  formatarg=str,
-					  formatvarargs=lambda name: '*' + name,
-					  formatvarkw=lambda name: '**' + name,
-					  formatvalue=lambda value: '=' + repr(value),
-					  join=inspect.joinseq):
-		"""Format an argument spec from the 4 values returned by getargspec.
+    #----------------------------------------------------------------------
+    def _formatargspec(self, args, varargs=None, varkw=None, defaults=None,
+                      formatarg=str,
+                      formatvarargs=lambda name: '*' + name,
+                      formatvarkw=lambda name: '**' + name,
+                      formatvalue=lambda value: '=' + repr(value),
+                      join=inspect.joinseq):
+        """Format an argument spec from the 4 values returned by getargspec.
 
-		The first four arguments are (args, varargs, varkw, defaults).  The
-		other four arguments are the corresponding optional formatting functions
-		that are called to turn names and values into strings.  The ninth
-		argument is an optional function to format the sequence of arguments."""
-		specs = []
-		if defaults:
-			firstdefault = len(args) - len(defaults)
-		for i in range(len(args)):
-			spec = inspect.strseq(args[i], formatarg, join)
-			if defaults and i >= firstdefault:
-				d = defaults[i - firstdefault]
-				# this is the difference from the original formatargspec() function
-				# to use nicer names then the default repr() output
-				if hasattr(d, '__name__'):
-					d = d.__name__
-				spec = spec + formatvalue(d)
-			specs.append(spec)
-		if varargs is not None:
-			specs.append(formatvarargs(varargs))
-		if varkw is not None:
-			specs.append(formatvarkw(varkw))
-		return ', '.join(specs)
+        The first four arguments are (args, varargs, varkw, defaults).  The
+        other four arguments are the corresponding optional formatting functions
+        that are called to turn names and values into strings.  The ninth
+        argument is an optional function to format the sequence of arguments."""
+        specs = []
+        if defaults:
+            firstdefault = len(args) - len(defaults)
+        for i in range(len(args)):
+            spec = inspect.strseq(args[i], formatarg, join)
+            if defaults and i >= firstdefault:
+                d = defaults[i - firstdefault]
+                # this is the difference from the original formatargspec() function
+                # to use nicer names then the default repr() output
+                if hasattr(d, '__name__'):
+                    d = d.__name__
+                spec = spec + formatvalue(d)
+            specs.append(spec)
+        if varargs is not None:
+            specs.append(formatvarargs(varargs))
+        if varkw is not None:
+            specs.append(formatvarkw(varkw))
+        return ', '.join(specs)
 
-	#----------------------------------------------------------------------
-	def _add_tag(self, obj, tag_type, parent=''):
-		"""
-		Verify the found tag name and if it is valid, add it to the list
+    #----------------------------------------------------------------------
+    def _add_tag(self, obj, tag_type, parent=''):
+        """
+        Verify the found tag name and if it is valid, add it to the list
 
-		@param obj (instance)
-		@param tag_type (str)
-		@param parent (str)
-		"""
-		args = ''
-		scope = ''
-		try:
-			args = apply(self._formatargspec, inspect.getargspec(obj))
-		except (TypeError, KeyError):
-			pass
-		if parent:
-			if tag_type == TYPE_CLASS:
-				args = '(%s)' % parent
-			else:
-				scope = '%s%s' % (TA_SCOPE, parent)
-		tagname = obj.__name__
-		# check for duplicates
-		if len(tagname) < 4:
-			# skip short tags
-			return
-		tag = '%s%s%s%s%s%s\n' % (tagname, TA_TYPE, tag_type, TA_ARGLIST, args, scope)
-		if not tagname in self.tags:
-			self.tags[tagname] = tag
+        @param obj (instance)
+        @param tag_type (str)
+        @param parent (str)
+        """
+        args = ''
+        scope = ''
+        try:
+            args = apply(self._formatargspec, inspect.getargspec(obj))
+        except (TypeError, KeyError):
+            pass
+        if parent:
+            if tag_type == TYPE_CLASS:
+                args = '(%s)' % parent
+            else:
+                scope = '%s%s' % (TA_SCOPE, parent)
+        tagname = obj.__name__
+        # check for duplicates
+        if len(tagname) < 4:
+            # skip short tags
+            return
+        tag = '%s%s%s%s%s%s\n' % (tagname, TA_TYPE, tag_type, TA_ARGLIST, args, scope)
+        if not tagname in self.tags:
+            self.tags[tagname] = tag
 
-	#----------------------------------------------------------------------
-	def process_file(self, filename):
-		"""
-		Read the file specified by filename and look for class and function definitions
+    #----------------------------------------------------------------------
+    def process_file(self, filename):
+        """
+        Read the file specified by filename and look for class and function definitions
 
-		@param filename (str)
-		"""
-		try:
-			module = imp.load_source('tags_file_module', filename)
-		except IOError, e:
-			# file not found
-			print '%s: %s' % (filename, e)
-			return
-		except Exception:
-			module = None
+        @param filename (str)
+        """
+        try:
+            module = imp.load_source('tags_file_module', filename)
+        except IOError, e:
+            # file not found
+            print '%s: %s' % (filename, e)
+            return
+        except Exception:
+            module = None
 
-		if module:
-			symbols = inspect.getmembers(module, callable)
-			for obj_name, obj in symbols:
-				try:
-					name = obj.__name__
-				except AttributeError:
-					name = obj_name
-				if not name or not isinstance(name, basestring) or name.startswith('_'):
-					# skip non-public tags
-					continue
-				if inspect.isfunction(obj):
-					self._add_tag(obj, TYPE_FUNCTION)
-				elif inspect.isclass(obj):
-					self._add_tag(obj, TYPE_CLASS, self._get_superclass(obj))
-					try:
-						methods = inspect.getmembers(obj, inspect.ismethod)
-					except AttributeError:
-						methods = []
-					for m_name, m_obj in methods:
-						# skip non-public tags
-						if m_name.startswith('_') or not inspect.ismethod(m_obj):
-							continue
-						self._add_tag(m_obj, TYPE_FUNCTION, name)
-		else:
-			# plain regular expression based parsing
-			filep = open(filename)
-			for line in filep:
-				m = self.re_matcher.match(line)
-				if m:
-					tag_type_str, tagname, args = m.groups()
-					if not tagname or tagname.startswith('_'):
-						# skip non-public tags
-						continue
-					if tag_type_str == 'class':
-						tag_type = TYPE_CLASS
-					else:
-						tag_type = TYPE_FUNCTION
-					args = args.strip()
-					tag = '%s%s%s%s%s\n' % (tagname, TA_TYPE, tag_type, TA_ARGLIST, args)
-					if not tagname in self.tags:
-						self.tags[tagname] = tag
-			filep.close()
+        if module:
+            symbols = inspect.getmembers(module, callable)
+            for obj_name, obj in symbols:
+                try:
+                    name = obj.__name__
+                except AttributeError:
+                    name = obj_name
+                if not name or not isinstance(name, basestring) or name.startswith('_'):
+                    # skip non-public tags
+                    continue
+                if inspect.isfunction(obj):
+                    self._add_tag(obj, TYPE_FUNCTION)
+                elif inspect.isclass(obj):
+                    self._add_tag(obj, TYPE_CLASS, self._get_superclass(obj))
+                    try:
+                        methods = inspect.getmembers(obj, inspect.ismethod)
+                    except AttributeError:
+                        methods = []
+                    for m_name, m_obj in methods:
+                        # skip non-public tags
+                        if m_name.startswith('_') or not inspect.ismethod(m_obj):
+                            continue
+                        self._add_tag(m_obj, TYPE_FUNCTION, name)
+        else:
+            # plain regular expression based parsing
+            filep = open(filename)
+            for line in filep:
+                m = self.re_matcher.match(line)
+                if m:
+                    tag_type_str, tagname, args = m.groups()
+                    if not tagname or tagname.startswith('_'):
+                        # skip non-public tags
+                        continue
+                    if tag_type_str == 'class':
+                        tag_type = TYPE_CLASS
+                    else:
+                        tag_type = TYPE_FUNCTION
+                    args = args.strip()
+                    tag = '%s%s%s%s%s\n' % (tagname, TA_TYPE, tag_type, TA_ARGLIST, args)
+                    if not tagname in self.tags:
+                        self.tags[tagname] = tag
+            filep.close()
 
-	#----------------------------------------------------------------------
-	def write_to_file(self, filename):
-		"""
-		Sort the found tags and write them into the file specified by filename
+    #----------------------------------------------------------------------
+    def write_to_file(self, filename):
+        """
+        Sort the found tags and write them into the file specified by filename
 
-		@param filename (str)
-		"""
-		result = self.tags.values()
-		# sort the tags
-		result.sort()
-		# write them
-		target_file = open(filename, 'wb')
-		target_file.write(
-			'# format=tagmanager - Automatically generated file - do not edit (created on %s)\n' % \
-			datetime.datetime.now().ctime())
-		for symbol in result:
-			if not symbol == '\n': # skip empty lines
-				target_file.write(symbol)
-		target_file.close()
+        @param filename (str)
+        """
+        result = self.tags.values()
+        # sort the tags
+        result.sort()
+        # write them
+        target_file = open(filename, 'wb')
+        target_file.write(
+            '# format=tagmanager - Automatically generated file - do not edit (created on %s)\n' % \
+            datetime.datetime.now().ctime())
+        for symbol in result:
+            if not symbol == '\n': # skip empty lines
+                target_file.write(symbol)
+        target_file.close()
 
 
 
@@ -233,19 +233,19 @@
 
 
 def main():
-	# process files given on command line
-	args = sys.argv[1:]
-	if not args:
-		args = default_files
+    # process files given on command line
+    args = sys.argv[1:]
+    if not args:
+        args = default_files
 
-	parser = Parser()
+    parser = Parser()
 
-	for filename in args:
-		parser.process_file(filename)
+    for filename in args:
+        parser.process_file(filename)
 
-	parser.write_to_file(tag_filename)
+    parser.write_to_file(tag_filename)
 
 
 if __name__ == '__main__':
-	main()
+    main()
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list