Example #1
0
	def get_nodes_from_scratch(self, stratch):
		modules = {}

		for module in utility.get_all_subclasses(Plugin):
			name = module.__name__
			modules[name] = module

		return modules
Example #2
0
    def get_nodes_from_scratch(self, stratch):
        modules = {}

        for module in utility.get_all_subclasses(Plugin):
            name = module.__name__
            modules[name] = module

        return modules
Example #3
0
	def on_message(self, bot, source, target, trigger, argument):
		m = re.search('^(\w*)\.?(\w*)\.?(\w*)\(?(.*?)\)?$', argument)

		if m:
			module_name, option_name, method_name, method_args = m.group(1, 2, 3, 4)

			name = ''
		
			modules = self.get_members_by_name(self._table.keys(), module_name)
			if not len(module_name) or len(modules) > 1:
				return "Choose a module: %s." % ", ".join(modules) 
			elif len(modules) == 1:
				module_name = modules[0]
				module = self._table[module_name]
				name = module_name

				plugin = None

				for p in utility.get_all_subclasses(Plugin):
					if p.__name__ == module_name:
						plugin = p.instance
						break
				
				options = self.get_members_by_name(module, option_name)
				if not len(option_name) or len(options) > 1:
					return "You're at: %s. Choose an option: %s." % (name, ", ".join(options))
				elif len(options) == 1:
					option_name = options[0]
					option = module[option_name]
					obj = plugin.__getattribute__(option_name)
					name += '.' + option_name

					methods = self.get_members_by_name(option, method_name)
					if not len(method_name) or len(methods) > 1:
						return 'You\'re at: ' + name + '. Choose a method: ' + ', '.join(methods) + '.'
					elif len(methods) == 1:
						method_name = methods[0]
						method = option[method_name]

						if method == self.dict_print or method == self.list_print:
							return 'Contents of \'' + option_name + '\': ' + method(obj) + '.'
						elif method == self.dict_assign:
							m = re.search('^\s*\'?"?(.+?)\'?"?,\s*\'?"?(.+?)\'?"?\s*$', method_args)
							if m:
								a = m.groups()
								#return 'args: |' + a[0] + '|' + a[1] + '|')
								method(obj, a[0], a[1])
								return 'All done, as far as I know.'
							else:
								return 'Couldn\'t parse argument(s).'
						else:
							m = re.search('^\s*\'?"?(.+?)\'?"?\s*$', method_args)
							if m:
								a = m.groups()
	
								method(obj, a[0])
								return 'All done, as far as I know.'
							else:
								return 'Couldn\'t parse argument(s).'

						plugin.on_modified_options()

					else:
						return 'Couldn\'t find method \'' + method_name + '\' in ' + name + '.'
				else:
					return 'Couldn\'t find option \'' + option_name + '\' in ' + name + '.'
			else:
				return 'Couldn\'t find module \'' + module_name + '\'.'
Example #4
0
    def on_message(self, bot, source, target, trigger, argument):
        m = re.search('^(\w*)\.?(\w*)\.?(\w*)\(?(.*?)\)?$', argument)

        if m:
            module_name, option_name, method_name, method_args = m.group(
                1, 2, 3, 4)

            name = ''

            modules = self.get_members_by_name(self._table.keys(), module_name)
            if not len(module_name) or len(modules) > 1:
                return "Choose a module: %s." % ", ".join(modules)
            elif len(modules) == 1:
                module_name = modules[0]
                module = self._table[module_name]
                name = module_name

                plugin = None

                for p in utility.get_all_subclasses(Plugin):
                    if p.__name__ == module_name:
                        plugin = p.instance
                        break

                options = self.get_members_by_name(module, option_name)
                if not len(option_name) or len(options) > 1:
                    return "You're at: %s. Choose an option: %s." % (
                        name, ", ".join(options))
                elif len(options) == 1:
                    option_name = options[0]
                    option = module[option_name]
                    obj = plugin.__getattribute__(option_name)
                    name += '.' + option_name

                    methods = self.get_members_by_name(option, method_name)
                    if not len(method_name) or len(methods) > 1:
                        return 'You\'re at: ' + name + '. Choose a method: ' + ', '.join(
                            methods) + '.'
                    elif len(methods) == 1:
                        method_name = methods[0]
                        method = option[method_name]

                        if method == self.dict_print or method == self.list_print:
                            return 'Contents of \'' + option_name + '\': ' + method(
                                obj) + '.'
                        elif method == self.dict_assign:
                            m = re.search(
                                '^\s*\'?"?(.+?)\'?"?,\s*\'?"?(.+?)\'?"?\s*$',
                                method_args)
                            if m:
                                a = m.groups()
                                #return 'args: |' + a[0] + '|' + a[1] + '|')
                                method(obj, a[0], a[1])
                                return 'All done, as far as I know.'
                            else:
                                return 'Couldn\'t parse argument(s).'
                        else:
                            m = re.search('^\s*\'?"?(.+?)\'?"?\s*$',
                                          method_args)
                            if m:
                                a = m.groups()

                                method(obj, a[0])
                                return 'All done, as far as I know.'
                            else:
                                return 'Couldn\'t parse argument(s).'

                        plugin.on_modified_options()

                    else:
                        return 'Couldn\'t find method \'' + method_name + '\' in ' + name + '.'
                else:
                    return 'Couldn\'t find option \'' + option_name + '\' in ' + name + '.'
            else:
                return 'Couldn\'t find module \'' + module_name + '\'.'