Sphinx role for referencing a JIRA ticket.

    Examples::

        :jira:`DM-6181` -> DM-6181
        :jira:`DM-6181,DM-6181` -> DM-6180 and DM-6181
        :jira:`DM-6181,DM-6181,DM-6182` -> DM-6180, DM-6181, and DM-6182
764089
def jira_role(name, rawtext, text, lineno, inliner,
              options=None, content=None, oxford_comma=True):
    
    options = options or {}
    content = content or []
    config = inliner.document.settings.env.app.config

    ticket_ids = [each.strip() for each in utils.unescape(text).split(',')]
    n_tickets = len(ticket_ids)

    if oxford_comma:
        sep_factory = _oxford_comma_separator
    else:
        sep_factory = _comma_separator

    node_list = []
    for i, ticket_id in enumerate(ticket_ids):
        node = _make_ticket_node(ticket_id, config, options=options)
        node_list.append(node)
        sep_text = sep_factory(i, n_tickets)
        if sep_text is not None:
            sep = nodes.raw(text=sep_text, format='html')
            node_list.append(sep)
    return node_list, []
689044
def verify_ticket(self, ticket):
        """"""
        (response, charset) = self.get_verification_response(ticket)
        return self.verify_response(response, charset)
784297
def ref(host, seq, takeoff, emergency=False):
    
    p = 0b10001010101000000000000000000
    if takeoff:
        p |= 0b1000000000
    if emergency:
        p |= 0b100000000
    at(host, 'REF', seq, [p])
410131
def touch_empty_backreferences(app, what, name, obj, options, lines):
    """"""

    if not bool(app.config.sphinx_gallery_conf['backreferences_dir']):
        return

    examples_path = os.path.join(app.srcdir,
                                 app.config.sphinx_gallery_conf[
                                     "backreferences_dir"],
                                 "%s.examples" % name)

    if not os.path.exists(examples_path):
        # touch file
        open(examples_path, 'w').close()
1071934
def get_sphinx_ref(self, url, label=None):
        

        # A url is assumed to correspond to a citation if it contains
        # 'zreferences.html#'
        if 'zreferences.html#' in url:
            key = url.partition('zreferences.html#')[2]
            ref = ':cite:`%s`' % key
        else:
            # If the url does not correspond to a citation, try to look it
            # up in each of the IntersphinxInventory objects in our list
            ref = None
            # Iterate over IntersphinxInventory objects in our list
            for ii in self.invlst:
                # If the baseurl for the current IntersphinxInventory
                # object matches the url, try to look up the reference
                # from the url and terminate the loop of the look up
                # succeeds
                if ii.matching_base_url(url):
                    ref = ii.get_sphinx_ref(url, label)
                    break

            if ref is None:
                raise KeyError('no match found for url %s' % url)

        return ref
