Extract all known zone labels
    - main code
    - keys (postal...)
    - name translation in every supported languages
505086
def labels_for_zone(zone):
    '''
    
    '''
    labels = set([zone.name, zone.code] + zone.keys_values)
    for lang in current_app.config['LANGUAGES'].keys():
        with language(lang):
            labels.add(_(zone.name))
    return list(labels)
104609
def allLocales(self):
        
        if self._allLocales:
            return self._allLocales
        
        expr = re.compile('[a-z]+_[A-Z]+')
        locales = babel.core.localedata.locale_identifiers()
        babel_locales = {}
        for locale in locales:
            if expr.match(locale):
                babel_locale = babel.Locale.parse(locale)
                if babel_locale.territory and babel_locale.language:
                    babel_locales[babel_locale.territory] = babel_locale
        
        babel_locales = babel_locales.values()
        babel_locales.sort(key=str)
        self._allLocales = babel_locales
        return self._allLocales
1294348
def find_locales(self) -> Dict[str, gettext.GNUTranslations]:
        
        translations = {}

        for name in os.listdir(self.path):
            if not os.path.isdir(os.path.join(self.path, name)):
                continue
            mo_path = os.path.join(self.path, name, 'LC_MESSAGES', self.domain + '.mo')

            if os.path.exists(mo_path):
                with open(mo_path, 'rb') as fp:
                    translations[name] = gettext.GNUTranslations(fp)
            elif os.path.exists(mo_path[:-2] + 'po'):
                raise RuntimeError(f"Found locale '{name} but this language is not compiled!")

        return translations
698175
def translation_key
      key = name.gsub(/Motivation\z/, '')
      key.gsub!(/^.*::/, '')
      key.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
      key.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
      key.tr!("-", "_")
      key.downcase!
    end
794515
def key_description(self):
        ""
        vk, scan, flags = self._get_key_info()
        desc = ''
        if vk:
            if vk in CODE_NAMES:
                desc = CODE_NAMES[vk]
            else:
                desc = "VK %d"% vk
        else:
            desc = "%s"% self.key

        return desc
581667
function _extractLocaleDays(abbr, locale) {
      if(abbr) {
        return cldr ? cldr.extractDayNames(locale).format.abbreviated : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
      }
      else {
        return cldr ? cldr.extractDayNames(locale).format.wide : ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
      }
    }
1244803
def extract_code_globals(cls, co):
        
        out_names = cls._extract_code_globals_cache.get(co)
        if out_names is None:
            try:
                names = co.co_names
            except AttributeError:
                # PyPy "builtin-code" object
                out_names = set()
            else:
                out_names = set(names[oparg]
                                for op, oparg in _walk_global_ops(co))

                # see if nested function have any global refs
                if co.co_consts:
                    for const in co.co_consts:
                        if type(const) is types.CodeType:
                            out_names |= cls.extract_code_globals(const)

            cls._extract_code_globals_cache[co] = out_names

        return out_names
759890
def get_zonecode():
    '''
    
    '''
    tz_object = pytz.timezone(get_zone())
    loc_time = tz_object.localize(datetime.utcnow())
    return loc_time.tzname()
433888
private function parseKey()
    {
        try {
            preg_match('/^([^\.]*)\.([^\:]*)/', $this->argument('key'), $matches);

            $this->fileName = $matches[1];
            $this->key = $matches[2];
        } catch (\ErrorException $e) {
            if (! $this->key) {
                $this->error('Could not recognize the key you want to translate.');

                return false;
            }
        }

        if (Str::contains($this->fileName, '::')) {
            try {
                $parts = explode('::', $this->fileName);

                $this->manager->setPathToVendorPackage($parts[0]);

                $this->packageName = $parts[0];
            } catch (\ErrorException $e) {
                $this->error('Could not recognize the package.');

                return false;
            }
        }

        return true;
    }
24383
def title_translations(self, key, value):
    """"""
    return {
        'language': langdetect.detect(value.get('a')),
        'source': value.get('9'),
        'subtitle': value.get('b'),
        'title': value.get('a'),
    }
