Permalink
Browse files

Perl+python: add arguments help text.

  • Loading branch information...
1 parent dcf105a commit d56c4437156fde7973332d570423327733535589 @DarthGandalf DarthGandalf committed Aug 26, 2012
Showing with 21 additions and 20 deletions.
  1. +8 −9 modules/modperl/startup.pl
  2. +13 −11 modules/modpython/znc.py
@@ -144,15 +144,7 @@ sub GetModInfo {
ZNC::CModules::FindModPath("$modname.pm", $modpath, $datapath) or return ($ZNC::Perl_NotFound, "Unable to find module [$modname]");
$modpath = $modpath->GetPerlStr;
return ($ZNC::Perl_LoadError, "Incorrect perl module.") unless IsModule $modpath, $modname;
- require $modpath;
- my $pmod = bless {}, $modname;
- my @types = $pmod->module_types;
- $modinfo->SetDefaultType($types[0]);
- $modinfo->SetDescription($pmod->description);
- $modinfo->SetWikiPage($pmod->wiki_page);
- $modinfo->SetName($modname);
- $modinfo->SetPath($modpath);
- $modinfo->AddType($_) for @types;
+ ModInfoByPath($modpath, $modname, $modinfo);
return ($ZNC::Perl_Loaded)
}
@@ -165,6 +157,8 @@ sub ModInfoByPath {
$modinfo->SetDefaultType($types[0]);
$modinfo->SetDescription($pmod->description);
$modinfo->SetWikiPage($pmod->wiki_page);
+ $modinfo->SetArgsHelpText($pmod->args_help_text);
+ $modinfo->SetHasArgs($pmod->has_args);
$modinfo->SetName($modname);
$modinfo->SetPath($modpath);
$modinfo->AddType($_) for @types;
@@ -291,6 +285,11 @@ sub module_types {
$ZNC::CModInfo::NetworkModule
}
+sub args_help_text { '' }
+
+sub has_args { 0 }
+
+
# Default implementations for module hooks. They can be overriden in derived modules.
sub OnLoad {1}
sub OnBoot {}
@@ -154,6 +154,9 @@ class Module:
wiki_page = ''
+ has_args = False
+ args_help_text = ''
+
def __str__(self):
return self.GetModName()
@@ -575,6 +578,14 @@ def unload_all():
unload_module(mod)
+def gather_mod_info(cl, modinfo):
+ modinfo.SetDescription(cl.description)
+ modinfo.SetWikiPage(cl.wiki_page)
+ modinfo.SetDefaultType(cl.module_types[0])
+ for module_type in cl.module_types:
+ modinfo.AddType(module_type)
+
+
def get_mod_info(modname, retmsg, modinfo):
'''0-not found, 1-error, 2-success'''
pymodule, datadir = find_open(modname)
@@ -585,13 +596,9 @@ def get_mod_info(modname, retmsg, modinfo):
pymodule.__file__, modname)
return 1
cl = pymodule.__dict__[modname]
- modinfo.SetDefaultType(cl.module_types[0])
- for module_type in cl.module_types:
- modinfo.AddType(module_type)
- modinfo.SetDescription(cl.description)
- modinfo.SetWikiPage(cl.wiki_page)
modinfo.SetName(modname)
modinfo.SetPath(pymodule.__file__)
+ gather_mod_info(cl, modinfo)
return 2
@@ -616,14 +623,9 @@ def get_mod_info_path(path, modname, modinfo):
if modname not in pymodule.__dict__:
return 0
cl = pymodule.__dict__[modname]
- modinfo.SetDescription(cl.description)
- modinfo.SetWikiPage(cl.wiki_page)
modinfo.SetName(modname)
modinfo.SetPath(pymodule.__file__)
- modinfo.SetDefaultType(cl.module_types[0])
- for module_type in cl.module_types:
- modinfo.AddType(module_type)
-
+ gather_mod_info(cl, modinfo)
return 1

0 comments on commit d56c443

Please sign in to comment.