This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lua_getglobal(L, "plugins"); | |
lua_pushnil(L); | |
string pname; | |
bool loaded = false; | |
while (lua_next(L, -2) != 0) { | |
/* key is at -2, value at -1 */ | |
if (lua_isstring(L, -2)) { | |
pname = lua_tostring(L, -2); | |
if (pname == name) { | |
loaded = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; This is a comment | |
# This is also a comment | |
; This is a variable defined outside a section, | |
; you can access _these_ by using section name "DEFAULT" | |
; (Note: "DEFAULT" doesn't appear when you use ConfigParser.sections();) | |
foo = bar | |
[ freenode ] ;This is a section, leading/trailing whitespace trimmed, always enclosed by [ ] | |
host = irc.freenode.net ;This is a unquoted variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* main.cxx | |
* | |
* Copyright 2011 FurryHead <[email protected]> | |
* | |
* ConfigParser 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 2 of the License, or | |
* (at your option) any later version. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* configparser.hxx | |
* | |
* Copyright 2011 FurryHead <[email protected]> | |
* | |
* ConfigParser 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 2 of the License, or | |
* (at your option) any later version. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* configparser.cxx | |
* | |
* Copyright 2011 FurryHead <[email protected]> | |
* | |
* ConfigParser 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 2 of the License, or | |
* (at your option) any later version. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(str): | |
def __new__(cls, user): | |
if getattr(user, "nick", None) is not None: | |
cls.nick = user.nick | |
cls.ident = user.ident | |
cls.host = user.host | |
else: | |
if re.match(".+!.+@.+", user): | |
cls.nick = user.split("!")[0] | |
cls.ident = user.split("!")[1].split("@")[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import inspect | |
import ctypes | |
def _async_raise(tid, exctype): | |
"""raises the exception, performs cleanup if needed""" | |
if not inspect.isclass(exctype): | |
raise TypeError("Only types can be raised (not instances)") | |
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
class TimeoutException(Exception): | |
pass | |
class TimeoutThread(threading.Thread): | |
def run(self): | |
def timeout_handler(signum, frame): | |
raise TimeoutException() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, new | |
modules = { } | |
def loadModule(moduleName, locals_dict={}): | |
""" | |
Imports a module without using the built-in import functions. | |
Parameters: | |
moduleName - The name of the module, same as if you were using __import__ or import |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, inspect, collections | |
pList = { } | |
mList = collections.defaultdict(list) | |
class NoSuchPluginError(Exception): pass | |
def plugin(cls): | |
#Using inspect, figure out what file is calling this function (using @plugin) | |
clsFile = inspect.stack()[1][1] |