1225086
def check_binder_conf(binder_conf):
    """"""
    # Grab the configuration and return None if it's not configured
    binder_conf = {} if binder_conf is None else binder_conf
    if not isinstance(binder_conf, dict):
        raise ValueError('`binder_conf` must be a dictionary or None.')
    if len(binder_conf) == 0:
        return binder_conf

    if binder_conf.get('url') and not binder_conf.get('binderhub_url'):
        logger.warning(
            'Found old BinderHub URL keyword ("url"). Please update your '
            'configuration to use the new keyword ("binderhub_url"). "url" will be '
            'deprecated in sphinx-gallery v0.4')
        binder_conf['binderhub_url'] = binderhub_conf.get('url')

    # Ensure all fields are populated
    req_values = ['binderhub_url', 'org', 'repo', 'branch', 'dependencies']
    optional_values = ['filepath_prefix', 'notebooks_dir', 'use_jupyter_lab']
    missing_values = []
    for val in req_values:
        if binder_conf.get(val) is None:
            missing_values.append(val)

    if len(missing_values) > 0:
        raise ValueError('binder_conf is missing values for: {}'.format(
            missing_values))

    for key in binder_conf.keys():
        if key not in (req_values + optional_values):
            raise ValueError("Unknown Binder config key: {}".format(key))

    # Ensure we have http in the URL
    if not any(binder_conf['binderhub_url'].startswith(ii)
               for ii in ['http://', 'https://']):
        raise ValueError('did not supply a valid url, '
                         'gave binderhub_url: {}'.format(binder_conf['binderhub_url']))

    # Ensure we have at least one dependency file
    # Need at least one of these three files
    required_reqs_files = ['requirements.txt', 'environment.yml', 'Dockerfile']
    path_reqs = binder_conf['dependencies']
    if isinstance(path_reqs, basestring):
        path_reqs = [path_reqs]
        binder_conf['dependencies'] = path_reqs
    elif not isinstance(path_reqs, (list, tuple)):
        raise ValueError("`dependencies` value should be a list of strings. "
                         "Got type {}.".format(type(path_reqs)))

    binder_conf['notebooks_dir'] = binder_conf.get('notebooks_dir',
                                                   'notebooks')
    path_reqs_filenames = [os.path.basename(ii) for ii in path_reqs]
    if not any(ii in path_reqs_filenames for ii in required_reqs_files):
        raise ValueError(
            'Did not find one of `requirements.txt` or `environment.yml` '
            'in the "dependencies" section of the binder configuration '
            'for sphinx-gallery. A path to at least one of these files '
            'must exist in your Binder dependencies.')
    return binder_conf
1052438
def get_jid(jid):
    '''
    
    '''
    serv = _get_serv(ret=None)
    ret = {}
    for minion, data in six.iteritems(serv.hgetall('ret:{0}'.format(jid))):
        if data:
            ret[minion] = salt.utils.json.loads(data)
    return ret
22459
def call_missing_reference(cls, kb_app, sphinx_app: Sphinx,
                               sphinx_env: BuildEnvironment,
                               node,
                               contnode,
                               ):
        

        for callback in EventAction.get_callbacks(kb_app,
                                                  SphinxEvent.MR):
            return callback(kb_app, sphinx_app, sphinx_env, node, contnode)
629614
def ticket_flag(self, which, new=None):
        
        flag = _get_flag(which, TicketFlags)
        if flag:
            if not self.capabilities.have_ticket_flag(flag):
                raise yubikey_base.YubiKeyVersionError('Ticket flag %s requires %s, and this is %s %d.%d'
                                                       % (which, flag.req_string(self.capabilities.model), \
                                                         self.capabilities.model, self.ykver[0], self.ykver[1]))
            req_major, req_minor = flag.req_version()
            self._require_version(major=req_major, minor=req_minor)
            value = flag.to_integer()
        else:
            if type(which) is not int:
                raise yubico_exception.InputError('Unknown non-integer TicketFlag (%s)' % which)
            value = which

        return self.ticket_flags.get_set(value, new)
1066035
def related_records2marc(self, key, value):
    
    if value.get('relation_freetext'):
        return {
            'i': value.get('relation_freetext'),
            'w': get_recid_from_ref(value.get('record')),
        }
    elif value.get('relation') == 'successor':
        self.setdefault('78502', []).append({
            'i': 'superseded by',
            'w': get_recid_from_ref(value.get('record')),
        })
    elif value.get('relation') == 'predecessor':
        self.setdefault('78002', []).append({
            'i': 'supersedes',
            'w': get_recid_from_ref(value.get('record')),
        })
    else:
        raise NotImplementedError(u"Unhandled relation in related_records: {}".format(value.get('relation')))
1207149
def get_slave_addrs(mgr_addr, N):
    '''
    '''
    return  [(HOST, p) for p in range(mgr_addr+1, mgr_addr+1+N)]
