text
stringlengths
81
112k
Setter for **self.__initialized** attribute. :param value: Attribute value. :type value: bool def initialized(self, value): """ Setter for **self.__initialized** attribute. :param value: Attribute value. :type value: bool """ if value is not None: ...
Setter for **self.__deactivatable** attribute. :param value: Attribute value. :type value: bool def deactivatable(self, value): """ Setter for **self.__deactivatable** attribute. :param value: Attribute value. :type value: bool """ if value is not None...
Actual main route of CTS APIs. Transfer typical requests through the ?request=REQUESTNAME route :return: Response def r_cts(self): """ Actual main route of CTS APIs. Transfer typical requests through the ?request=REQUESTNAME route :return: Response """ _request = request.args....
Create a CTS Error reply :param error_name: Name of the error :param message: Message of the Error :return: CTS Error Response with information (XML) def cts_error(self, error_name, message=None): """ Create a CTS Error reply :param error_name: Name of the error :param...
Provisional route for GetCapabilities request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetCapabilities response def _get_capabilities(self, urn=None): """ Provisional route for GetCapabilities request :param urn: URN to filter the resour...
Provisional route for GetPassage request :param urn: URN to filter the resource :return: GetPassage response def _get_passage(self, urn): """ Provisional route for GetPassage request :param urn: URN to filter the resource :return: GetPassage response """ urn = ...
Provisional route for GetPassagePlus request :param urn: URN to filter the resource :return: GetPassagePlus response def _get_passage_plus(self, urn): """ Provisional route for GetPassagePlus request :param urn: URN to filter the resource :return: GetPassagePlus response ...
Provisional route for GetValidReff request :param urn: URN to filter the resource :return: GetValidReff response def _get_valid_reff(self, urn, level): """ Provisional route for GetValidReff request :param urn: URN to filter the resource :return: GetValidReff response ...
Provisional route for GetPrevNext request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetPrevNext response def _get_prev_next(self, urn): """ Provisional route for GetPrevNext request :param urn: URN to filter the resource :param in...
Provisional route for GetFirstUrn request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetFirstUrn response def _get_first_urn(self, urn): """ Provisional route for GetFirstUrn request :param urn: URN to filter the resource :param in...
Provisional route for GetLabel request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetLabel response def _get_label(self, urn): """ Provisional route for GetLabel request :param urn: URN to filter the resource :param inv: Inventory ...
Yield events from the internal libinput's queue. Yields device events that are subclasses of :class:`~libinput.event.Event`. Yields: :class:`~libinput.event.Event`: Device event. def events(self): """Yield events from the internal libinput's queue. Yields device events that are subclasses of :class:`...
Return the type of the next event in the internal queue. This method does not pop the event off the queue and the next call to :attr:`events` returns that event. Returns: ~libinput.constant.EventType: The event type of the next available event or :obj:`None` if no event is available. def next_event_type(...
Add a device to a libinput context. If successful, the device will be added to the internal list and re-opened on :meth:`~libinput.LibInput.resume`. The device can be removed with :meth:`remove_device`. If the device was successfully initialized, it is returned. Args: path (str): Path to an input device....
Assign a seat to this libinput context. New devices or the removal of existing devices will appear as events when iterating over :meth:`~libinput.LibInput.get_event`. :meth:`assign_seat` succeeds even if no input devices are currently available on this seat, or if devices are available but fail to open. Dev...
Setup instance to extract metrics from the proper run :param outdir: run directory :param log_prefix: log filenames prefix def context(self, outdir, log_prefix): """Setup instance to extract metrics from the proper run :param outdir: run directory :param log_prefix: log filena...
Get Benchmark subclass by name :param name: name returned by ``Benchmark.name`` property :return: instance of ``Benchmark`` class def get_subclass(cls, name): """Get Benchmark subclass by name :param name: name returned by ``Benchmark.name`` property :return: instance of ``Bench...
Attempt to automatically find "adjacent" shapes in a SVG layer. In a layer within a new SVG document, draw each detected connection between the center points of the corresponding shapes. Parameters ---------- svg_source : str Input SVG file as a filepath (or file-like object). shape_i_...
Flatten sub-keys of a dictionary def flatten_dict(dic, parent_key='', sep='.'): """Flatten sub-keys of a dictionary """ items = [] for key, value in dic.items(): new_key = parent_key + sep + key if parent_key else key if isinstance(value, collections.MutableMapping): items.e...
Recursive dict merge. Inspired by :meth:``dict.update()``, instead of updating only top-level keys, dict_merge recurses down into dicts nested to an arbitrary depth, updating keys. The ``merge_dct`` is merged into ``dct``. :param dct: dict onto which the merge is executed :param merge_dct: dct merge...
Transform tree of dict and list in read-only data structure. dict instances are transformed to FrozenDict, lists in FrozenList. def freeze(obj): """Transform tree of dict and list in read-only data structure. dict instances are transformed to FrozenDict, lists in FrozenList. """ if ...
Create a ``Configuration`` from a file :param path: path to YAML file :return: new configuration :rtype: ``Configuration`` def from_file(cls, path): """Create a ``Configuration`` from a file :param path: path to YAML file :return: new configuration :rtype: ``Co...
Convert a hex-formatted number (i.e., `"#RGB[A]"` or `"#RRGGBB[AA]"`) to an RGBA tuple (i.e., `(<r>, <g>, <b>, <a>)`). Args: hex_color (str) : hex-formatted number (e.g., `"#2fc"`, `"#3c2f8611"`) normalize_to (int, float) : Factor to normalize each channel by Returns: (tuple) : R...
Split a term in to parent and record term components :param term: combined term text :return: Tuple of parent and record term def split_term(cls, term): """ Split a term in to parent and record term components :param term: combined term text :return: Tuple of parent and ...
Like split_term, but also lowercases both parent and record term :param term: combined term text :return: Tuple of parent and record term def split_term_lower(cls, term): """ Like split_term, but also lowercases both parent and record term :param term: combined term text ...
Return a string for the file, row and column of the term. def file_ref(self): """Return a string for the file, row and column of the term.""" from metatab.util import slugify assert self.file_name is None or isinstance(self.file_name, str) if self.file_name is not None and self.row is...
Add a term to this term's children. Also sets the child term's parent def add_child(self, child): """Add a term to this term's children. Also sets the child term's parent""" assert isinstance(child, Term) self.children.append(child) child.parent = self assert not child.term_is("...
Create a new term and add it to this term as a child. Creates grandchildren from the kwargs. :param term: term name. Just the record term :param term: Value to assign to the term :param term: Term properties, which create children of the child term. def new_child(self, term, value, **kwargs): ...
Remove the term from this term's children. def remove_child(self, child): """Remove the term from this term's children. """ assert isinstance(child, Term) self.children.remove(child) self.doc.remove_term(child)
Create new children from kwargs def new_children(self, **kwargs): """Create new children from kwargs""" for k, v in kwargs.items(): self.new_child(k, v) return self
Recursivelt set the parent, section and doc for a children def set_ownership(self): """Recursivelt set the parent, section and doc for a children""" assert self.section is not None for t in self.children: t.parent = self t._section = self.section t.doc = sel...
Return a terms by name. If the name is not qualified, use this term's record name for the parent. The method will yield all terms with a matching qualified name. def find(self, term, value=False): """Return a terms by name. If the name is not qualified, use this term's record name for the parent. ...
Find a term, using find_first, and set it's value and properties, if it exists. If it does not, create a new term and children. def get_or_new_child(self, term, value=False, **kwargs): """Find a term, using find_first, and set it's value and properties, if it exists. If it does not, create a ne...
Get the value of a child def get_value(self, item, default=None): """Get the value of a child""" try: return self[item].value except (AttributeError, KeyError) as e: return default
Return the fully qualified term name. The parent will be 'root' if there is no parent term defined. def qualified_term(self): """Return the fully qualified term name. The parent will be 'root' if there is no parent term defined. """ assert self.parent is not None or self.parent_term_lc == 'root' ...
Return True if the fully qualified name of the term is the same as the argument. If the argument is a list or tuple, return True if any of the term names match. Either the parent or the record term can be '*' ( 'Table.*' or '*.Name' ) to match any value for either the parent or record term. d...
Return the value and scalar properties as a dictionary. Returns only argumnet properties, properties declared on the same row as a term. It will return an entry for all of the args declared by the term's section. Use props to get values of all children and arg props combined def arg_props(self...
Return a dictionary with the values of all children, and place holders for all of the section argumemts. It combines props and arg_props def all_props(self): """Return a dictionary with the values of all children, and place holders for all of the section argumemts. It combines props and arg_pro...
Converts a record heirarchy to nested dicts. :param term: Root term at which to start conversion def _convert_to_dict(cls, term, replace_value_names=True): """Converts a record heirarchy to nested dicts. :param term: Root term at which to start conversion """ from collection...
Yield rows for the term, for writing terms to a CSV file. def rows(self): """Yield rows for the term, for writing terms to a CSV file. """ # Translate the term value name so it can be assigned to a parameter. tvm = self.section.doc.decl_terms.get(self.qualified_term, {}).get('termvaluename', '...
Iterate over all descendent terms def descendents(self): """Iterate over all descendent terms""" for c in self.children: yield c for d in c.descendents: yield d
Change a term into a Section Term def subclass(cls, t): """Change a term into a Section Term""" t.doc = None t.terms = [] t.__class__ = SectionTerm return t
Append an arg to the arg list def add_arg(self,arg, prepend=False): """Append an arg to the arg list""" self.args = [arg_.strip() for arg_ in self.args if arg_.strip()] if arg.title() not in self.args: if prepend: self.args = [arg.title()] + self.args e...
Remove an arg to the arg list def remove_arg(self, arg): """Remove an arg to the arg list""" self.args = [arg_.strip() for arg_ in self.args if arg_.strip()] for arg_ in list(self.args): if arg_.lower() == arg.lower(): self.args.remove(arg_)
Add a term to this section and set it's ownership. Should only be used on root level terms def add_term(self, t): """Add a term to this section and set it's ownership. Should only be used on root level terms""" if t not in self.terms: if t.parent_term_lc == 'root': self.term...
Create a new root-level term in this section def new_term(self, term, value, **kwargs): """Create a new root-level term in this section""" tc = self.doc.get_term_class(term.lower()) t = tc(term, value, doc=self.doc, parent=None, section=self).new_children(**kwargs) self.doc.add_term(...
Synonym for find_first, restructed to this section def get_term(self, term, value=False): """Synonym for find_first, restructed to this section""" return self.doc.find_first(term, value=value, section=self.name)
Create or set top level terms in the section. After python 3.6.0, the terms entries should maintain the same order as the argument list. The term arguments can have any of these forms: * For position argument, a Term object * For kw arguments: - 'TermName=TermValue' - 'T...
Remove a term from the terms. Must be the identical term, the same object def remove_term(self, term, remove_from_doc=True): """Remove a term from the terms. Must be the identical term, the same object""" try: self.terms.remove(term) except ValueError: pass if ...
Remove all of the terms from the section, and also remove them from the document def clean(self): """Remove all of the terms from the section, and also remove them from the document""" terms = list(self) for t in terms: self.doc.remove_term(t)
Sort the terms in the section. :param order: If specified, a list of qualified, lowercased term names. These names will appear first in the section, and the remaining terms will be sorted alphabetically. If not specified, all terms are alphabetized. :return: def sort_by_term(self, order...
Extract the chldren of a term that are arg-children from those that are row-children. def _args(self, term, d): """Extract the chldren of a term that are arg-children from those that are row-children. """ # Get the term value name, the property name that should be assigned to the term value. t...
Yield rows for the section def rows(self): """Yield rows for the section""" for t in self.terms: for row in t.rows: term, value = row # Value can either be a string, or a dict if isinstance(value, dict): # Dict is for properties, which might be arg-childr...
Iterate over all of the rows as text lines def lines(self): """Iterate over all of the rows as text lines""" # Yield the section header if self.name != 'Root': yield ('Section', '|'.join([self.value] + self.property_names)) # Yield all of the rows for terms in the section ...
Return the whole section as a dict def as_dict(self, replace_value_names=True): """Return the whole section as a dict""" old_children = self.children self.children = self.terms d = super(SectionTerm, self).as_dict(replace_value_names) self.children = old_children retu...
Identify a suitable C/fortran/other compiler When it is possible that the user (un)installs a compiler inbetween compilations of object files we want to catch that. This method allows compiler choice to be stored in a pickled metadata file. Provide metadir a dirpath to make the...
The command below covers most cases, if you need someting more complex subclass this. def cmd(self): """ The command below covers most cases, if you need someting more complex subclass this. """ cmd = ( [self.compiler_binary] + self.flags + ...
Draws a line on the current :py:class:`Layer` with the current :py:class:`Brush`. Coordinates are relative to the original layer size WITHOUT downsampling applied. :param x1: Starting X coordinate. :param y1: Starting Y coordinate. :param x2: End X coordinate. :param y2: End Y coordinate. :rtype: Nothing. ...
Draws a point on the current :py:class:`Layer` with the current :py:class:`Brush`. Coordinates are relative to the original layer size WITHOUT downsampling applied. :param x1: Point X coordinate. :param y1: Point Y coordinate. :rtype: Nothing. def drawPoint(self, x, y, silent=True): """ Draws a point on t...
Draws a series of lines on the current :py:class:`Layer` with the current :py:class:`Brush`. No interpolation is applied to these point and :py:meth:`drawLine` will be used to connect all the points lineraly. Coordinates are relative to the original layer size WITHOUT downsampling applied. :param pointList: A ...
Draws a closed series of lines on the current :py:class:`Layer` with the current :py:class:`Brush`. No interpolation is applied to these point and :py:meth:`drawLine` will be used to connect all the points lineraly. Coordinates are relative to the original layer size WITHOUT downsampling applied. :param pointL...
Draws a rectangle on the current :py:class:`Layer` with the current :py:class:`Brush`. Coordinates are relative to the original layer size WITHOUT downsampling applied. :param x1: The X of the top-left corner of the rectangle. :param y1: The Y of the top-left corner of the rectangle. :param x2: The X of the ...
Fills the current :py:class:`Layer` with the current :py:class:`Color`. :param color: The :py:class:`Color` to apply to the layer. :rtype: Nothing. def fillLayerWithColor(self, color): """ Fills the current :py:class:`Layer` with the current :py:class:`Color`. :param color: The :py:class:`Color` to app...
Add a border to the current :py:class:`Layer`. :param width: The width of the border. :param color: The :py:class:`Color` of the border, current :py:class:`Color` is the default value. :rtype: Nothing. def addBorder(self, width, color=None): """ Add a border to the current :py:class:`Layer`. :param w...
Sets the current :py:class:`Color` to use. :param color: The :py:class:`Color` to use. :rtype: Nothing. def setColor(self, color): """ Sets the current :py:class:`Color` to use. :param color: The :py:class:`Color` to use. :rtype: Nothing. """ self.color = color if self.brush and self.brush.does...
Change the alpha of the current :py:class:`Color`. :param fixed: Set the absolute 0-1 value of the alpha. :param proportional: Set the relative value of the alpha (Es: If the current alpha is 0.8, a proportional value of 0.5 will set the final value to 0.4). :rtype: Nothing. def setColorAlpha(self, fixed=None...
Swaps the current :py:class:`Color` with the secondary :py:class:`Color`. :rtype: Nothing. def swapColors(self): """ Swaps the current :py:class:`Color` with the secondary :py:class:`Color`. :rtype: Nothing. """ rgba = self.color.get_0_255() self.color = self.secondColor self.secondColor = Color(...
Sets the size of the current :py:class:`Brush`. :param brush: The :py:class:`Brush` object to use as a brush. :param resize: An optional absolute value to resize the brush before using it. :param proportional: An optional relative float 0-1 value to resize the brush before using it. :rtype: Nothing. def set...
Sets the mirror mode to use in the next operation. :param mirror: A string object with one of these values : '', 'h', 'v', 'hv'. "h" stands for horizontal mirroring, while "v" stands for vertical mirroring. "hv" sets both at the same time. :rtype: Nothing. def setMirrorMode(self, mirror): """ Sets the mirro...
Renders the :py:class:`Image` and outputs the final PNG file. :param output: A string with the output file path, can be empty if you don't want to save the final image. :param show: A boolean telling the system to display the final image after the rendering is done. :rtype: Nothing. def renderImage(self, outp...
Changes the effect of the current active :py:class:`Layer`. :param output: A string with the one of the blend modes listed in :py:meth:`newLayer`. :rtype: Nothing. def setActiveLayerEffect(self, effect): """ Changes the effect of the current active :py:class:`Layer`. :param output: A string with the on...
Recursively hash the contents of the given directory. Args: directory (str): The root directory we want to hash. Returns: A hash of all the contents in the directory. def get_hash_of_dirs(directory): """ Recursively hash the contents of the given directory. Args: director...
Check, if a download is required. Args: src_file: The filename to check for. src_root: The path we find the file in. Returns: True, if we need to download something, False otherwise. def source_required(src_file): """ Check, if a download is required. Args: src_fi...
Update the hash for the given file. Args: src: The file name. root: The path of the given file. def update_hash(src_file): """ Update the hash for the given file. Args: src: The file name. root: The path of the given file. """ hash_file = local.path(src_file) +...
Small copy wrapper. Args: From (str): Path to the SOURCE. To (str): Path to the TARGET. def Copy(From, To): """ Small copy wrapper. Args: From (str): Path to the SOURCE. To (str): Path to the TARGET. """ from benchbuild.utils.cmd import cp cp("-ar", "--refl...
Just copy fName into the current working directory, if it exists. No action is executed, if fName does not exist. No Hash is checked. Args: src: The filename we want to copy to '.'. root: The optional source dir we should pull fName from. Defaults to benchbuild.settings.CFG["tmpdir...
Download url, if required. Args: src_url (str): Our SOURCE url. tgt_name (str): The filename we want to have on disk. tgt_root (str): The TARGET directory for the download. Defaults to ``CFG["tmpdir"]``. def Wget(src_url, tgt_name, tgt_root=None): """ Download url, if r...
Decorate a project class with wget-based version information. This adds two attributes to a project class: - A `versions` method that returns a list of available versions for this project. - A `repository` attribute that provides a repository string to download from later. W...
Get a clone of the given repo Args: repository (str): Git URL of the SOURCE repo. directory (str): Name of the repo folder on disk. tgt_root (str): TARGET folder for the git repo. Defaults to ``CFG["tmpdir"]`` shallow_clone (bool): Only clone the repository shallow ...
Decorate a project class with git-based version information. This adds two attributes to a project class: - A `versions` method that returns a list of available versions for this project. - A `repository` attribute that provides a repository string to download from later. We...
Checkout the SVN repo. Args: url (str): The SVN SOURCE repo. fname (str): The name of the repo on disk. to (str): The name of the TARGET folder on disk. Defaults to ``CFG["tmpdir"]`` def Svn(url, fname, to=None): """ Checkout the SVN repo. Args: url (str): ...
RSync a folder. Args: url (str): The url of the SOURCE location. fname (str): The name of the TARGET. to (str): Path of the target location. Defaults to ``CFG["tmpdir"]``. def Rsync(url, tgt_name, tgt_root=None): """ RSync a folder. Args: url (str): The url...
Convert string from camel case to snake case. def camel_to_snake(s: str) -> str: """Convert string from camel case to snake case.""" return CAMEL_CASE_RE.sub(r'_\1', s).strip().lower()
Convert string from snake case to camel case. def snake_to_camel(s: str) -> str: """Convert string from snake case to camel case.""" fragments = s.split('_') return fragments[0] + ''.join(x.title() for x in fragments[1:])
Build metrics extractors according to the `metrics` config :param metrics: Benchmark `metrics` configuration section def _create_extractors(cls, metrics): """Build metrics extractors according to the `metrics` config :param metrics: Benchmark `metrics` configuration section """ ...
:return: Description of metrics extracted by this class def metrics(self): """ :return: Description of metrics extracted by this class """ return dict( (name, getattr(Metrics, config['type'])) for name, config in six.iteritems(self._metrics) )
Group metrics according to the `from` property. def froms(self): """Group metrics according to the `from` property. """ eax = {} for name, config in six.iteritems(self._metrics): from_ = self._get_property(config, 'from', default=self.stdout) eax.setdefault(from_...
Tesselate each shape path into one or more triangles. Parameters ---------- df_shapes : pandas.DataFrame Table containing vertices of shapes, one row per vertex, with the *at least* the following columns: - ``x``: The x-coordinate of the vertex. - ``y``: The y-coordinate o...
Intercept standard output in a with-context :return: cStringIO instance >>> with capture_stdout() as stdout: ... print stdout.getvalue() def capture_stdout(): """Intercept standard output in a with-context :return: cStringIO instance >>> with capture_stdout() as stdout: ...
Change current working directory in a with-context :param mkdir: If True, then directory is created if it does not exist :param cleanup: If True and no pre-existing directory, the directory is cleaned up at the end def pushd(path, mkdir=True, cleanup=False): """Change current working directory in a wit...
Create a temporary directory in a with-context keyword remove: Remove the directory when leaving the context if True. Default is True. other keywords arguments are given to the tempfile.mkdtemp function. def mkdtemp(*args, **kwargs): """Create a temporary directory in a with-context keyword r...
:return: duration in seconds spent in the context. :rtype: float def elapsed(self): """ :return: duration in seconds spent in the context. :rtype: float """ if self.end is None: return self() - self.end return self.end - self.start
Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens.type( def slugify(value): """ Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens.type( """ import re import unicodedata value = str(...
Import an obect as either a fully qualified, dotted name, def import_name_or_class(name): " Import an obect as either a fully qualified, dotted name, " if isinstance(name, str): # for "a.b.c.d" -> [ 'a.b.c', 'd' ] module_name, object_name = name.rsplit('.',1) # __import__ loads the mu...
Get argument to give to ``pip`` to install HPCBench. def pip_installer_url(version=None): """Get argument to give to ``pip`` to install HPCBench. """ version = version or hpcbench.__version__ version = str(version) if '.dev' in version: git_rev = 'master' if 'TRAVIS_BRANCH' in os.en...
Load campaign from YAML file :return: memory representation of the YAML file :rtype: dictionary def from_file(campaign_file, **kwargs): """Load campaign from YAML file :return: memory representation of the YAML file :rtype: dictionary """ realpath = osp.realpath(campaign_file) if osp....
Fill an existing campaign with default values for optional keys :param campaign: dictionary :type campaign: str :param exclude_nodes: node set to exclude from allocations :type exclude_nodes: str :param expandcampvars: should env variables be expanded? True by default :type expandcampvars: ...
Get of benchmarks referenced in the configuration :return: benchmarks :rtype: string generator def get_benchmark_types(campaign): """Get of benchmarks referenced in the configuration :return: benchmarks :rtype: string generator """ for benchmarks in campaign.benchmarks.values(): f...
Extract metrics from existing campaign :param campaign: campaign loaded with `hpcbench.campaign.from_file` :param report: instance of `hpcbench.campaign.ReportNode` :param top: this function is recursive. This parameter help distinguishing top-call. def get_metrics(campaign, report, top=True): """...
Write YAML campaign template to the given open file def write(self, file): """Write YAML campaign template to the given open file """ render( self.template, file, benchmarks=self.benchmarks, hostname=socket.gethostname(), )