Determine appropriate stencil name for stencil definition.

    Given a fastfood.json stencil definition with a stencil set, figure out
    what the name of the stencil within the set should be, or use the default
553137
def _determine_selected_stencil(stencil_set, stencil_definition):
    
    if 'stencil' not in stencil_definition:
        selected_stencil_name = stencil_set.manifest.get('default_stencil')
    else:
        selected_stencil_name = stencil_definition.get('stencil')

    if not selected_stencil_name:
        raise ValueError("No stencil name, within stencil set %s, specified."
                         % stencil_definition['name'])

    return selected_stencil_name
352398
def prep_rg_names(item, config, fc_name, fc_date):
    
    if fc_name and fc_date:
        lane_name = "%s_%s_%s" % (item["lane"], fc_date, fc_name)
    else:
        lane_name = item["description"]
    return {"rg": item["description"],
            "sample": item["description"],
            "lane": lane_name,
            "pl": (tz.get_in(["algorithm", "platform"], item)
                   or tz.get_in(["algorithm", "platform"], item, "illumina")).lower(),
            "lb": tz.get_in(["metadata", "library"], item),
            "pu": tz.get_in(["metadata", "platform_unit"], item) or lane_name}
682947
def com_google_fonts_check_name_typographicsubfamilyname(ttFont, style_with_spaces):
  
  from fontbakery.utils import name_entry_id

  failed = False
  if style_with_spaces in ['Regular',
                           'Italic',
                           'Bold',
                           'Bold Italic']:
    for name in ttFont['name'].names:
      if name.nameID == NameID.TYPOGRAPHIC_SUBFAMILY_NAME:
        failed = True
        yield FAIL, Message("ribbi",
                            ("Font style is '{}' and, for that reason,"
                             " it is not expected to have a "
                             "{} entry!").format(style_with_spaces,
                                                 name_entry_id(name)))
  else:
    expected_value = style_with_spaces
    has_entry = False
    for name in ttFont['name'].names:
      if name.nameID == NameID.TYPOGRAPHIC_SUBFAMILY_NAME:
        string = name.string.decode(name.getEncoding()).strip()
        if string == expected_value:
          has_entry = True
        else:
          failed = True
          yield FAIL, Message("non-ribbi-bad-value",
                              ("Entry {} on the 'name' table: "
                               "Expected '{}' "
                               "but got '{}'.").format(name_entry_id(name),
                                                       expected_value,
                                                       string))
    if not failed and not has_entry:
      failed = True
      yield FAIL, Message("non-ribbi-lacks-entry",
                          ("non-RIBBI fonts must have a"
                           " TYPOGRAPHIC_SUBFAMILY_NAME entry"
                           " on the name table."))
  if not failed:
    yield PASS, "TYPOGRAPHIC_SUBFAMILY_NAME entries are all good."
959973
def get_definition_from_renderer(renderer):
    """"""

    config = {
        'colors': [[x[0], x[1].to_hex()] for x in renderer.colormap],
        'options': {}
    }

    if renderer.fill_value:
        config['options']['fill_value'] = renderer.fill_value

    if isinstance(renderer, StretchedRenderer):
        config['type'] = 'stretched'
        config['options']['color_space'] = renderer.colorspace
    elif isinstance(renderer, UniqueValuesRenderer):
        config['type'] = 'unique'
        if renderer.labels:
            config['options']['labels'] = renderer.labels
    elif isinstance(renderer, ClassifiedRenderer):
        config['type'] = 'classified'
    else:
        raise ValueError('{0} is not a valid renderer type'.format(renderer.__class__.__name__))

    return config
545179
function guessFontStyle(basename) {
  return basename
    .split('-')
    .slice(1)
    .map(item => item.toLowerCase())
    .reduce((prev, item) => {
      if (fontStyleKeywords.indexOf(item) >= 0) {
        return `font-style:${item};`
      }

      return prev
    }, '')
}
745527
private static void parseStencilSet(JSONObject modelJSON,
                                        Diagram current) throws JSONException {
        // get stencil type
        if (modelJSON.has("stencilset")) {
            JSONObject object = modelJSON.getJSONObject("stencilset");
            String url = null;
            String namespace = null;

            if (object.has("url")) {
                url = object.getString("url");
            }

            if (object.has("namespace")) {
                namespace = object.getString("namespace");
            }

            current.setStencilset(new StencilSet(url,
                                                 namespace));
        }
    }
660343
def qname(self):
        
        if self.prefix is None:
            return self.name
        else:
            return '%s:%s' % (self.prefix, self.name)
941308
def _get_queue_name(cls, queue_name=None):
        
        if queue_name is None and cls.queue_name is None:
            raise LimpydJobsException("Queue's name not defined")
        if queue_name is None:
            return cls.queue_name
        return queue_name
731081
def _build_filename_from_browserstack_json(j):
    
    filename = ''
    device = j['device'] if j['device'] else 'Desktop'
    if j['state'] == 'done' and j['image_url']:
        detail = [device, j['os'], j['os_version'],
                  j['browser'], j['browser_version'], '.jpg']
        filename = '_'.join(item.replace(" ", "_") for item in detail if item)
    else:
        print 'screenshot timed out, ignoring this result'
    return filename
