_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q248500
write_terminator
train
def write_terminator(buff, capacity, ver, length): """\ Writes the terminator. :param buff: The byte buffer. :param capacity: Symbol capacity. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param length: Length
python
{ "resource": "" }
q248501
write_padding_bits
train
def write_padding_bits(buff, version, length): """\ Writes padding bits if the data stream does not meet the codeword boundary. :param buff: The byte buffer. :param int length: Data stream length. """ # ISO/IEC 18004:2015(E) - 7.4.10 Bit stream to codeword conversion -- page 32 # [...] ...
python
{ "resource": "" }
q248502
write_pad_codewords
train
def write_pad_codewords(buff, version, capacity, length): """\ Writes the pad codewords iff the data does not fill the capacity of the symbol. :param buff: The byte buffer. :param int version: The (Micro) QR Code version. :param int capacity: The total capacity of the symbol (incl. error correc...
python
{ "resource": "" }
q248503
add_alignment_patterns
train
def add_alignment_patterns(matrix, version): """\ Adds the adjustment patterns to the matrix. For versions < 2 this is a no-op. ISO/IEC 18004:2015(E) -- 6.3.6 Alignment patterns (page 17) ISO/IEC 18004:2015(E) -- Annex E Position of alignment patterns (page 83) """ if version < 2: r...
python
{ "resource": "" }
q248504
make_blocks
train
def make_blocks(ec_infos, codewords): """\ Returns the data and error blocks. :param ec_infos: Iterable of ECC information :param codewords: Iterable of (integer) code words. """ data_blocks, error_blocks = [], [] offset = 0 for ec_info in ec_infos: for i in range(ec_info.num_bl...
python
{ "resource": "" }
q248505
make_error_block
train
def make_error_block(ec_info, data_block): """\ Creates the error code words for the provided data block. :param ec_info: ECC information (number of blocks, number of code words etc.) :param data_block: Iterable of (integer) code words. """ num_error_words = ec_info.num_total - ec_info.num_data...
python
{ "resource": "" }
q248506
find_and_apply_best_mask
train
def find_and_apply_best_mask(matrix, version, is_micro, proposed_mask=None): """\ Applies all mask patterns against the provided QR Code matrix and returns the best matrix and best pattern. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data...
python
{ "resource": "" }
q248507
apply_mask
train
def apply_mask(matrix, mask_pattern, matrix_size, is_encoding_region): """\ Applies the provided mask pattern on the `matrix`. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) :param tuple matrix: A tuple of bytearrays :param mask_pattern: A mask pattern (a function) :param int matr...
python
{ "resource": "" }
q248508
evaluate_mask
train
def evaluate_mask(matrix, matrix_size): """\ Evaluates the provided `matrix` of a QR code. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results (page 53) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The penalty score o...
python
{ "resource": "" }
q248509
score_n1
train
def score_n1(matrix, matrix_size): """\ Implements the penalty score feature 1. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================================ ======================== ====== Feature Ev...
python
{ "resource": "" }
q248510
score_n2
train
def score_n2(matrix, matrix_size): """\ Implements the penalty score feature 2. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================== ==================== =============== Feature Evaluation condition Poi...
python
{ "resource": "" }
q248511
score_n3
train
def score_n3(matrix, matrix_size): """\ Implements the penalty score feature 3. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ========================================= ======================== ====== Feature Evaluatio...
python
{ "resource": "" }
q248512
score_n4
train
def score_n4(matrix, matrix_size): """\ Implements the penalty score feature 4. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) =========================================== ==================================== ====== Feature ...
python
{ "resource": "" }
q248513
evaluate_micro_mask
train
def evaluate_micro_mask(matrix, matrix_size): """\ Evaluates the provided `matrix` of a Micro QR code. ISO/IEC 18004:2015(E) -- 7.8.3.2 Evaluation of Micro QR Code symbols (page 54) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The ...
python
{ "resource": "" }
q248514
calc_format_info
train
def calc_format_info(version, error, mask_pattern): """\ Returns the format information for the provided error level and mask patttern. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- Table C.1 — Valid format information bit sequences (page 80) :param int version...
python
{ "resource": "" }
q248515
add_format_info
train
def add_format_info(matrix, version, error, mask_pattern): """\ Adds the format information into the provided matrix. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- 7.9.1 QR Code symbols ISO/IEC 18004:2015(E) -- 7.9.2 Micro QR Code symbols :param matrix: The...
python
{ "resource": "" }
q248516
add_version_info
train
def add_version_info(matrix, version): """\ Adds the version information to the matrix, for versions < 7 this is a no-op. ISO/IEC 18004:2015(E) -- 7.10 Version information (page 58) """ # # module 0 = least significant bit # module 17 = most significant bit # # Figure 27 — Version ...
python
{ "resource": "" }
q248517
prepare_data
train
def prepare_data(content, mode, encoding, version=None): """\ Returns an iterable of `Segment` instances. If `content` is a string, an integer, or bytes, the returned tuple will have a single item. If `content` is a list or a tuple, a tuple of `Segment` instances of the same length is returned. ...
python
{ "resource": "" }
q248518
data_to_bytes
train
def data_to_bytes(data, encoding): """\ Converts the provided data into bytes. If the data is already a byte sequence, it will be left unchanged. This function tries to use the provided `encoding` (if not ``None``) or the default encoding (ISO/IEC 8859-1). It uses UTF-8 as fallback. Returns th...
python
{ "resource": "" }
q248519
normalize_version
train
def normalize_version(version): """\ Canonicalizes the provided `version`. If the `version` is ``None``, this function returns ``None``. Otherwise this function checks if `version` is an integer or a Micro QR Code version. In case the string represents a Micro QR Code version, an uppercased str...
python
{ "resource": "" }
q248520
normalize_errorlevel
train
def normalize_errorlevel(error, accept_none=False): """\ Returns a constant for the provided error level. This function returns ``None`` if the provided parameter is ``None`` and `accept_none` is set to ``True`` (default: ``False``). If `error` is ``None`` and `accept_none` is ``False`` or if the p...
python
{ "resource": "" }
q248521
get_mode_name
train
def get_mode_name(mode_const): """\ Returns the mode name for the provided mode constant. :param int mode_const: The mode constant (see :py:module:`segno.consts`) """ for name, val in consts.MODE_MAPPING.items():
python
{ "resource": "" }
q248522
get_error_name
train
def get_error_name(error_const): """\ Returns the error name for the provided error constant. :param int error_const: The error constant (see :py:module:`segno.consts`) """ for name, val in consts.ERROR_MAPPING.items():
python
{ "resource": "" }
q248523
get_version_name
train
def get_version_name(version_const): """\ Returns the version name. For version 1 .. 40 it returns the version as integer, for Micro QR Codes it returns a string like ``M1`` etc. :raises: VersionError: In case the `version_constant` is unknown. """ if 0 < version_const < 41: return...
python
{ "resource": "" }
q248524
is_kanji
train
def is_kanji(data): """\ Returns if the `data` can be encoded in "kanji" mode. :param bytes data: The data to check. :rtype: bool """ data_len = len(data) if not data_len or data_len % 2: return False if _PY2: data = (ord(c) for c in data)
python
{ "resource": "" }
q248525
calc_structured_append_parity
train
def calc_structured_append_parity(content): """\ Calculates the parity data for the Structured Append mode. :param str content: The content. :rtype: int """ if not isinstance(content, str_type): content = str(content) try: data = content.encode('iso-8859-1') except Unico...
python
{ "resource": "" }
q248526
is_mode_supported
train
def is_mode_supported(mode, ver): """\ Returns if `mode` is supported by `version`. Note: This function does not check if `version` is actually a valid (Micro) QR Code version. Invalid versions like ``41`` may return an illegal value. :param int mode: Canonicalized mode. :param int or None...
python
{ "resource": "" }
q248527
version_range
train
def version_range(version): """\ Returns the version range for the provided version. This applies to QR Code versions, only. :param int version: The QR Code version (1 .. 40) :rtype: int """ # ISO/IEC 18004:2015(E) # Table 3 — Number of bits in character count indicator for QR Code (pag...
python
{ "resource": "" }
q248528
get_eci_assignment_number
train
def get_eci_assignment_number(encoding): """\ Returns the ECI number for the provided encoding. :param str encoding: A encoding name :return str: The ECI number. """ try:
python
{ "resource": "" }
q248529
get_data_mask_functions
train
def get_data_mask_functions(is_micro): """ Returns the data mask functions. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) Table 10 — Data mask pattern generation conditions (page 50) =============== ===================== ===================================== QR Code Pattern...
python
{ "resource": "" }
q248530
Buffer.toints
train
def toints(self): """\ Returns an iterable of integers interpreting the content of `seq` as sequence of binary numbers of length 8. """ def grouper(iterable, n, fillvalue=None): "Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x')
python
{ "resource": "" }
q248531
color_to_webcolor
train
def color_to_webcolor(color, allow_css3_colors=True, optimize=True): """\ Returns either a hexadecimal code or a color name. :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or ``(R, G, B, A)``)...
python
{ "resource": "" }
q248532
check_valid_border
train
def check_valid_border(border): """\ Raises a ValueError iff `border` is negative. :param int border: Indicating the size of the quiet zone.
python
{ "resource": "" }
q248533
VentApp.onStart
train
def onStart(self): """ Override onStart method for npyscreen """ curses.mousemask(0) self.paths.host_config() version = Version() # setup initial runtime stuff if self.first_time[0] and self.first_time[1] != 'exists': system = System() thr = Threa...
python
{ "resource": "" }
q248534
InstanceWriter.setGroups
train
def setGroups(self, groups, kerningGroupConversionRenameMaps=None): """ Copy the groups into our font. """ skipping = [] for name, members in groups.items(): checked = [] for m in members: if m in self.font: checked.append(m) ...
python
{ "resource": "" }
q248535
InstanceWriter.setLib
train
def setLib(self, lib): """ Copy the lib items into our font. """
python
{ "resource": "" }
q248536
InstanceWriter.copyFeatures
train
def copyFeatures(self, featureSource): """ Copy the features from this source """ if featureSource in self.sources: src, loc = self.sources[featureSource]
python
{ "resource": "" }
q248537
InstanceWriter.makeUnicodeMapFromSources
train
def makeUnicodeMapFromSources(self): """ Create a dict with glyphName -> unicode value pairs using the data in the sources. If all master glyphs have the same unicode value this value will be used in the map. If master glyphs have conflicting value, a warning wil...
python
{ "resource": "" }
q248538
InstanceWriter.getAvailableGlyphnames
train
def getAvailableGlyphnames(self): """ Return a list of all glyphnames we have masters for.""" glyphNames = {}
python
{ "resource": "" }
q248539
InstanceWriter.addInfo
train
def addInfo(self, instanceLocation=None, sources=None, copySourceName=None): """ Add font info data. """ if instanceLocation is None: instanceLocation = self.locationObject infoObject = self.font.info infoMasters = [] if sources is None: sources = self.sou...
python
{ "resource": "" }
q248540
InstanceWriter._copyFontInfo
train
def _copyFontInfo(self, targetInfo, sourceInfo): """ Copy the non-calculating fields from the source info. """ infoAttributes = [ "versionMajor", "versionMinor", "copyright", "trademark", "note", "openTypeGaspRangeRecords", ...
python
{ "resource": "" }
q248541
InstanceWriter._calculateGlyph
train
def _calculateGlyph(self, targetGlyphObject, instanceLocationObject, glyphMasters): """ Build a Mutator object for this glyph. * name: glyphName * location: Location object * glyphMasters: dict with font objects. """ sources = None items = []...
python
{ "resource": "" }
q248542
InstanceWriter.save
train
def save(self): """ Save the UFO.""" # handle glyphs that were muted for name in self.mutedGlyphsNames: if name not in self.font: continue if self.logger: self.logger.info("removing muted glyph %s", name) del self.font[name] # XXX ...
python
{ "resource": "" }
q248543
DesignSpaceDocumentWriter.save
train
def save(self, pretty=True): """ Save the xml. Make pretty if necessary. """ self.endInstance() if pretty: _indent(self.root, whitespace=self._whiteSpace) tree = ET.ElementTree(self.root)
python
{ "resource": "" }
q248544
DesignSpaceDocumentWriter._makeLocationElement
train
def _makeLocationElement(self, locationObject, name=None): """ Convert Location object to an locationElement.""" locElement = ET.Element("location") if name is not None: locElement.attrib['name'] = name for dimensionName, dimensionValue in locationObject.items(): d...
python
{ "resource": "" }
q248545
DesignSpaceDocumentReader.reportProgress
train
def reportProgress(self, state, action, text=None, tick=None): """ If we want to keep other code updated about our progress. state: 'prep' reading sources 'generate' making instances 'done' wrapping up 'error' ...
python
{ "resource": "" }
q248546
DesignSpaceDocumentReader.getSourcePaths
train
def getSourcePaths(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Return a list of paths referenced in the document.""" paths = []
python
{ "resource": "" }
q248547
DesignSpaceDocumentReader.process
train
def process(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Process the input file and generate the instances. """ if self.logger: self.logger.info("Reading
python
{ "resource": "" }
q248548
DesignSpaceDocumentReader.readWarp
train
def readWarp(self): """ Read the warp element :: <warp> <axis name="weight"> <map input="0" output="0" /> <map input="500" output="200" /> <map input="1000" output="1000" /> </axis> </war...
python
{ "resource": "" }
q248549
DesignSpaceDocumentReader.readAxes
train
def readAxes(self): """ Read the axes element. """ for axisElement in self.root.findall(".axes/axis"): axis = {} axis['name'] = name = axisElement.attrib.get("name") axis['tag'] = axisElement.attrib.get("tag") axis['minimum'] = float(axisElement.at...
python
{ "resource": "" }
q248550
DesignSpaceDocumentReader.readSources
train
def readSources(self): """ Read the source elements. :: <source filename="LightCondensed.ufo" location="location-token-aaa" name="master-token-aaa1"> <info mute="1" copy="1"/> <kerning mute="1"/> <glyph mute="1" name="thirdGlyph"/> ...
python
{ "resource": "" }
q248551
DesignSpaceDocumentReader.locationFromElement
train
def locationFromElement(self, element): """ Find the MutatorMath location of this element, either by name or from a child element. """ elementLocation = None for locationElement in element.findall('.location'):
python
{ "resource": "" }
q248552
DesignSpaceDocumentReader.readInstance
train
def readInstance(self, key, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Read a single instance element. key: an (attribute, value) tuple used to find the requested instance. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-...
python
{ "resource": "" }
q248553
DesignSpaceDocumentReader.readInstances
train
def readInstances(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Read all instance elements. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular"> """
python
{ "resource": "" }
q248554
DesignSpaceDocumentReader.readInfoElement
train
def readInfoElement(self, infoElement, instanceObject): """ Read the info element. :: <info/> <info"> <location/>
python
{ "resource": "" }
q248555
DesignSpaceDocumentReader.readKerningElement
train
def readKerningElement(self, kerningElement, instanceObject): """ Read the kerning element. :: Make kerning at the location and with the masters specified at the instance level. <kerning/>
python
{ "resource": "" }
q248556
DesignSpaceDocumentReader.readGlyphElement
train
def readGlyphElement(self, glyphElement, instanceObject): """ Read the glyph element. :: <glyph name="b" unicode="0x62"/> <glyph name="b"/> <glyph name="b"> <master location="location-token-bbb" source="master-token-aaa2"/> ...
python
{ "resource": "" }
q248557
Enumerable.group_by
train
def group_by(self, key_names=[], key=lambda x: x, result_func=lambda x: x): """ Groups an enumerable on given key selector. Index of key name corresponds to index of key lambda function. Usage: Enumerable([1,2,3]).group_by(key_names=['id'], key=lambda x: x) _ ...
python
{ "resource": "" }
q248558
Tools.inventory
train
def inventory(self, choices=None): """ Return a dictionary of the inventory items and status """ status = (True, None) if not choices: return (False, 'No choices made') try: # choices: repos, tools, images, built, running, enabled items = {'repos': [],...
python
{ "resource": "" }
q248559
Tools._start_priority_containers
train
def _start_priority_containers(self, groups, group_orders, tool_d): """ Select containers based on priorities to start """ vent_cfg = Template(self.path_dirs.cfg_file) cfg_groups = vent_cfg.option('groups', 'start_order') if cfg_groups[0]: cfg_groups = cfg_groups[1].split(','...
python
{ "resource": "" }
q248560
Tools._start_remaining_containers
train
def _start_remaining_containers(self, containers_remaining, tool_d): """ Select remaining containers that didn't have priorities to start """ s_containers = [] f_containers = [] for container in containers_remaining: s_containers, f_containers = self._start_co...
python
{ "resource": "" }
q248561
Tools._start_container
train
def _start_container(self, container, tool_d, s_containers, f_containers): """ Start container that was passed in and return status """ # use section to add info to manifest section = tool_d[container]['section'] del tool_d[container]['section'] manifest = Template(self.manifest)...
python
{ "resource": "" }
q248562
Tools.repo_commits
train
def repo_commits(self, repo): """ Get the commit IDs for all of the branches of a repository """ commits = [] try: status = self.path_dirs.apply_path(repo) # switch to directory where repo will be cloned to if status[0]: cwd = status[1] ...
python
{ "resource": "" }
q248563
Tools.repo_branches
train
def repo_branches(self, repo): """ Get the branches of a repository """ branches = [] try: # switch to directory where repo will be cloned to status = self.path_dirs.apply_path(repo) if status[0]: cwd = status[1] else: ...
python
{ "resource": "" }
q248564
Tools.repo_tools
train
def repo_tools(self, repo, branch, version): """ Get available tools for a repository branch at a version """ try: tools = [] status = self.path_dirs.apply_path(repo) # switch to directory where repo will be cloned to if status[0]: cwd = st...
python
{ "resource": "" }
q248565
HelpForm.change_forms
train
def change_forms(self, *args, **keywords): """ Checks which form is currently displayed and toggles to the other one """ # Returns to previous Form in history if there is a previous Form try:
python
{ "resource": "" }
q248566
capture_logger
train
def capture_logger(name): """ Context manager to capture a logger output with a StringIO stream. """ import logging logger = logging.getLogger(name) try: import StringIO stream = StringIO.StringIO() except ImportError: from io import StringIO
python
{ "resource": "" }
q248567
Mutator.setNeutral
train
def setNeutral(self, aMathObject, deltaName="origin"): """Set the neutral object.""" self._neutral = aMathObject
python
{ "resource": "" }
q248568
Mutator.getAxisNames
train
def getAxisNames(self): """ Collect a set of axis names from all deltas. """ s = {} for l, x in self.items():
python
{ "resource": "" }
q248569
Mutator._collectAxisPoints
train
def _collectAxisPoints(self): """ Return a dictionary with all on-axis locations. """ for l, (value, deltaName) in self.items(): location = Location(l)
python
{ "resource": "" }
q248570
Mutator._collectOffAxisPoints
train
def _collectOffAxisPoints(self): """ Return a dictionary with all off-axis locations. """ offAxis = {} for l, (value,
python
{ "resource": "" }
q248571
Mutator.collectLocations
train
def collectLocations(self): """ Return a dictionary with all objects.
python
{ "resource": "" }
q248572
Mutator._allLocations
train
def _allLocations(self): """ Return a list of all locations of all objects.
python
{ "resource": "" }
q248573
Mutator._accumulateFactors
train
def _accumulateFactors(self, aLocation, deltaLocation, limits, axisOnly): """ Calculate the factors of deltaLocation towards aLocation, """ relative = [] deltaAxis = deltaLocation.isOnAxis() if deltaAxis is None: relative.append(1) elif deltaAxis: ...
python
{ "resource": "" }
q248574
Mutator._calcOnAxisFactor
train
def _calcOnAxisFactor(self, aLocation, deltaAxis, deltasOnSameAxis, deltaLocation): """ Calculate the on-axis factors. """ if deltaAxis == "origin": f = 0 v = 0 else: f = aLocation[deltaAxis] v = deltaLocation[deltaAxis] ...
python
{ "resource": "" }
q248575
Mutator._calcOffAxisFactor
train
def _calcOffAxisFactor(self, aLocation, deltaLocation, limits): """ Calculate the off-axis factors. """ relative = [] for dim in limits.keys(): f = aLocation[dim] v = deltaLocation[dim] mB, M, mA = limits[dim] r = 0 ...
python
{ "resource": "" }
q248576
biasFromLocations
train
def biasFromLocations(locs, preferOrigin=True): """ Find the vector that translates the whole system to the origin. """ dims = {} locs.sort() for l in locs: for d in l.keys(): if not d in dims: dims[d] = [] v = l[d] if type(v)==tup...
python
{ "resource": "" }
q248577
Location.getType
train
def getType(self, short=False): """Return a string describing the type of the location, i.e. origin, on axis, off axis etc. :: >>> l = Location() >>> l.getType() 'origin' >>> l = Location(pop=1) >>> l.getType() 'on-axi...
python
{ "resource": "" }
q248578
Location.distance
train
def distance(self, other=None): """Return the geometric distance to the other location. If no object is provided, this will calculate the distance to the origin. :: >>> l = Location(pop=100) >>> m = Location(pop=200) >>> l.distance(m) 100.0 ...
python
{ "resource": "" }
q248579
RmqEs.connections
train
def connections(self, wait): """ wait for connections to both rabbitmq and elasticsearch to be made before binding a routing key to a channel and sending messages to elasticsearch """ while wait: try: params = pika.ConnectionParameters(host=sel...
python
{ "resource": "" }
q248580
RmqEs.callback
train
def callback(self, ch, method, properties, body): """ callback triggered on rabiitmq message received and sends it to an elasticsearch index """ index = method.routing_key.split('.')[1] index = index.replace('/', '-') failed = False body = str(body) ...
python
{ "resource": "" }
q248581
RmqEs.start
train
def start(self): """ start the channel listener and start consuming messages """ self.connections(True) binding_keys = sys.argv[1:] if not binding_keys: print(sys.stderr, 'Usage: {0!s} [binding_key]...'.format(sys.argv[0])) sys.exit(0)
python
{ "resource": "" }
q248582
RmqEs.consume
train
def consume(self): # pragma: no cover """ start consuming rabbitmq messages """ print(' [*]
python
{ "resource": "" }
q248583
System.backup
train
def backup(self): """ Saves the configuration information of the current running vent instance to be used for restoring at a later time """ status = (True, None) # initialize all needed variables (names for backup files, etc.) backup_name = ('.vent-backup-' + '-'....
python
{ "resource": "" }
q248584
System.reset
train
def reset(self): """ Factory reset all of Vent's user data, containers, and images """ status = (True, None) error_message = '' # remove containers try: c_list = set(self.d_client.containers.list( filters={'label': 'vent'}, all=True)) for ...
python
{ "resource": "" }
q248585
System.get_configure
train
def get_configure(self, repo=None, name=None, groups=None, main_cfg=False): """ Get the vent.template settings for a given tool by looking at the plugin_manifest """ constraints = locals() ...
python
{ "resource": "" }
q248586
AddOptionsForm.repo_values
train
def repo_values(self): """ Set the appropriate repo dir and get the branches and commits of it """ branches = [] commits = {} m_helper = Tools() status = m_helper.repo_branches(self.parentApp.repo_value['repo']) # branches and commits must both be retrieve...
python
{ "resource": "" }
q248587
AddOptionsForm.on_ok
train
def on_ok(self): """ Take the branch, commit, and build selection and add them as plugins """ self.parentApp.repo_value['versions'] = {} self.parentApp.repo_value['build'] = {} for branch in self.branch_cb: if self.branch_cb[branch].value: # pr...
python
{ "resource": "" }
q248588
AddForm.create
train
def create(self): """ Create widgets for AddForm """ self.add_handlers({'^T': self.quit, '^Q': self.quit}) self.add(npyscreen.Textfield, value='Add a plugin from a Git repository or an image from a ' 'Docker registry.', editable=False, ...
python
{ "resource": "" }
q248589
AddForm.on_ok
train
def on_ok(self): """ Add the repository """ def popup(thr, add_type, title): """ Start the thread and display a popup of the plugin being cloned until the thread is finished """ thr.start() tool_str = 'Cloning repository...' ...
python
{ "resource": "" }
q248590
ToolForm.toggle_view
train
def toggle_view(self, *args, **kwargs): """ Toggles the view between different groups """ group_to_display = self.views.popleft() self.cur_view.value = group_to_display for repo in self.tools_tc: for tool in self.tools_tc[repo]: t_groups = self.manifest.option...
python
{ "resource": "" }
q248591
Template.options
train
def options(self, section): """ Returns a list of options for a section """ if self.config.has_section(section):
python
{ "resource": "" }
q248592
Template.option
train
def option(self, section, option): """ Returns the value of the option """ if self.config.has_section(section): if self.config.has_option(section, option):
python
{ "resource": "" }
q248593
Template.add_section
train
def add_section(self, section): """ If section exists, returns log, otherwise adds section and returns list of sections. """ # check if section already exists if not self.config.has_section(section): self.config.add_section(section)
python
{ "resource": "" }
q248594
Template.add_option
train
def add_option(self, section, option, value=None): """ Creates an option for a section. If the section does not exist, it will create the section. """ # check if section exists; create if not if not self.config.has_section(section): message = self.add_section(...
python
{ "resource": "" }
q248595
Template.del_section
train
def del_section(self, section): """ Deletes a section if it exists """ if self.config.has_section(section): self.config.remove_section(section)
python
{ "resource": "" }
q248596
Template.del_option
train
def del_option(self, section, option): """ Deletes an option if the section and option exist """ if self.config.has_section(section): if self.config.has_option(section, option): self.config.remove_option(section, option) return
python
{ "resource": "" }
q248597
Template.set_option
train
def set_option(self, section, option, value): """ Sets an option to a value in the given section. Option is created if it does not already exist """ if self.config.has_section(section): self.config.set(section, option, value)
python
{ "resource": "" }
q248598
Template.constrain_opts
train
def constrain_opts(self, constraint_dict, options): """ Return result of constraints and options against a template """ constraints = {} for constraint in constraint_dict: if constraint != 'self':
python
{ "resource": "" }
q248599
Template.list_tools
train
def list_tools(self): """ Return list of tuples of all tools """ tools = [] exists, sections = self.sections() if exists: for section in sections: options = {'section': section, 'built': None, ...
python
{ "resource": "" }