1292837
def get_jsapi_ticket(self):
        
        ticket_key = '{0}_jsapi_ticket'.format(self.appid)
        expires_at_key = '{0}_jsapi_ticket_expires_at'.format(self.appid)
        ticket = self.session.get(ticket_key)
        expires_at = self.session.get(expires_at_key, 0)
        if not ticket or expires_at < int(time.time()):
            jsapi_ticket_response = self.get_ticket('jsapi')
            ticket = jsapi_ticket_response['ticket']
            expires_at = int(time.time()) + int(jsapi_ticket_response['expires_in'])
            self.session.set(ticket_key, ticket)
            self.session.set(expires_at_key, expires_at)
        return ticket
1370470
def format_name(self):
        '''
        
        '''
        if not hasattr(self.module, '__func_alias__'):
            # Resume normal sphinx.ext.autodoc operation
            return super(FunctionDocumenter, self).format_name()

        if not self.objpath:
            # Resume normal sphinx.ext.autodoc operation
            return super(FunctionDocumenter, self).format_name()

        if len(self.objpath) > 1:
            # Resume normal sphinx.ext.autodoc operation
            return super(FunctionDocumenter, self).format_name()

        # Use the salt func aliased name instead of the real name
        return self.module.__func_alias__.get(self.objpath[0], self.objpath[0])
37222
def reqs_txt(self):
        
        role_lines = ""

        for role in sorted(self.report["roles"]):
            name = utils.normalize_role(role, self.config)
            galaxy_name = "{0}.{1}".format(self.config["scm_user"], name)

            version_path = os.path.join(self.roles_path, role, "VERSION")
            version = utils.get_version(version_path)
            role_lines += "{0},{1}\n".format(galaxy_name, version)

        if self.out_file:
            utils.string_to_file(self.out_file, role_lines)
        else:
            print role_lines
1352594
def parse_django_adminopt_node(env, sig, signode):
    """"""
    from sphinx.domains.std import option_desc_re
    count = 0
    firstname = ''
    for m in option_desc_re.finditer(sig):
        optname, args = m.groups()
        if count:
            signode += addnodes.desc_addname(', ', ', ')
        signode += addnodes.desc_name(optname, optname)
        signode += addnodes.desc_addname(args, args)
        if not count:
            firstname = optname
        count += 1
    if not count:
        for m in simple_option_desc_re.finditer(sig):
            optname, args = m.groups()
            if count:
                signode += addnodes.desc_addname(', ', ', ')
            signode += addnodes.desc_name(optname, optname)
            signode += addnodes.desc_addname(args, args)
            if not count:
                firstname = optname
            count += 1
    if not firstname:
        raise ValueError
    return firstname
299225
def finalize_backreferences(seen_backrefs, gallery_conf):
    """"""
    logger = sphinx_compatibility.getLogger('sphinx-gallery')
    if gallery_conf['backreferences_dir'] is None:
        return

    for backref in seen_backrefs:
        path = os.path.join(gallery_conf['src_dir'],
                            gallery_conf['backreferences_dir'],
                            '%s.examples.new' % backref)
        if os.path.isfile(path):
            _replace_md5(path)
        else:
            level = gallery_conf['log_level'].get('backreference_missing',
                                                  'warning')
            func = getattr(logger, level)
            func('Could not find backreferences file: %s' % (path,))
            func('The backreferences are likely to be erroneous '
                 'due to file system case insensitivity.')
1088588
def siblingsId(self) -> Tuple[CtsReference, CtsReference]:
        

        if not self._text:
            raise MissingAttribute("CapitainsCtsPassage was iniated without CtsTextMetadata object")
        if self._prev_next is not None:
            return self._prev_next

        document_references = self._text.getReffs(level=self.depth)

        range_length = 1
        if self.reference.is_range():
            range_length = len(self.getReffs())

        start = document_references.index(self.reference.start)

        if start == 0:
            # If the passage is already at the beginning
            _prev = None
        elif start - range_length < 0:
            _prev = document_references[0]
        else:
            _prev = document_references[start - 1]

        if start + 1 == len(document_references):
            # If the passage is already at the end
            _next = None
        elif start + range_length > len(document_references):
            _next = document_references[-1]
        else:
            _next = document_references[start + 1]

        self._prev_next = (_prev, _next)
        return self._prev_next