1126044
function getName(name, width, separator) {

        // handle empty separator as no separator
        if (typeof separator === 'undefined') {
            separator = '';
        }

        if (name) {
            return separator + name;
        } else {
            return separator + width;
        }
    }
385041
def _qname(self, name):
        
        if isinstance(name, QName):
            return name
        if not isinstance(name, str):
            raise TypeError("{} must be str".format(name))
        if name == '':
            return name
        if name.startswith('{'):
            return name
        prefix, tag = name.split(':', maxsplit=1)
        uri = self.NS[prefix]
        return QName(uri, tag)
901892
def com_google_fonts_check_metadata_nameid_font_name(ttFont, style, font_metadata):
  
  from fontbakery.utils import get_name_entry_strings
  from fontbakery.constants import RIBBI_STYLE_NAMES

  if style in RIBBI_STYLE_NAMES:
    font_familynames = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME)
    nameid = NameID.FONT_FAMILY_NAME
  else:
    font_familynames = get_name_entry_strings(ttFont, NameID.TYPOGRAPHIC_FAMILY_NAME)
    nameid = NameID.TYPOGRAPHIC_FAMILY_NAME

  if len(font_familynames) == 0:
    yield FAIL, Message("lacks-entry",
                        (f"This font lacks a {NameID(nameid).name} entry"
                         f" (nameID={nameid}) in the name table."))
  else:
    for font_familyname in font_familynames:
      if font_familyname != font_metadata.name:
        yield FAIL, Message("mismatch",
                            ("Unmatched familyname in font:"
                             " TTF has \"{}\" while METADATA.pb has"
                             " name=\"{}\".").format(font_familyname,
                                                     font_metadata.name))
      else:
        yield PASS, ("OK: Family name \"{}\" is identical"
                     " in METADATA.pb and on the"
                     " TTF file.").format(font_metadata.name)
1053974
def process_stencil(cookbook, cookbook_name, template_pack,
                    force_argument, stencil_set, stencil, written_files):
    
    # force can be passed on the command line or forced in a stencil's options
    force = force_argument or stencil['options'].get('force', False)

    stencil['files'] = stencil.get('files') or {}
    files = {
        # files.keys() are template paths, files.values() are target paths
        # {path to template: rendered target path, ... }
        os.path.join(stencil_set.path, tpl): os.path.join(cookbook.path, tgt)
        for tgt, tpl in stencil['files'].items()
    }

    stencil['partials'] = stencil.get('partials') or {}
    partials = {
        # files.keys() are template paths, files.values() are target paths
        # {path to template: rendered target path, ... }
        os.path.join(stencil_set.path, tpl): os.path.join(cookbook.path, tgt)
        for tgt, tpl in stencil['partials'].items()
    }

    stencil['binaries'] = stencil.get('binaries') or {}
    binaries = {
        # files.keys() are binary paths, files.values() are target paths
        # {path to binary: rendered target path, ... }
        os.path.join(stencil_set.path, tpl): os.path.join(cookbook.path, tgt)
        for tgt, tpl in stencil['binaries'].items()
    }

    template_map = _build_template_map(cookbook, cookbook_name, stencil)

    filetable = templating.render_templates(*files.keys(), **template_map)
    _render_templates(files, filetable, written_files, force)

    parttable = templating.render_templates(*partials.keys(), **template_map)
    _render_templates(partials, parttable, written_files, force, open_mode='a')

    # no templating needed for binaries, just pass off to the copy method
    _render_binaries(binaries, written_files)

    # merge metadata.rb dependencies
    stencil_metadata_deps = {'depends': stencil.get('dependencies', {})}
    stencil_metadata = book.MetadataRb.from_dict(stencil_metadata_deps)
    cookbook.metadata.merge(stencil_metadata)

    # merge Berksfile dependencies
    stencil_berks_deps = {'cookbook': stencil.get('berks_dependencies', {})}
    stencil_berks = book.Berksfile.from_dict(stencil_berks_deps)
    cookbook.berksfile.merge(stencil_berks)

    return cookbook
780291
def normalizeDefaultLayerName(value, font):
    
    value = normalizeLayerName(value)
    if value not in font.layerOrder:
        raise ValueError("No layer with the name '%s' exists." % value)
    return unicode(value)
936221
function() {
      var name = this.jCal[NAME_INDEX];
      var designSet = this._designSet;

      if (name in designSet.property) {
        var details = designSet.property[name];
        if ('defaultType' in details) {
          return details.defaultType;
        }
      }
      return design.defaultType;
    }
1307873
def _qname(self) -> Optional[QualName]:
        """"""
        if self.test_string("*"):
            self.skip_ws()
            return False
        ident = self.yang_identifier()
        ws = self.skip_ws()
        try:
            next = self.peek()
        except EndOfInput:
            return ident, None
        if next == "(":
            return self._node_type(ident)
        if not ws and self.test_string(":"):
            res = (
                self.yang_identifier(),
                self.sctx.schema_data.prefix2ns(ident, self.sctx.text_mid))
        else:
            res = (ident, None)
        self.skip_ws()
        return res
518295
def _get_name(self, graph, group=None):
        
        if group is not None:
            graph = graph.get_subgraph(group, normalize=True)

        fingerprint = graph.fingerprint.tobytes()
        name = self.name_cache.get(fingerprint)
        if name is None:
            name = "NM%02i" % len(self.name_cache)
            self.name_cache[fingerprint] = name
        return name