def help(obj=None): if not obj: print """Welcome to Abrupt! If this is your first time using Abrupt, you should check the quickstart at http://securusglobal.github.com/abrupt/. Here are the basic functions of Abrupt, type 'help(function)' for a complete description of these functions: * proxy: Start a HTTP proxy on port 8080. * create: Create a HTTP request based on a URL. * inject: Inject or fuzz a request. Abrupt have few classes which worth having a look at, typing 'help(class)': * Request * Response * RequestSet There are also few interesting global objects, 'help(object)': * conf * history Please, report any bug or comment to [email protected]""" else: pydoc.help(obj)
def test_resolve_false(self): # Issue #23008: pydoc enum.{,Int}Enum failed # because bool(enum.Enum) is False. with captured_stdout() as help_io: pydoc.help('enum.Enum') helptext = help_io.getvalue() self.assertIn('class Enum', helptext)
def output_help_to_file(filepath, request): f = file(filepath, 'w') sys.stdout = f pydoc.help(request) f.close() sys.stdout = sys.__stdout__ return
def help(obj, visualization=False, ansi=True): """ Extended version of the built-in help that supports parameterized functions and objects. If ansi is set to False, all ANSI color codes are stripped out. """ ansi_escape = re.compile(r'\x1b[^m]*m') parameterized_object = isinstance(obj, param.Parameterized) parameterized_class = (isinstance(obj,type) and issubclass(obj,param.Parameterized)) if parameterized_object or parameterized_class: if Store.registry.get(obj if parameterized_class else type(obj), False): if visualization is False: print("\nTo view the visualization options applicable to this object or class, use:\n\n" " holoviews.help(obj, visualization=True)\n") else: Store.info(obj, ansi=ansi) return info = param.ipython.ParamPager()(obj) if ansi is False: info = ansi_escape.sub('', info) print(info) else: pydoc.help(obj)
def usage(): if __name__ == '__main__': import pydoc #FIXME: literally displayed '__main__' print pydoc.help(__name__) else: help(str(os.path.basename(sys.argv[0]).split('.')[0]))
def test_dispatch_method_class_help(capsys): pydoc.help(Foo) out, err = capsys.readouterr() assert rstrip_lines(out) == """\ Help on class Foo in module reg.tests.fixtures.module: class Foo({builtins}.object) | Class for foo objects. | | Methods defined here: | | bar(self, obj) | Return the bar of an object. | | baz(self, obj) | Return the baz of an object. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) """.format(builtins=object.__module__)
def test_namedtuple_public_underscore(self): NT = namedtuple("NT", ["abc", "def"], rename=True) with captured_stdout() as help_io: pydoc.help(NT) helptext = help_io.getvalue() self.assertIn("_1", helptext) self.assertIn("_replace", helptext) self.assertIn("_asdict", helptext)
def test_namedtuple_public_underscore(self): NT = namedtuple('NT', ['abc', 'def'], rename=True) with captured_stdout() as help_io: pydoc.help(NT) helptext = help_io.getvalue() self.assertIn('_1', helptext) self.assertIn('_replace', helptext) self.assertIn('_asdict', helptext)
def output_help_to_file(request): filepath = request + "_package_info.txt" f = file(filepath, 'w') sys.stdout = f pydoc.help(request) f.close() sys.stdout = sys.__stdout__ return
def _help(*args): # because of how the console works. we need our own help() pager func. # replace the bold function because it adds crazy chars import pydoc pydoc.getpager = lambda: pydoc.plainpager pydoc.Helper.getline = lambda self, prompt: None pydoc.TextDoc.use_bold = lambda self, text: text pydoc.help(*args)
def test_pydoc_gitr(capsys): """ Verify the behavior of running 'pydoc gitr' """ pytest.dbgfunc() pydoc.help(gitr) o, e = capsys.readouterr() z = docopt_exp() for k in z: assert k in o
def main(): f = Foo(4) assert(f.value2 == 8) f.value2 = 5 # This will override value2() method assert(f.value2 == 5) assert(f.value3 == 4) f.value3 = 6 assert(f.value3 == 6) print help(Foo) del(f.value3) print "Success." return 0
def help(self, *args, **kwargs): """Print Automate help if no parameter is given. Otherwise, act as pydoc.help()""" if len(args) > 0 or len(kwargs) > 0: import pydoc pydoc.help(*args, **kwargs) else: hstr = helpstr for i in hstr.split("\n"): self.logger.info(i) return True
def main(): """ Usage: pyXPad [opt] output Argument: output: Base name for the output file. Image number and extension will be append. Ex: #python pyXPad data/Test #ls data/Test* data/Test_0000.edf Options: -c: Load calibration files. Calibration file names are defined in pyXPad_conf.py -n: Number of images to be taken. -e: Exposure time in us. -l: Latency time in us (minimum 5000 us). -o: Overflow counter pull period (minimum 4000 us). -t: Trigger mode. 0: Internal trigger 1: External gate 2: External trigger for sequence 3: External trigger for singles -a: Analog output mode. 0: Bussy 1: Bussy - Shutter time 2: Image read enabled 3: Overflow counter pull 4: Exposure 5: Reserved 6: Image transfer 7: FIFO full 8: External Gate 9: Reserved Press "q" to exit """ import getopt, sys import pydoc import time from EdfFile import EdfFile as EDF try: opts, args = getopt.getopt(sys.argv[1:], "cn:t:a:e:l:o:") except getopt.GetoptError, err: # print help information and exit: pydoc.help(main) sys.exit(2)
def help(*objects): """Print doc strings for object(s). Usage: >>> help(object, [obj2, objN]) (brackets mean [optional] argument) """ if len(objects) == 0: help(help) return for obj in objects: try: print('****', obj.__name__ , '****') print(obj.__doc__) except AttributeError: print(obj, 'has no __doc__ attribute') print()
def get_help(self, topic): title = text = None if topic is not None: import pydoc pydoc.help(topic) rv = sys.stdout.reset().decode('utf-8', 'ignore') paragraphs = _paragraph_re.split(rv) if len(paragraphs) > 1: title = paragraphs[0] text = '\n\n'.join(paragraphs[1:]) else: title = 'Help' text = paragraphs[0] return render_template('help_command.html', title=title, text=text)
def __call__(self, topic=None): if topic is None: sys.stdout._write('<span class="help">%s</span>' % repr(self)) return import pydoc pydoc.help(topic) rv = text_(sys.stdout.reset(), 'utf-8', 'ignore') paragraphs = _paragraph_re.split(rv) if len(paragraphs) > 1: title = paragraphs[0] text = '\n\n'.join(paragraphs[1:]) else: # pragma: no cover title = 'Help' text = paragraphs[0] sys.stdout._write(HELP_HTML % {'title': title, 'text': text})
def __call__(self, topic=None): title = text = None if topic is not None: import pydoc pydoc.help(topic) rv = sys.stdout.reset().decode('utf-8', 'ignore') paragraphs = _paragraph_re.split(rv) if len(paragraphs) > 1: title = paragraphs[0] text = '\n\n'.join(paragraphs[1:]) else: # pragma: no cover title = 'Help' text = paragraphs[0] rv = render_template('help_command.html', title=title, text=text) sys.stdout._write(rv)
def init(): # for PythonExtensions Help File PythonHelp = 0 # doesn't work on systems which haven't installed Python # dump Civ python module directory if PythonHelp: import CvPythonExtensions helpFile=file("CvPythonExtensions.hlp.txt", "w") sys.stdout=helpFile import pydoc pydoc.help(CvPythonExtensions) helpFile.close() sys.stderr=CvUtil.RedirectError() sys.excepthook = CvUtil.myExceptHook sys.stdout=CvUtil.RedirectDebug()
def __call__(self, *args, **kwds): if args and args[0]==self.socialite: print self.socialiteHelp return import pydoc return pydoc.help(*args, **kwds)
def __call__(self, *args, **kwds): if args and args[0]==self.socialite: print self.socialite.__doc__ return elif args and args[0]==self.socialiteExamples: print self.socialite.examples return import pydoc return pydoc.help(*args, **kwds)
def helpCli(self, command=None): ''' Prints helpful information help - list all register CLI command help [command] - prints the docstring help for that command''' if command and command in self.clis: import pydoc pydoc.help(self.clis[command]) #Why does this not work? help(self.clis[command]) else: print 'Usage: %s [command]\n' % os.path.split(sys.argv[0])[-1] print 'Supported commands:' commandWidth = max(map(len, self.clis.keys())) commandWidth = min(commandWidth, 20) #20 is the most I'm willing to sacrifice for cli in self.clis: help = getattr(self.clis[cli], 'help', 'No help provided') print textwrap.fill(('{:<%d} - {}' % commandWidth).format(cli, help), width=getTerminalSize()[0]-1, subsequent_indent=' '*(commandWidth+3)) print '\nFor docstring on a particular command' print '\t%s help [command]' % os.path.split(sys.argv[0])[-1] return 0
def help(obj, visualization=True, ansi=True, backend='matplotlib', recursive=False, pattern=None): """ Extended version of the built-in help that supports parameterized functions and objects. A pattern (regular expression) may be used to filter the output and if recursive is set to True, documentation for the supplied object is shown. Note that the recursive option will only work with an object instance and not a class. If ansi is set to False, all ANSI color codes are stripped out. """ info = Store.info(obj, ansi=ansi, backend=backend, visualization=visualization, recursive=recursive, pattern=pattern) msg = ( "\nTo view the visualization options applicable to this " "object or class, use:\n\n" " holoviews.help(obj, visualization=True)\n\n") if info: print((msg if visualization is False else '') + info) else: pydoc.help(obj)
def help(obj=None): if not obj: print """Welcome to Burst! Here are the basic functions of Burst, type 'help(function)' for a complete description of these functions: * proxy: Start a HTTP proxy (port 8080 by default). * create: Create a HTTP request based on a URL. * inject: Inject or fuzz a request. Burst have few classes which worth having a look at, typing 'help(class)': * Request * Response * RequestSet There are also few interesting global objects, 'help(object)': * conf * history Please, report any bug or comment to [email protected]""" else: pydoc.help(obj)
def __call__(self, *args, **kwds): class DummyWriter(object): def __init__(self,pager): self._pager = pager def write(self,data): self._pager(data) import pydoc pydoc.help.output = DummyWriter(self._pager) pydoc.help.interact = lambda :1 return pydoc.help(*args, **kwds)
def _get_help(self, s, imports=None): """Return string printed by help function.""" if not s: return '' if s == 'pydoc.help': # Prevent pydoc from going into interactive mode s = 'pydoc.Helper' obj = None if not keyword.iskeyword(s): try: self._import_modules(imports) obj = self._load_symbol(s, strict=False) except Exception as ex: return '%s' % ex if not obj: obj = str(s) out = self._helpout() try: sys.stdout = out pydoc.help(obj) finally: sys.stdout = self._stdout return out.getvalue()
def __call__(self, *args, **kwds): class DummyWriter(object): '''Dumy class to handle help output''' def __init__(self, pager): self._pager = pager def write(self, data): '''hook to fill self._pager''' self._pager(data) import pydoc pydoc.help.output = DummyWriter(self._pager) pydoc.help.interact = lambda :1 return pydoc.help(*args, **kwds)
def help_replacement(self, text=None, interactive=False): """For help builtin function emulation""" if text is not None and not interactive: return pydoc.help(text) elif text is None: pyver = "%d.%d" % (sys.version_info[0], sys.version_info[1]) self.write(""" Welcome to Python %s! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://www.python.org/doc/tut/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". """ % pyver) else: text = text.strip() try: eval("pydoc.help(%s)" % text) except (NameError, SyntaxError): print "no Python documentation found for '%r'" % text self.write(os.linesep) self.widget_proxy.new_prompt("help> ") inp = self.raw_input_replacement() if inp.strip(): self.help_replacement(inp, interactive=True) else: self.write(""" You are now leaving help and returning to the Python interpreter. If you want to ask for help on a particular object directly from the interpreter, you can type "help(object)". Executing "help('string')" has the same effect as typing a particular string at the help> prompt. """)
def __call__(self, request=None): """ Executes either man page for LMIShell or prints pydoc help for an object. """ if request is None: try: # Python 3+ from subprocess import DEVNULL as devnull devnull_close = lambda: None except ImportError: devnull = open(os.devnull, "wb") devnull_close = lambda: devnull.close() rcode = subprocess.call(["man", "lmishell"], stderr=devnull) devnull_close() if rcode > 0: sys.stderr.write("Man page for lmishell can not be found, ") sys.stderr.write("refer to official documentation.\n\n") sys.stderr.write("Available at: http://www.openlmi.org\n") else: import pydoc return pydoc.help(request)
pass # print i test_dbl_prop = fbx.FbxProperty.Create(test_node, fbx.FbxDoubleDT, "testDoubleProperty") test_dbl_prop.ModifyFlag(fbx.FbxPropertyFlags.eUserDefined, True) test_dbl_prop.ModifyFlag(fbx.FbxPropertyFlags.eAnimatable, True) print test_dbl_prop.Set(16.0) for i in dir(FbxCommon): pass # print i import sys import pydoc filepath = r"C:\Users\Bren\Desktop\tests\fbx_help.txt" f = open(filepath, 'w') sys.stdout = f pydoc.help(fbx) f.close() sys.stdout = sys.__stdout__ # # listener.Bind( # test_node, # fbx # )
def help(self): """ Description of the class and the methods. """ return help(VSM)
def makefile(self): file = open('test.txt', 'w+') sys.stdout = file pydoc.help('modules') sys.stdout = sys.__stdout__ file.close()
import pandas as pd import numpy as np import matplotlib.pyplot as plt wcat=pd.read_csv("C:\\Users\\mozak\\Desktop\\ExcelR\\Assigments\\Simple Linear Regression\\Python\\calories_consumed.csv") plt.scatter(x=wcat.Calories_Consumed,y=wcat.Weight_gained,color='green') help(np.corrcoef) wcat.describe() import statsmodels.formula.api as smf model = smf.ols('Weight_gained~Calories_Consumed',data=wcat).fit() model.params model model.summary() pred=model.predict(wcat.iloc[:,0]) print(model.conf_int(0.01))# cnfudence intervaal of 99% res=wcat.Weight_gained-pred res from sklearn.metrics import mean_squared_error from math import sqrt rmse = sqrt(mean_squared_error(wcat.Weight_gained, pred)) rmse ------------------------------------------- ####x= log(Calories_Consumed) , y = Weight_gained######
# possible mismatches, checks if present at all and then if equal # HTTP + XML if encinfo.http_encoding and encinfo.xml_encoding and\ encinfo.http_encoding != encinfo.xml_encoding: encinfo.mismatch = True log.warn(u'"%s" (HTTP) != "%s" (XML) encoding mismatch' % (encinfo.http_encoding, encinfo.xml_encoding)) # HTTP + Meta if encinfo.http_encoding and encinfo.meta_encoding and\ encinfo.http_encoding != encinfo.meta_encoding: encinfo.mismatch = True log.warn(u'"%s" (HTTP) != "%s" (HTML <meta>) encoding mismatch' % (encinfo.http_encoding, encinfo.meta_encoding)) # XML + Meta if encinfo.xml_encoding and encinfo.meta_encoding and\ encinfo.xml_encoding != encinfo.meta_encoding: encinfo.mismatch = True log.warn(u'"%s" (XML) != "%s" (HTML <meta>) encoding mismatch' % (encinfo.xml_encoding, encinfo.meta_encoding)) log.info(u'Encoding (probably): %s (Mismatch: %s)', encinfo.encoding, encinfo.mismatch) encinfo.logtext = logstream.getvalue() return encinfo if __name__ == '__main__': import pydoc pydoc.help(__name__)
self.Alias('figs', paper + '.figs') self.Default('pdf') default = TeXPaper() def Dir(**kw): return apply(default.Dir, [], kw) def Paper(paper, source='', **kw): return apply(default.Paper, (paper, source), kw) def Command2(target, source, command): return default.Command(target, source, command) def End(paper='paper', source='', **kw): return apply(default.End, (paper, source), kw) def Depends2(target, source): return default.Depends(target, source) if __name__ == "__main__": import pydoc pydoc.help(TeXPaper)
# self._loggraph[current]['data'].append(record) # code around cases where columns merge together... for j in range(len(data)): record = data[j].split() if len(record) == columns: self._loggraph[current]['data'].append(record) return self._loggraph return CCP4Decorator() if __name__ == '__main__': if not os.environ.has_key('XIA2CORE_ROOT'): raise RuntimeError, 'XIA2CORE_ROOT not defined' sys.path.append( os.path.join(os.environ['XIA2CORE_ROOT'], 'Python', 'Driver')) from DriverFactory import DriverFactory d = DriverFactory.Driver('script') d = CCP4DecoratorFactory(d) from pydoc import help print help(d.__class__)
def __call__(self, *args, **kwds): import pydoc return pydoc.help(*args, **kwds)
def __call__(self, *args, **kwargs): return pydoc.help(*args, **kwargs)
self.dprint("current frame %s" % inspect.currentframe()) #self.dprint ("stack %s " % inspect.stack()) stacklist = inspect.stack(5) for indx in range(len(stacklist)): val = stacklist[indx] self.indent() for indx in range(len(val)): self.dprint(val[indx]) self.dedent() self.dprint("trace %s " % inspect.trace()) self.dedent() ########################################### # Main Routine ########################################## if __name__ == "__main__": import sys module = ModuleShow() if len(sys.argv) < 2: module.list_allmodules() sys.exit() if ((len(sys.argv) > 2) and (sys.argv[2] == "help")): pydoc.help(sys.argv[1]) sys.exit() module.describe(sys.argv[1])
def usage(): """ This code contains methods to perform performance tests of block devices, e.g. hard disks. It also allows using files rather than devices directly. Synopsis: diskTest.py [-d device] [-s skip] [-t testcount] [-i iosize] [-b blocksize] [-c {b|z|c}] [-f file] [-m] [-w] [-l] [-o] [-p] [-h] long arguments are allowed as well, e.g. --device [d]evice: string, e.g. /dev/hdb1, can also be a file or a url (for http disk write). If the first four characters are /dev a number of additional checks are performed before writing to the raw device. [s]kip: integer [0 GB], e.g. 5 [t]estcount: integer [1], number of consecutive tests [1] [i]osize: integer [1073741824 bytes == 1 GB], full size of one test, i.e. iosize/blocksize IOs will be carried out before calculating statistics. [b]locksize: integer [1024 bytes], number of bytes in single IO sndbufsi[z]e:the TCP send buffer size. This parameter is used only when the device is a URL (HTTP write test) [c]rc: string, if 'b' binascii is used, if 'z' zlib, if 'c' crc32c is used. [m]ethod: flag, if set a python implementation of dd will be used. [l]owio: [direct, async], this will switch to lower level I/O using either the O_DIRECT or the O_ASYNC flag when opening the file. s[e]ssion: string, session id for this HTTP write test data[r]ate: the data rate for HTTP write test. This parameter is used only when the device is a URL (HTTP write test) [f]file: string, filename of the file containing the results. Default: bspeed.pkl [w]rite: flag, if set writeTest is performed. [o]ld: flag, if set the old implementation of python DD is used. [m]ethod: flag, if set a python implementation of dd will be used. Default: False, standard dd will be used. [p]arallel: flag, if dev=='http', this will send <testcount> streams in parallel. [h]elp: flag, if set this help text is shown. NOTE: All byte values are forced to be an integer multiple of 4. Typical usage: python ~/diskTest.py -d /mymnt/testio -b 262144 -w -m -c z -t 5 -l async This performs 5 consecutive write tests on files /mymnt/testio* using a 256kB block size, the internal Python implementation of dd, performs a CRC checksum calculation on the stream using the zlib based CRC algorithm, repeats the test 5 times and uses low-level I/O. Plotting: The myDD write test is producing a fairly concise timing profile of the whole I/O and processing performance. The result will be stored in a file called bspeed.pkl. Since usually the platform where the tests are executed are servers or machines without window servers the plotting functionality is split off into a stand-alone function. Typically you would need to copy the bspeed.pkl file to a desktop machine. There is an additional dependency on the python pylab module to do the actual plotting. The best way to do this is to change to the directory where the bspeed.pkl file is located and launch ipython --pylab >>> import diskTest >>> speedPlot() Author: A. Wicenec [ESO, ICRAR] Date: 29-May-2002 Version 1.0 Version 2.0 20-Jun-2002: writeTest included Version 3.1 16-Aug-2013: various additions, CRC and stats writing. also added plotting function. """ import pydoc print pydoc.help('diskTest.usage') sys.exit()
columns = len(self._loggraph[current]['columns']) # while len(data) > 0: # record = [] # for i in range(columns): # record.append(data.pop()) # self._loggraph[current]['data'].append(record) # code around cases where columns merge together... for j in range(len(data)): record = data[j].split() if len(record) == columns: self._loggraph[current]['data'].append(record) return self._loggraph return CCP4Decorator() if __name__ == '__main__': from xia2.Driver.DriverFactory import DriverFactory d = DriverFactory.Driver('script') d = CCP4DecoratorFactory(d) from pydoc import help print help(d.__class__)
self.data.append(os.path.join(server,dir,fil)) elif top: self.data.append(os.path.join(top,dir,fil)) else: self.data.append(os.path.join(dir,fil)) return self.Retrieve(files,None, dir=dir,private=private, top=top,server=server,usedatapath=usedatapath) # Default project project = Project() def Flow(target,source,flow,**kw): return apply(project.Flow,(target,source,flow),kw) def Plot (target,source,flow=None,**kw): return apply(project.Plot,(target,source,flow),kw) def Result(target,source,flow=None,**kw): return apply(project.Result,(target,source,flow),kw) def Fetch(file,dir,private=0,**kw): return apply(project.Fetch,(file,dir,private),kw) def End(**kw): return apply(project.End,[],kw) def Program(*arg,**kw): return apply(project.Program,arg,kw) def Get(name): return project['ENV'].get(name) if __name__ == "__main__": import pydoc pydoc.help(Project)