997868
def _handle_tag_definefontalignzones(self):
        """"""
        obj = _make_object("DefineFontAlignZones")
        obj.FontId = unpack_ui16(self._src)
        bc = BitConsumer(self._src)
        obj.CSMTableHint = bc.u_get(2)
        obj.Reserved = bc.u_get(6)

        obj.ZoneTable = zone_records = []
        glyph_count = self._last_defined_glyphs_quantity
        self._last_defined_glyphs_quantity = None
        for _ in range(glyph_count):
            zone_record = _make_object("ZoneRecord")
            zone_records.append(zone_record)
            zone_record.NumZoneData = unpack_ui8(self._src)
            zone_record.ZoneData = zone_data = []
            for _ in range(zone_record.NumZoneData):
                zone_datum = _make_object("ZoneData")
                zone_data.append(zone_datum)
                zone_datum.AlignmentCoordinate = unpack_float16(self._src)
                zone_datum.Range = unpack_float16(self._src)
            bc = BitConsumer(self._src)
            zone_record.Reserved = bc.u_get(6)
            zone_record.ZoneMaskY = bc.u_get(1)
            zone_record.ZoneMaskX = bc.u_get(1)
        return obj
311814
function extractTodoTitle (content, conf) {
  var result = null;

  var labels = {};
  _.each(conf, function (value, key) {
    if (value && key.match(/^label\./)) {
      var trigger = key.substring(6);
      if (conf["label-whitespace"]) {
        trigger += " ";
      }
      labels[trigger] = value;
    }
  });

  if (_.isString(content)) {
    _.find(Object.keys(labels), function (trigger) {
      var index;
      if (conf["case-sensitive"]) {
        index = content.indexOf(trigger);
      } else {
        index = content.toUpperCase().indexOf(trigger.toUpperCase());
      }

      if (index !== -1) {
        var title = content.substring(index + trigger.length).trim();
        var issue = null;
        if (title && !isCode(title)) {
          var match = title.match(/^\s+#(\d+)\s+/);
          if (match) {
            issue = match[1];
            title = title.substring(match[0].length);
          }
          result = {
            "title":  title,
            "label":  labels[trigger],
            "issue":  Number(issue)
          };
        }
        return true; // break
      }
    });
  }

  return result;
}
312402
def extract_country_code(input, options={})
      options[:region] ||= Phoney.region
      intl_prefix = international_call_prefix_for(input, region: options[:region])
      
      # only try to extract a country code if we're dialing internationally
      if intl_prefix
        rest   = input[intl_prefix.count(NUMPAD_CHARS)..-1]
        region = Phoney::Region.all.find { |r| rest.start_with? r.country_code.to_s }
        
        region.country_code.to_s if region
      end
    end
197825
def _extract_translations(self, domains):
        """"""
        for domain, options in domains.items():
            # Create the extractor
            extractor = babel_frontend.extract_messages()
            extractor.initialize_options()
            # The temporary location to write the `.pot` file
            extractor.output_file = options['pot']
            # Add the comments marked with 'tn:' to the translation file for translators to read. Strip the marker.
            extractor.add_comments = ['tn:']
            extractor.strip_comments = True
            # The directory where the sources for this domain are located
            extractor.input_paths = [options['source']]
            # Pass the metadata to the translator
            extractor.msgid_bugs_address = self.manager.args.contact
            extractor.copyright_holder = self.manager.args.copyright
            extractor.version = self.manager.args.version
            extractor.project = self.manager.args.project
            extractor.finalize_options()
            # Add keywords for lazy translation functions, based on their non-lazy variants
            extractor.keywords.update({
                'gettext_lazy': extractor.keywords['gettext'],
                'ngettext_lazy': extractor.keywords['ngettext'],
                '__': extractor.keywords['gettext'],  # double underscore for lazy
            })
            # Do the extraction
            _run_babel_command(extractor)
953878
def extract_object_names_from_docs(filename):
    """"""
    text = split_code_and_text_blocks(filename)[1]
    text = '\n'.join(t[1] for t in text if t[0] == 'text')
    regex = re.compile(r':(?:'
                       r'func(?:tion)?|'
                       r'meth(?:od)?|'
                       r'attr(?:ibute)?|'
                       r'obj(?:ect)?|'
                       r'class):`(\S*)`'
                       )
    return [(x, x) for x in re.findall(regex, text)]
772415
def _get_encoding(encoding_or_label):
    
    if hasattr(encoding_or_label, 'codec_info'):
        return encoding_or_label

    encoding = lookup(encoding_or_label)
    if encoding is None:
        raise LookupError('Unknown encoding label: %r' % encoding_or_label)
    return encoding
129217
def labels(self):
        
        if self._labels is None:
            cmd = ["skopeo", "inspect", self.skopeo_target]
            self._labels = json.loads(subprocess.check_output(cmd))["Labels"]
        return self._labels