Search is not available for this dataset
text
stringlengths
75
104k
def trace_module(no_print=True): """Trace eng wave module exceptions.""" mname = "wave_core" fname = "peng" module_prefix = "peng.{0}.Waveform.".format(mname) callable_names = ("__init__",) return docs.support.trace_support.run_trace( mname, fname, module_prefix, callable_names, no_print...
def def_links(mobj): """Define Sphinx requirements links.""" fdict = json_load(os.path.join("data", "requirements.json")) sdeps = sorted(fdict.keys()) olines = [] for item in sdeps: olines.append( ".. _{name}: {url}\n".format( name=fdict[item]["name"], url=fdict[i...
def make_common_entry(plist, pyver, suffix, req_ver): """Generate Python interpreter version entries for 2.x or 3.x series.""" prefix = "Python {pyver}.x{suffix}".format(pyver=pyver, suffix=suffix) plist.append("{prefix}{ver}".format(prefix=prefix, ver=ops_to_words(req_ver)))
def make_multi_entry(plist, pkg_pyvers, ver_dict): """Generate Python interpreter version entries.""" for pyver in pkg_pyvers: pver = pyver[2] + "." + pyver[3:] plist.append("Python {0}: {1}".format(pver, ops_to_words(ver_dict[pyver])))
def op_to_words(item): """Translate >=, ==, <= to words.""" sdicts = [ {"==": ""}, {">=": " or newer"}, {">": "newer than "}, {"<=": " or older"}, {"<": "older than "}, {"!=": "except "}, ] for sdict in sdicts: prefix = list(sdict.keys())[0] ...
def ops_to_words(item): """Translate requirement specification to words.""" unsupp_ops = ["~=", "==="] # Ordered for "pleasant" word specification supp_ops = [">=", ">", "==", "<=", "<", "!="] tokens = sorted(item.split(","), reverse=True) actual_tokens = [] for req in tokens: for o...
def proc_requirements(mobj): """Get requirements in reStructuredText format.""" pyvers = ["py{0}".format(item.replace(".", "")) for item in get_supported_interps()] py2vers = sorted([item for item in pyvers if item.startswith("py2")]) py3vers = sorted([item for item in pyvers if item.startswith("py3")])...
def _make_version(major, minor, micro, level, serial): """Generate version string from tuple (almost entirely from coveragepy).""" level_dict = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""} if level not in level_dict: raise RuntimeError("Invalid release level") version = "{0:d}.{1:...
def _chunk_noise(noise): """Chunk input noise data into valid Touchstone file rows.""" data = zip( noise["freq"], noise["nf"], np.abs(noise["rc"]), np.angle(noise["rc"]), noise["res"], ) for freq, nf, rcmag, rcangle, res in data: yield freq, nf, rcmag, rca...
def _chunk_pars(freq_vector, data_matrix, pformat): """Chunk input data into valid Touchstone file rows.""" pformat = pformat.upper() length = 4 for freq, data in zip(freq_vector, data_matrix): data = data.flatten() for index in range(0, data.size, length): fpoint = [freq] if...
def read_touchstone(fname): r""" Read a `Touchstone <https://ibis.org/connector/touchstone_spec11.pdf>`_ file. According to the specification a data line can have at most values for four complex parameters (plus potentially the frequency point), however this function is able to process malformed fi...
def write_touchstone(fname, options, data, noise=None, frac_length=10, exp_length=2): r""" Write a `Touchstone`_ file. Parameter data is first resized to an :code:`points` x :code:`nports` x :code:`nports` where :code:`points` represents the number of frequency points and :code:`nports` represents ...
def _bound_waveform(wave, indep_min, indep_max): """Add independent variable vector bounds if they are not in vector.""" indep_min, indep_max = _validate_min_max(wave, indep_min, indep_max) indep_vector = copy.copy(wave._indep_vector) if ( isinstance(indep_min, float) or isinstance(indep_max, fl...
def _build_units(indep_units, dep_units, op): """Build unit math operations.""" if (not dep_units) and (not indep_units): return "" if dep_units and (not indep_units): return dep_units if (not dep_units) and indep_units: return ( remove_extra_delims("1{0}({1})".format...
def _operation(wave, desc, units, fpointer): """Perform generic operation on a waveform object.""" ret = copy.copy(wave) ret.dep_units = units ret.dep_name = "{0}({1})".format(desc, ret.dep_name) ret._dep_vector = fpointer(ret._dep_vector) return ret
def _running_area(indep_vector, dep_vector): """Calculate running area under curve.""" rect_height = np.minimum(dep_vector[:-1], dep_vector[1:]) rect_base = np.diff(indep_vector) rect_area = np.multiply(rect_height, rect_base) triang_height = np.abs(np.diff(dep_vector)) triang_area = 0.5 * np.mu...
def _validate_min_max(wave, indep_min, indep_max): """Validate min and max bounds are within waveform's independent variable vector.""" imin, imax = False, False if indep_min is None: indep_min = wave._indep_vector[0] imin = True if indep_max is None: indep_max = wave._indep_vect...
def acos(wave): r""" Return the arc cosine of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for...
def acosh(wave): r""" Return the hyperbolic arc cosine of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions docum...
def asin(wave): r""" Return the arc sine of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for ...
def atanh(wave): r""" Return the hyperbolic arc tangent of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions docu...
def average(wave, indep_min=None, indep_max=None): r""" Return the running average of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param indep_min: Independent vector start point of computation :type indep_min: integer or float ...
def db(wave): r""" Return a waveform's dependent variable vector expressed in decibels. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation f...
def derivative(wave, indep_min=None, indep_max=None): r""" Return the numerical derivative of a waveform's dependent variable vector. The method used is the `backwards differences <https://en.wikipedia.org/wiki/ Finite_difference#Forward.2C_backward.2C_and_central_differences>`_ method :param ...
def fft(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is less than the size of ...
def fftdb(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the Fast Fourier Transform of a waveform. The dependent variable vector of the returned waveform is expressed in decibels :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of point...
def ffti(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the imaginary part of the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is...
def fftm(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the magnitude of the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is less...
def fftp(wave, npoints=None, indep_min=None, indep_max=None, unwrap=True, rad=True): r""" Return the phase of the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** ...
def fftr(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the real part of the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is less...
def find(wave, dep_var, der=None, inst=1, indep_min=None, indep_max=None): r""" Return the independent variable point associated with a dependent variable point. If the dependent variable point is not in the dependent variable vector the independent variable vector point is obtained by linear interpola...
def ifftdb(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the inverse Fast Fourier Transform of a waveform. The dependent variable vector of the returned waveform is expressed in decibels :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number...
def iffti(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the imaginary part of the inverse Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** ...
def ifftm(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the magnitude of the inverse Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** ...
def ifftp(wave, npoints=None, indep_min=None, indep_max=None, unwrap=True, rad=True): r""" Return the phase of the inverse Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints**...
def ifftr(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the real part of the inverse Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** ...
def integral(wave, indep_min=None, indep_max=None): r""" Return the running integral of a waveform's dependent variable vector. The method used is the `trapezoidal <https://en.wikipedia.org/wiki/Trapezoidal_rule>`_ method :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :p...
def group_delay(wave): r""" Return the group delay of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]] .. Auto-generated exceptions documentation for .. p...
def log(wave): r""" Return the natural logarithm of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentati...
def naverage(wave, indep_min=None, indep_max=None): r""" Return the numerical average of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param indep_min: Independent vector start point of computation :type indep_min: integer or float ...
def nintegral(wave, indep_min=None, indep_max=None): r""" Return the numerical integral of a waveform's dependent variable vector. The method used is the `trapezoidal <https://en.wikipedia.org/wiki/Trapezoidal_rule>`_ method :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` ...
def nmax(wave, indep_min=None, indep_max=None): r""" Return the maximum of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param indep_min: Independent vector start point of computation :type indep_min: integer or float :param ind...
def nmin(wave, indep_min=None, indep_max=None): r""" Return the minimum of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param indep_min: Independent vector start point of computation :type indep_min: integer or float :param ind...
def phase(wave, unwrap=True, rad=True): r""" Return the phase of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param unwrap: Flag that indicates whether phase should change phase shifts to their :code:`2*pi` complement ...
def round(wave, decimals=0): r""" Round a waveform's dependent variable vector to a given number of decimal places. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param decimals: Number of decimals to round to :type decimals: integer :rtype: :py:class:`peng.eng.Wavefor...
def sqrt(wave): r""" Return the square root of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation fo...
def subwave(wave, dep_name=None, indep_min=None, indep_max=None, indep_step=None): r""" Return a waveform that is a sub-set of a waveform, potentially re-sampled. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param dep_name: Independent variable name :type dep_name: `Non...
def wcomplex(wave): r""" Convert a waveform's dependent variable vector to complex. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for ...
def wfloat(wave): r""" Convert a waveform's dependent variable vector to float. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for ....
def wint(wave): r""" Convert a waveform's dependent variable vector to integer. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :rtype: :py:class:`peng.eng.Waveform` .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for ....
def wvalue(wave, indep_var): r""" Return the dependent variable value at a given independent variable point. If the independent variable point is not in the independent variable vector the dependent variable value is obtained by linear interpolation :param wave: Waveform :type wave: :py:class...
def find(self, path, all=False): """ Only allow lookups for jspm_packages. # TODO: figure out the 'jspm_packages' dir from packag.json. """ bits = path.split('/') dirs_to_serve = ['jspm_packages', settings.SYSTEMJS_OUTPUT_DIR] if not bits or bits[0] not in dirs_t...
def get_short_desc(long_desc): """Get first sentence of first paragraph of long description.""" found = False olines = [] for line in [item.rstrip() for item in long_desc.split("\n")]: if found and (((not line) and (not olines)) or (line and olines)): olines.append(line) elif...
def find_apps(self, templates=None): """ Crawls the (specified) template files and extracts the apps. If `templates` is specified, the template loader is used and the template is tokenized to extract the SystemImportNode. An empty context is used to resolve the node variables. ...
def render(self, context): """ Build the filepath by appending the extension. """ module_path = self.path.resolve(context) if not settings.SYSTEMJS_ENABLED: if settings.SYSTEMJS_DEFAULT_JS_EXTENSIONS: name, ext = posixpath.splitext(module_path) ...
def engineering_notation_number(obj): r""" Validate if an object is an :ref:`EngineeringNotationNumber` pseudo-type object. :param obj: Object :type obj: any :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The token \*[argument_name]\* is replaced by the name of the argu...
def touchstone_data(obj): r""" Validate if an object is an :ref:`TouchstoneData` pseudo-type object. :param obj: Object :type obj: any :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The token \*[argument_name]\* is replaced by the name of the argument the contract ...
def touchstone_noise_data(obj): r""" Validate if an object is an :ref:`TouchstoneNoiseData` pseudo-type object. :param obj: Object :type obj: any :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The token \*[argument_name]\* is replaced by the name of the argument the ...
def touchstone_options(obj): r""" Validate if an object is an :ref:`TouchstoneOptions` pseudo-type object. :param obj: Object :type obj: any :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The token \*[argument_name]\* is replaced by the name of the argument the con...
def wave_interp_option(obj): r""" Validate if an object is a :ref:`WaveInterpOption` pseudo-type object. :param obj: Object :type obj: any :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The token \*[argument_name]\* is replaced by the name of the argument the contr...
def wave_vectors(obj): r""" Validate if an object is a :ref:`WaveVectors` pseudo-type object. :param obj: Object :type obj: any :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The token \*[argument_name]\* is replaced by the name of the argument the contract is atta...
def _build_expr(tokens, higher_oplevel=-1, ldelim="(", rdelim=")"): """Build mathematical expression from hierarchical list.""" # Numbers if isinstance(tokens, str): return tokens # Unary operators if len(tokens) == 2: return "".join(tokens) # Multi-term operators oplevel = _...
def _next_rdelim(items, pos): """Return position of next matching closing delimiter.""" for num, item in enumerate(items): if item > pos: break else: raise RuntimeError("Mismatched delimiters") del items[num] return item
def _get_functions(expr, ldelim="(", rdelim=")"): """Parse function calls.""" tpars = _pair_delims(expr, ldelim=ldelim, rdelim=rdelim) alphas = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" fchars = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" "_" tfuncs = [] ...
def _pair_delims(expr, ldelim="(", rdelim=")"): """Pair delimiters.""" # Find where remaining delimiters are lindex = reversed([num for num, item in enumerate(expr) if item == ldelim]) rindex = [num for num, item in enumerate(expr) if item == rdelim] # Pair remaining delimiters return [(lpos, _n...
def _parse_expr(text, ldelim="(", rdelim=")"): """Parse mathematical expression using PyParsing.""" var = pyparsing.Word(pyparsing.alphas + "_", pyparsing.alphanums + "_") point = pyparsing.Literal(".") exp = pyparsing.CaselessLiteral("E") number = pyparsing.Combine( pyparsing.Word("+-" + py...
def _remove_consecutive_delims(expr, ldelim="(", rdelim=")"): """Remove consecutive delimiters.""" tpars = _pair_delims(expr, ldelim=ldelim, rdelim=rdelim) # Flag superfluous delimiters ddelim = [] for ctuple, ntuple in zip(tpars, tpars[1:]): if ctuple == (ntuple[0] - 1, ntuple[1] + 1): ...
def _remove_extra_delims(expr, ldelim="(", rdelim=")", fcount=None): """ Remove unnecessary delimiters (parenthesis, brackets, etc.). Internal function that can be recursed """ if not expr.strip(): return "" fcount = [0] if fcount is None else fcount tfuncs = _get_functions(expr, ld...
def _split_every(text, sep, count, lstrip=False, rstrip=False): """ Return list of the words in the string, using count of a separator as delimiter. :param text: String to split :type text: string :param sep: Separator :type sep: string :param count: Number of separators to use as delim...
def _to_eng_tuple(number): """ Return tuple with mantissa and exponent of number formatted in engineering notation. :param number: Number :type number: integer or float :rtype: tuple """ # pylint: disable=W0141 # Helper function: split integer and fractional part of mantissa # + ...
def no_exp(number): r""" Convert number to string guaranteeing result is not in scientific notation. :param number: Number to convert :type number: integer or float :rtype: string .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for peng.fu...
def peng(number, frac_length, rjust=True): r""" Convert a number to engineering notation. The absolute value of the number (if it is not exactly zero) is bounded to the interval [1E-24, 1E+24) :param number: Number to convert :type number: integer or float :param frac_length: Number of d...
def peng_float(snum): r""" Return floating point equivalent of a number represented in engineering notation. :param snum: Number :type snum: :ref:`EngineeringNotationNumber` :rtype: string .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation fo...
def peng_frac(snum): r""" Return the fractional part of a number represented in engineering notation. :param snum: Number :type snum: :ref:`EngineeringNotationNumber` :rtype: integer .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for ...
def peng_mant(snum): r""" Return the mantissa of a number represented in engineering notation. :param snum: Number :type snum: :ref:`EngineeringNotationNumber` :rtype: float .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]] .. Auto-generated exceptions documentation for .. peng.f...
def peng_power(snum): r""" Return engineering suffix and its floating point equivalent of a number. :py:func:`peng.peng` lists the correspondence between suffix and floating point exponent. :param snum: Number :type snum: :ref:`EngineeringNotationNumber` :rtype: named tuple in which the ...
def peng_suffix_math(suffix, offset): r""" Return engineering suffix from a starting suffix and an number of suffixes offset. :param suffix: Engineering suffix :type suffix: :ref:`EngineeringNotationSuffix` :param offset: Engineering suffix offset :type offset: integer :rtype: string ...
def remove_extra_delims(expr, ldelim="(", rdelim=")"): r""" Remove unnecessary delimiters in mathematical expressions. Delimiters (parenthesis, brackets, etc.) may be removed either because there are multiple consecutive delimiters enclosing a single expressions or because the delimiters are implie...
def round_mantissa(arg, decimals=0): """ Round floating point number(s) mantissa to given number of digits. Integers are not altered. The mantissa used is that of the floating point number(s) when expressed in `normalized scientific notation <https://en.wikipedia.org/wiki/Scientific_notation#Normal...
def pprint_vector(vector, limit=False, width=None, indent=0, eng=False, frac_length=3): r""" Format a list of numbers (vector) or a Numpy vector for printing. If the argument **vector** is :code:`None` the string :code:`'None'` is returned :param vector: Vector to pretty print or None :type v...
def to_scientific_string(number, frac_length=None, exp_length=None, sign_always=False): """ Convert number or number string to a number string in scientific notation. Full precision is maintained if the number is represented as a string :param number: Number to convert :type number: number or str...
def to_scientific_tuple(number): """ Return mantissa and exponent of a number in scientific notation. Full precision is maintained if the number is represented as a string :param number: Number :type number: integer, float or string :rtype: named tuple in which the first item is the mantissa...
def find_sourcemap_comment(filepath, block_size=100): """ Seeks and removes the sourcemap comment. If found, the sourcemap line is returned. Bundled output files can have massive amounts of lines, and the sourceMap comment is always at the end. So, to extract it efficiently, we read out the lin...
def get_paths(self): """ Return a tuple with the absolute path and relative path (relative to STATIC_URL) """ outfile = self.get_outfile() rel_path = os.path.relpath(outfile, settings.STATIC_ROOT) return outfile, rel_path
def needs_ext(self): """ Check whether `self.app` is missing the '.js' extension and if it needs it. """ if settings.SYSTEMJS_DEFAULT_JS_EXTENSIONS: name, ext = posixpath.splitext(self.app) if not ext: return True return False
def bundle(self): """ Bundle the app and return the static url to the bundle. """ outfile, rel_path = self.get_paths() options = self.opts if self.system._has_jspm_log(): self.command += ' --log {log}' options.setdefault('log', 'err') if ...
def trace(self, app): """ Trace the dependencies for app. A tracer-instance is shortlived, and re-tracing the same app should yield the same results. Since tracing is an expensive process, cache the result on the tracer instance. """ if app not in self._trace_cac...
def hashes_match(self, dep_tree): """ Compares the app deptree file hashes with the hashes stored in the cache. """ hashes = self.get_hashes() for module, info in dep_tree.items(): md5 = self.get_hash(info['path']) if md5 != hashes[info['path']]: ...
def format_hexdump(arg): """Convert the bytes object to a hexdump. The output format will be: <offset, 4-byte> <16-bytes of output separated by 1 space> <16 ascii characters> """ line = '' for i in range(0, len(arg), 16): if i > 0: line += '\n' chunk = arg[i:i +...
def parse_docstring(doc): """Parse a docstring into ParameterInfo and ReturnInfo objects.""" doc = inspect.cleandoc(doc) lines = doc.split('\n') section = None section_indent = None params = {} returns = None for line in lines: line = line.rstrip() if len(line) == 0: ...
def valid_identifiers(self): """Get a list of all valid identifiers for the current context. Returns: list(str): A list of all of the valid identifiers for this context """ funcs = list(utils.find_all(self.contexts[-1])) + list(self.builtins) return funcs
def _deferred_add(cls, add_action): """Lazily load a callable. Perform a lazy import of a context so that we don't have a huge initial startup time loading all of the modules that someone might want even though they probably only will use a few of them. """ module, _, o...
def _split_line(self, line): """Split a line into arguments using shlex and a dequoting routine.""" parts = shlex.split(line, posix=self.posix_lex) if not self.posix_lex: parts = [self._remove_quotes(x) for x in parts] return parts
def _check_initialize_context(self): """ Check if our context matches something that we have initialization commands for. If so, run them to initialize the context before proceeding with other commands. """ path = ".".join([annotate.context_name(x) for x in self.context...
def _builtin_help(self, args): """Return help information for a context or function.""" if len(args) == 0: return self.list_dir(self.contexts[-1]) if len(args) == 1: func = self.find_function(self.contexts[-1], args[0]) return annotate.get_help(func) ...
def find_function(self, context, funname): """Find a function in the given context by name. This function will first search the list of builtins and if the desired function is not a builtin, it will continue to search the given context. Args: context (object): A dic...
def list_dir(self, context): """Return a listing of all of the functions in this context including builtins. Args: context (object): The context to print a directory for. Returns: str """ doc = inspect.getdoc(context) listing = "" listi...
def _is_flag(cls, arg): """Check if an argument is a flag. A flag starts with - or -- and the next character must be a letter followed by letters, numbers, - or _. Currently we only check the alpha'ness of the first non-dash character to make sure we're not just looking at a ne...
def process_arguments(self, func, args): """Process arguments from the command line into positional and kw args. Arguments are consumed until the argument spec for the function is filled or a -- is found or there are no more arguments. Keyword arguments can be specified using --field=v...
def _extract_arg_value(cls, arg_name, arg_type, remaining): """Try to find the value for a keyword argument.""" next_arg = None should_consume = False if len(remaining) > 0: next_arg = remaining[0] should_consume = True if next_arg == '--': ...