_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q56900
VSGJinjaRenderer.render
train
def render(self, template, filename, context={}, filters={}): """ Renders a Jinja2 template to text. """ filename = os.path.normpath(filename) path, file = os.path.split(filename) try: os.makedirs(path) except OSError as exception: if excep...
python
{ "resource": "" }
q56901
VSGWriter.write
train
def write(pylist, parallel=True): """ Utility method to spawn a VSGWriter for each element in a collection. :param list pylist: A list of VSG objects (PrProjects, VSGSolutions, etc) :param bool parallel: Flag to enable asynchronous writing. """ threads = [VSGWriter(o) ...
python
{ "resource": "" }
q56902
WebBrowserInteractor.interact
train
def interact(self, ctx, location, ir_err): '''Implement Interactor.interact by opening the browser window and waiting for the discharge token''' p = ir_err.interaction_method(self.kind(), WebBrowserInteractionInfo) if not location.endswith('/'): location += '/' visit_...
python
{ "resource": "" }
q56903
WebBrowserInteractor._wait_for_token
train
def _wait_for_token(self, ctx, wait_token_url): ''' Returns a token from a the wait token URL @param wait_token_url URL to wait for (string) :return DischargeToken ''' resp = requests.get(wait_token_url) if resp.status_code != 200: raise InteractionError('cann...
python
{ "resource": "" }
q56904
WebBrowserInteractionInfo.from_dict
train
def from_dict(cls, info_dict): '''Create a new instance of WebBrowserInteractionInfo, as expected by the Error.interaction_method method. @param info_dict The deserialized JSON object @return a new WebBrowserInteractionInfo object. ''' return WebBrowserInteractionInfo( ...
python
{ "resource": "" }
q56905
Config.set
train
def set(self, name, value, overwrite=False): """ Sets a new value for a given configuration parameter. If it already exists, an Exception is thrown. To overwrite an existing value, set overwrite to True. :param name: Unique name of the parameter :param value: Value of t...
python
{ "resource": "" }
q56906
Parser.create_missing_types
train
def create_missing_types(cls, schema, type_dict, type_builder=None): """Creates missing types for fields with a CardinalityField part. It is assumed that the primary type converter for cardinality=1 is registered in the type dictionary. :param schema: Parse schema (or format) for parse...
python
{ "resource": "" }
q56907
Parser.extract_missing_special_type_names
train
def extract_missing_special_type_names(schema, type_dict): """Extract the type names for fields with CardinalityField part. Selects only the missing type names that are not in the type dictionary. :param schema: Parse schema to use (as string). :param type_dict: Type dictionary wit...
python
{ "resource": "" }
q56908
_check_operations
train
def _check_operations(ctx, need_ops, arg): ''' Checks an allow or a deny caveat. The need_ops parameter specifies whether we require all the operations in the caveat to be declared in the context. ''' ctx_ops = ctx.get(OP_KEY, []) if len(ctx_ops) == 0: if need_ops: f = arg.sp...
python
{ "resource": "" }
q56909
Checker.info
train
def info(self): ''' Returns information on all the registered checkers. Sorted by namespace and then name :returns a list of CheckerInfo ''' return sorted(self._checkers.values(), key=lambda x: (x.ns, x.name))
python
{ "resource": "" }
q56910
Checker.register_std
train
def register_std(self): ''' Registers all the standard checkers in the given checker. If not present already, the standard checkers schema (STD_NAMESPACE) is added to the checker's namespace with an empty prefix. ''' self._namespace.register(STD_NAMESPACE, '') for cond i...
python
{ "resource": "" }
q56911
AuthorizerFunc.authorize
train
def authorize(self, ctx, identity, ops): '''Implements Authorizer.authorize by calling f with the given identity for each operation. ''' allowed = [] caveats = [] for op in ops: ok, fcaveats = self._f(ctx, identity, op) allowed.append(ok) ...
python
{ "resource": "" }
q56912
ACLAuthorizer.authorize
train
def authorize(self, ctx, identity, ops): '''Implements Authorizer.authorize by calling identity.allow to determine whether the identity is a member of the ACLs associated with the given operations. ''' if len(ops) == 0: # Anyone is allowed to do nothing. r...
python
{ "resource": "" }
q56913
Rule.is_relevant
train
def is_relevant(self, action, subject): """ Matches both the subject and action, not necessarily the conditions. """ return self.matches_action(action) and self.matches_subject(subject)
python
{ "resource": "" }
q56914
is_valid
train
def is_valid(hal_id): """ Check that a given HAL id is a valid one. :param hal_id: The HAL id to be checked. :returns: Boolean indicating whether the HAL id is valid or not. >>> is_valid("hal-01258754, version 1") True >>> is_valid("hal-01258754") True >>> is_valid("hal-01258754v...
python
{ "resource": "" }
q56915
extract_from_text
train
def extract_from_text(text): """ Extract HAL ids from a text. :param text: The text to extract HAL ids from. :returns: A list of matching HAL ids. >>> sorted(extract_from_text("hal-01258754 hal-01258754v2 foobar")) ['hal-01258754', 'hal-01258754v2'] """ return tools.remove_duplicates([...
python
{ "resource": "" }
q56916
VSGSuite._getsolution
train
def _getsolution(self, config, section, **kwargs): """ Creates a VSG solution from a configparser instance. :param object config: The instance of the configparser class :param str section: The section name to read. :param kwargs: List of additional keyworded arguments to be pas...
python
{ "resource": "" }
q56917
VSGSuite._getproject
train
def _getproject(self, config, section, **kwargs): """ Creates a VSG project from a configparser instance. :param object config: The instance of the configparser class :param str section: The section name to read. :param kwargs: List of additional keyworded arguments to be passe...
python
{ "resource": "" }
q56918
VSGSuite.from_args
train
def from_args(cls, **kwargs): """ Generates one or more VSGSuite instances from command line arguments. :param kwargs: List of additional keyworded arguments to be passed into the VSGSuite defined in the :meth:`~VSGSuite.make_parser` method. """ # Create a VSGSuite for each fil...
python
{ "resource": "" }
q56919
VSGSuite.write
train
def write(self, parallel=True): """ Writes the configuration to disk. """ # Write the Solution files solutions = sorted(self._solutions, key=lambda x: x.Name) with VSGWriteCommand('Writing VSG Solution', solutions, parallel) as command: command.execute() ...
python
{ "resource": "" }
q56920
bibitem_as_plaintext
train
def bibitem_as_plaintext(bibitem): """ Return a plaintext representation of a bibitem from the ``.bbl`` file. .. note:: This plaintext representation can be super ugly, contain URLs and so \ on. .. note:: You need to have ``delatex`` installed system-wide, or to build it in \...
python
{ "resource": "" }
q56921
CardinalityField.split_type
train
def split_type(cls, type_name): """Split type of a type name with CardinalityField suffix into its parts. :param type_name: Type name (as string). :return: Tuple (type_basename, cardinality) """ if cls.matches_type(type_name): basename = type_name[:-1] c...
python
{ "resource": "" }
q56922
CardinalityField.make_type
train
def make_type(cls, basename, cardinality): """Build new type name according to CardinalityField naming scheme. :param basename: Type basename of primary type (as string). :param cardinality: Cardinality of the new type (as Cardinality item). :return: Type name with CardinalityField suf...
python
{ "resource": "" }
q56923
CardinalityFieldTypeBuilder.create_missing_type_variants
train
def create_missing_type_variants(cls, type_names, type_dict): """ Create missing type variants for types with a cardinality field. :param type_names: List of type names with cardinality field suffix. :param type_dict: Type dictionary with named type converters. :return: Type di...
python
{ "resource": "" }
q56924
MemoryOpsStore.put_ops
train
def put_ops(self, key, time, ops): ''' Put an ops only if not already there, otherwise it's a no op. ''' if self._store.get(key) is None: self._store[key] = ops
python
{ "resource": "" }
q56925
MemoryOpsStore.get_ops
train
def get_ops(self, key): ''' Returns ops from the key if found otherwise raises a KeyError. ''' ops = self._store.get(key) if ops is None: raise KeyError( 'cannot get operations for {}'.format(key)) return ops
python
{ "resource": "" }
q56926
_parse_local_location
train
def _parse_local_location(loc): '''Parse a local caveat location as generated by LocalThirdPartyCaveat. This is of the form: local <version> <pubkey> where <version> is the bakery version of the client that we're adding the local caveat for. It returns None if the location does not repre...
python
{ "resource": "" }
q56927
Macaroon.add_caveat
train
def add_caveat(self, cav, key=None, loc=None): '''Add a caveat to the macaroon. It encrypts it using the given key pair and by looking up the location using the given locator. As a special case, if the caveat's Location field has the prefix "local " the caveat is added as a clie...
python
{ "resource": "" }
q56928
Macaroon.add_caveats
train
def add_caveats(self, cavs, key, loc): '''Add an array of caveats to the macaroon. This method does not mutate the current object. @param cavs arrary of caveats. @param key the PublicKey to encrypt third party caveat. @param loc locator to find the location object that has a met...
python
{ "resource": "" }
q56929
Macaroon.to_dict
train
def to_dict(self): '''Return a dict representation of the macaroon data in JSON format. @return a dict ''' if self.version < VERSION_3: if len(self._caveat_data) > 0: raise ValueError('cannot serialize pre-version3 macaroon with ' ...
python
{ "resource": "" }
q56930
Macaroon.from_dict
train
def from_dict(cls, json_dict): '''Return a macaroon obtained from the given dictionary as deserialized from JSON. @param json_dict The deserialized JSON object. ''' json_macaroon = json_dict.get('m') if json_macaroon is None: # Try the v1 format if we don't ha...
python
{ "resource": "" }
q56931
Macaroon.deserialize_json
train
def deserialize_json(cls, serialized_json): '''Return a macaroon deserialized from a string @param serialized_json The string to decode {str} @return {Macaroon} ''' serialized = json.loads(serialized_json) return Macaroon.from_dict(serialized)
python
{ "resource": "" }
q56932
Macaroon._new_caveat_id
train
def _new_caveat_id(self, base): '''Return a third party caveat id This does not duplicate any third party caveat ids already inside macaroon. If base is non-empty, it is used as the id prefix. @param base bytes @return bytes ''' id = bytearray() if len(b...
python
{ "resource": "" }
q56933
extract_macaroons
train
def extract_macaroons(headers_or_request): ''' Returns an array of any macaroons found in the given slice of cookies. If the argument implements a get_header method, that will be used instead of the get method to retrieve headers. @param headers_or_request: dict of headers or a urllib.request.Reques...
python
{ "resource": "" }
q56934
_wait_for_macaroon
train
def _wait_for_macaroon(wait_url): ''' Returns a macaroon from a legacy wait endpoint. ''' headers = { BAKERY_PROTOCOL_HEADER: str(bakery.LATEST_VERSION) } resp = requests.get(url=wait_url, headers=headers) if resp.status_code != 200: raise InteractionError('cannot get {}'.format(...
python
{ "resource": "" }
q56935
Client.handle_error
train
def handle_error(self, error, url): '''Try to resolve the given error, which should be a response to the given URL, by discharging any macaroon contained in it. That is, if error.code is ERR_DISCHARGE_REQUIRED then it will try to discharge err.info.macaroon. If the discharge succ...
python
{ "resource": "" }
q56936
Client.acquire_discharge
train
def acquire_discharge(self, cav, payload): ''' Request a discharge macaroon from the caveat location as an HTTP URL. @param cav Third party {pymacaroons.Caveat} to be discharged. @param payload External caveat data {bytes}. @return The acquired macaroon {macaroonbakery.Macaroon} ...
python
{ "resource": "" }
q56937
Client._interact
train
def _interact(self, location, error_info, payload): '''Gathers a macaroon by directing the user to interact with a web page. The error_info argument holds the interaction-required error response. @return DischargeToken, bakery.Macaroon ''' if (self._interaction_methods is...
python
{ "resource": "" }
q56938
dict2bibtex
train
def dict2bibtex(data): """ Convert a single BibTeX entry dict to a BibTeX string. :param data: A dict representing BibTeX entry, as the ones from \ ``bibtexparser.BibDatabase.entries`` output. :return: A formatted BibTeX string. """ bibtex = '@' + data['ENTRYTYPE'] + '{' + data['ID'...
python
{ "resource": "" }
q56939
write
train
def write(filename, data): """ Create a new BibTeX file. :param filename: The name of the BibTeX file to write. :param data: A ``bibtexparser.BibDatabase`` object. """ with open(filename, 'w') as fh: fh.write(bibdatabase2bibtex(data))
python
{ "resource": "" }
q56940
edit
train
def edit(filename, identifier, data): """ Update an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to update, in the BibTeX file. :param data: A dict associating fields and updated values. Fields present \ in the BibT...
python
{ "resource": "" }
q56941
delete
train
def delete(filename, identifier): """ Delete an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to delete, in the BibTeX file. """ # Get current bibtex with open(filename, 'r') as fh: bibtex = bibtexparser.load(fh)...
python
{ "resource": "" }
q56942
get
train
def get(filename, ignore_fields=None): """ Get all entries from a BibTeX file. :param filename: The name of the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ file. :returns: A ``bibtexparser.BibDatabase`` object representing the fetched \ ...
python
{ "resource": "" }
q56943
to_filename
train
def to_filename(data, mask=DEFAULT_PAPERS_FILENAME_MASK, extra_formatters=None): """ Convert a bibtex entry to a formatted filename according to a given mask. .. note :: Available formatters out of the box are: - ``journal`` - ``title`` ...
python
{ "resource": "" }
q56944
Field.bind_name
train
def bind_name(self, name): """Bind field to its name in model class.""" if self.name: raise errors.Error('Already bound "{0}" with name "{1}" could not ' 'be rebound'.format(self, self.name)) self.name = name self.storage_name = ''.join(('_', se...
python
{ "resource": "" }
q56945
Field.bind_model_cls
train
def bind_model_cls(self, model_cls): """Bind field to model class.""" if self.model_cls: raise errors.Error('"{0}" has been already bound to "{1}" and ' 'could not be rebound to "{2}"'.format( self, self.model_cls, model_cls))...
python
{ "resource": "" }
q56946
Field.init_model
train
def init_model(self, model, value): """Init model with field. :param DomainModel model: :param object value: """ if value is None and self.default is not None: value = self.default() if callable(self.default) else self.default self.set_value(model, value)
python
{ "resource": "" }
q56947
Field.get_value
train
def get_value(self, model, default=None): """Return field's value. :param DomainModel model: :param object default: :rtype object: """ if default is not None: default = self._converter(default) value = getattr(model, self.storage_name) return...
python
{ "resource": "" }
q56948
Field.set_value
train
def set_value(self, model, value): """Set field's value. :param DomainModel model: :param object value: """ if value is None and self.required: raise AttributeError("This field is required.") if value is not None: value = self._converter(value) ...
python
{ "resource": "" }
q56949
Field._get_model_instance
train
def _get_model_instance(model_cls, data): """Convert dict into object of class of passed model. :param class model_cls: :param object data: :rtype DomainModel: """ if not isinstance(data, (model_cls, dict)): raise TypeError('{0} is not valid type, instance of...
python
{ "resource": "" }
q56950
Collection.get_builtin_type
train
def get_builtin_type(self, model): """Return built-in type representation of Collection. :param DomainModel model: :rtype list: """ return [item.get_data() if isinstance(item, self.related_model_cls) else item for item in self.get_value(model)]
python
{ "resource": "" }
q56951
gw_get
train
def gw_get(object_dict, name=None, plugin=None): """ Getter function to retrieve objects from a given object dictionary. Used mainly to provide get() inside patterns. :param object_dict: objects, which must have 'name' and 'plugin' as attribute :type object_dict: dictionary :param name: name o...
python
{ "resource": "" }
q56952
http_error_handler
train
def http_error_handler(f): """Handle 404 errors returned by the API server """ def hrefs_to_resources(hrefs): for href in hrefs.replace(',', '').split(): type, uuid = href.split('/')[-2:] yield Resource(type, uuid=uuid) def hrefs_list_to_resources(hrefs_list): f...
python
{ "resource": "" }
q56953
ResourceBase.href
train
def href(self): """Return URL of the resource :rtype: str """ url = self.session.base_url + str(self.path) if self.path.is_collection and not self.path.is_root: return url + 's' return url
python
{ "resource": "" }
q56954
Collection.filter
train
def filter(self, field_name, field_value): """Add permanent filter on the collection :param field_name: name of the field to filter on :type field_name: str :param field_value: value to filter on :rtype: Collection """ self.filters.append((field_name, field_valu...
python
{ "resource": "" }
q56955
Collection.fetch
train
def fetch(self, recursive=1, fields=None, detail=None, filters=None, parent_uuid=None, back_refs_uuid=None): """ Fetch collection from API server :param recursive: level of recursion :type recursive: int :param fields: fetch only listed fields. ...
python
{ "resource": "" }
q56956
Resource.check
train
def check(self): """Check that the resource exists. :raises ResourceNotFound: if the resource doesn't exists """ if self.fq_name: self['uuid'] = self._check_fq_name(self.fq_name) elif self.uuid: self['fq_name'] = self._check_uuid(self.uuid) return...
python
{ "resource": "" }
q56957
Resource.fq_name
train
def fq_name(self): """Return FQDN of the resource :rtype: FQName """ return self.get('fq_name', self.get('to', super(Resource, self).fq_name))
python
{ "resource": "" }
q56958
Resource.parent
train
def parent(self): """Return parent resource :rtype: Resource :raises ResourceNotFound: parent resource doesn't exists :raises ResourceMissing: parent resource is not defined """ try: return Resource(self['parent_type'], uuid=self['parent_uuid'], check=True) ...
python
{ "resource": "" }
q56959
Resource.parent
train
def parent(self, resource): """Set parent resource :param resource: parent resource :type resource: Resource :raises ResourceNotFound: resource not found on the API """ resource.check() self['parent_type'] = resource.type self['parent_uuid'] = resource.u...
python
{ "resource": "" }
q56960
Resource.created
train
def created(self): """Return creation date :rtype: datetime :raises ResourceNotFound: resource not found on the API """ if 'id_perms' not in self: self.fetch() created = self['id_perms']['created'] return datetime.strptime(created, '%Y-%m-%dT%H:%M:%S....
python
{ "resource": "" }
q56961
Resource.save
train
def save(self): """Save the resource to the API server If the resource doesn't have a uuid the resource will be created. If uuid is present the resource is updated. :rtype: Resource """ if self.path.is_collection: self.session.post_json(self.href, ...
python
{ "resource": "" }
q56962
Resource.delete
train
def delete(self): """Delete resource from the API server """ res = self.session.delete(self.href) self.emit('deleted', self) return res
python
{ "resource": "" }
q56963
Resource.fetch
train
def fetch(self, recursive=1, exclude_children=False, exclude_back_refs=False): """Fetch resource from the API server :param recursive: level of recursion for fetching resources :type recursive: int :param exclude_children: don't get children references :type exclude_children: bo...
python
{ "resource": "" }
q56964
Resource.from_dict
train
def from_dict(self, data, recursive=1): """Populate the resource from a python dict :param recursive: level of recursion for fetching resources :type recursive: int """ # Find other linked resources data = self._encode_resource(data, recursive=recursive) self.dat...
python
{ "resource": "" }
q56965
Resource.remove_ref
train
def remove_ref(self, ref): """Remove reference from self to ref >>> iip = Resource('instance-ip', uuid='30213cf9-4b03-4afc-b8f9-c9971a216978', fetch=True) >>> for vmi in iip['virtual_machine_interface_refs']: iip.remove_ref(v...
python
{ "resource": "" }
q56966
Resource.set_ref
train
def set_ref(self, ref, attr=None): """Set reference to resource Can be used to set references on a resource that is not already created. :param ref: reference to add :type ref: Resource :rtype: Resource """ ref_attr = '%s_refs' % ref.type.replace('-', '...
python
{ "resource": "" }
q56967
Resource.add_ref
train
def add_ref(self, ref, attr=None): """Add reference to resource :param ref: reference to add :type ref: Resource :rtype: Resource """ self.session.add_ref(self, ref, attr) return self.fetch()
python
{ "resource": "" }
q56968
Resource.add_back_ref
train
def add_back_ref(self, back_ref, attr=None): """Add reference from back_ref to self :param back_ref: back_ref to add :type back_ref: Resource :rtype: Resource """ back_ref.add_ref(self, attr) return self.fetch()
python
{ "resource": "" }
q56969
ResourceCache._search
train
def _search(self, trie, strings, limit=None): """Search in cache :param strings: list of strings to get from the cache :type strings: str list :param limit: limit search results :type limit: int :rtype: [Resource | Collection] """ results = [trie.has_key...
python
{ "resource": "" }
q56970
SignalsApplication.register
train
def register(self, signal, plugin, description=""): """ Registers a new signal. :param signal: Unique name of the signal :param plugin: Plugin, which registers the new signal :param description: Description of the reason or use case, why this signal is needed. ...
python
{ "resource": "" }
q56971
SignalsApplication.unregister
train
def unregister(self, signal): """ Unregisters an existing signal :param signal: Name of the signal """ if signal in self.signals.keys(): del(self.signals[signal]) self.__log.debug("Signal %s unregisterd" % signal) else: self.__log.debu...
python
{ "resource": "" }
q56972
SignalsApplication.disconnect
train
def disconnect(self, receiver): """ Disconnect a receiver from a signal. Signal and receiver must exist, otherwise an exception is thrown. :param receiver: Name of the receiver """ if receiver not in self.receivers.keys(): raise Exception("No receiver %s was ...
python
{ "resource": "" }
q56973
SignalsApplication.get
train
def get(self, signal=None, plugin=None): """ Get one or more signals. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if plugin is not None: ...
python
{ "resource": "" }
q56974
SignalsApplication.get_receiver
train
def get_receiver(self, receiver=None, plugin=None): """ Get one or more receivers. :param receiver: Name of the signal :type receiver: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if plugin is ...
python
{ "resource": "" }
q56975
start
train
def start(inqueue, outqueue=None): """Starts the listener with incoming and outgoing queues.""" conf.init(), db.init(conf.DbPath) Listener(inqueue, outqueue).run()
python
{ "resource": "" }
q56976
main
train
def main(): """Entry point for stand-alone execution.""" conf.init(), db.init(conf.DbPath) inqueue = LineQueue(sys.stdin).queue outqueue = type("", (), {"put": lambda self, x: print("\r%s" % x, end=" ")})() if "--quiet" in sys.argv: outqueue = None if conf.MouseEnabled: inqueue.put("mou...
python
{ "resource": "" }
q56977
KeyHandler._handle_windows
train
def _handle_windows(self, event): """Windows key event handler.""" vkey = self._keyname(event.GetKey()) if event.Message in self.KEYS_UP + self.KEYS_DOWN: if vkey in self.MODIFIERNAMES: self._realmodifiers[vkey] = event.Message in self.KEYS_DOWN ...
python
{ "resource": "" }
q56978
KeyHandler._handle_mac
train
def _handle_mac(self, keycode): """Mac key event handler""" key = self._keyname(unichr(keycode)) self._output(type="keys", key=key, realkey=key)
python
{ "resource": "" }
q56979
KeyHandler._handle_linux
train
def _handle_linux(self, keycode, character, press): """Linux key event handler.""" if character is None: return key = self._keyname(character, keycode) if key in self.MODIFIERNAMES: self._modifiers[self.MODIFIERNAMES[key]] = press self._realmodifiers[key] = ...
python
{ "resource": "" }
q56980
GwDocumentsInfo._store_documentation
train
def _store_documentation(self, path, html, overwrite, quiet): """ Stores all documents on the file system. Target location is **path**. File name is the lowercase name of the document + .rst. """ echo("Storing groundwork application documents\n") echo("Application: %s" ...
python
{ "resource": "" }
q56981
GwDocumentsInfo._show_documentation
train
def _show_documentation(self): """ Shows all documents of the current groundwork app in the console. Documents are sorted bei its names, except "main", which gets set to the beginning. """ documents = [] for key, document in self.app.documents.get().items(): ...
python
{ "resource": "" }
q56982
execute_cleanup_tasks
train
def execute_cleanup_tasks(ctx, cleanup_tasks, dry_run=False): """Execute several cleanup tasks as part of the cleanup. REQUIRES: ``clean(ctx, dry_run=False)`` signature in cleanup tasks. :param ctx: Context object for the tasks. :param cleanup_tasks: Collection of cleanup tasks (as Colle...
python
{ "resource": "" }
q56983
entrypoints
train
def entrypoints(section): """ Returns the Entry Point for a given Entry Point section. :param str section: The section name in the entry point collection :returns: A dictionary of (Name, Class) pairs stored in the entry point collection. """ return {ep.name: ep.load() for ep in pkg_resources.i...
python
{ "resource": "" }
q56984
entrypoint
train
def entrypoint(section, option): """ Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available. """ try: ...
python
{ "resource": "" }
q56985
infer_declared
train
def infer_declared(ms, namespace=None): '''Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, th...
python
{ "resource": "" }
q56986
infer_declared_from_conditions
train
def infer_declared_from_conditions(conds, namespace=None): ''' like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons. ''' conflicts = [] # If we can't resolve that standard namespace, then we'll look for # just bare...
python
{ "resource": "" }
q56987
GwBasePattern._pre_activate_injection
train
def _pre_activate_injection(self): """ Injects functions before the activation routine of child classes gets called """ # Let's be sure that this plugins class is registered and available on application level under # application.plugins.classes. This allows to reuse this class fo...
python
{ "resource": "" }
q56988
SignalsPlugin.register
train
def register(self, signal, description): """ Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used fo...
python
{ "resource": "" }
q56989
SignalsPlugin.get
train
def get(self, signal=None): """ Returns a single signal or a dictionary of signals for this plugin. """ return self.__app.signals.get(signal, self._plugin)
python
{ "resource": "" }
q56990
SignalsPlugin.get_receiver
train
def get_receiver(self, receiver=None): """ Returns a single receiver or a dictionary of receivers for this plugin. """ return self.__app.signals.get_receiver(receiver, self._plugin)
python
{ "resource": "" }
q56991
ContextViewMetaClass.validate
train
def validate(mcs, bases, attributes): """Check attributes.""" if bases[0] is object: return None mcs.check_model_cls(attributes) mcs.check_include_exclude(attributes) mcs.check_properties(attributes)
python
{ "resource": "" }
q56992
ContextViewMetaClass.get_properties
train
def get_properties(attributes): """Return tuple of names of defined properties. :type attributes: dict :rtype: list """ return [key for key, value in six.iteritems(attributes) if isinstance(value, property)]
python
{ "resource": "" }
q56993
ContextViewMetaClass.check_properties
train
def check_properties(mcs, attributes): """Check whether intersections exist. :type attributes: dict """ include, exclude = mcs.get_prepared_include_exclude(attributes) properties = mcs.get_properties(attributes) intersections = list( set(properties).intersect...
python
{ "resource": "" }
q56994
FilesystemEventHandler.on_deleted
train
def on_deleted(self, event): """ Event Handler when a file is deleted """ key = 'filesystem:file_deleted' data = { 'filepath': event.src_path, 'is_directory': event.is_directory, 'dirpath': os.path.dirname(event.src_path) } bms...
python
{ "resource": "" }
q56995
read_auth_info
train
def read_auth_info(agent_file_content): '''Loads agent authentication information from the specified content string, as read from an agents file. The returned information is suitable for passing as an argument to the AgentInteractor constructor. @param agent_file_content The agent file content (str)...
python
{ "resource": "" }
q56996
AgentInteractor.interact
train
def interact(self, client, location, interaction_required_err): '''Implement Interactor.interact by obtaining obtaining a macaroon from the discharger, discharging it with the local private key using the discharged macaroon as a discharge token''' p = interaction_required_err.int...
python
{ "resource": "" }
q56997
AgentInteractor.legacy_interact
train
def legacy_interact(self, client, location, visit_url): '''Implement LegacyInteractor.legacy_interact by obtaining the discharge macaroon using the client's private key ''' agent = self._find_agent(location) # Shallow-copy the client so that we don't unexpectedly side-effect ...
python
{ "resource": "" }
q56998
expiry_time
train
def expiry_time(ns, cavs): ''' Returns the minimum time of any time-before caveats found in the given list or None if no such caveats were found. The ns parameter is :param ns: used to determine the standard namespace prefix - if the standard namespace is not found, the empty prefix is assumed. ...
python
{ "resource": "" }
q56999
replace_all
train
def replace_all(text, replace_dict): """ Replace multiple strings in a text. .. note:: Replacements are made successively, without any warranty on the order \ in which they are made. :param text: Text to replace in. :param replace_dict: Dictionary mapping strings to replace with ...
python
{ "resource": "" }