set_encoding is False when resizing
18212
def refresh_win(self, set_encoding=True):
        
        self._fix_geometry()
        self.init_window(set_encoding)
        self._win.bkgdset(' ', curses.color_pair(3))
        self._win.erase()
        self._win.box()
        self._win.addstr(0,
            int((self.maxX - len(self._title)) / 2),
            self._title,
            curses.color_pair(4))
        for i in range(1, self.maxX - 1):
            try:
                self._win.addch(self.maxY -4,  i, '─', curses.color_pair(3))
            except:
                self._win.addstr(self.maxY -4 , i, u'─'.encode('utf-8'), curses.color_pair(3))
        try:
            self._win.addch(self.maxY - 4, 0, '├', curses.color_pair(3))
            self._win.addch(self.maxY - 4, self.maxX - 1, '┤', curses.color_pair(3))
        except:
            self._win.addstr(self.maxY - 4,  0, u'├'.encode('utf-8'), curses.color_pair(3))
            self._win.addstr(self.maxY - 4,  self.maxX - 1, u'┤'.encode('utf-8'), curses.color_pair(3))

        self._num_of_rows = int(len(self._encodings) / self._num_of_columns)
        self._get_invalids()
        self.refresh_selection()
372449
def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
    
    # Handle the common case first for performance reasons.
    if isinstance(s, bytes):
        if encoding == 'utf-8':
            return s
        else:
            return s.decode('utf-8', errors).encode(encoding, errors)
    if strings_only and is_protected_type(s):
        return s
    if isinstance(s, memoryview):
        return bytes(s)
    if not isinstance(s, str):
        return str(s).encode(encoding, errors)
    else:
        return s.encode(encoding, errors)
900532
def resizeTile(index, size):
    """"""
    resized = tiles[index].resize(size, Image.ANTIALIAS)
    return sImage(resized.tostring(), resized.size, resized.mode)
576533
def _normalize_utf8_keys(kwargs):
  """"""
  if any(type(key) is binary_type for key in kwargs.keys()):
    # This is to preserve the original dict type for kwargs.
    dict_type = type(kwargs)
    return dict_type([(text_type(k), v) for k, v in kwargs.items()])
  return kwargs
819680
private void resizeValueText() {
        double maxWidth = size * 0.86466165;
        double fontFactor = -0.035 * ( Math.max(1, gauge.getDecimals() ) - 1 ) + 0.2556391;
        double fontSize = size * fontFactor;
        valueText.setFont(Fonts.latoLight(fontSize));
        if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }
        valueText.relocate((size - valueText.getLayoutBounds().getWidth()) * 0.5, (size - valueText.getLayoutBounds().getHeight()) * 0.5);
    }
637249
def _encode_string(s):
        
        if six.PY2 and isinstance(s, unicode):
            return s.encode('utf-8')
        return s
759152
@Override protected void resize() {
        width  = clock.getWidth() - clock.getInsets().getLeft() - clock.getInsets().getRight();
        height = clock.getHeight() - clock.getInsets().getTop() - clock.getInsets().getBottom();

        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        if (width > 0 && height > 0) {
            pane.setMaxSize(width, height);
            pane.relocate((clock.getWidth() - height) * 0.5, (clock.getHeight() - height) * 0.5);

            if (clock.isTextVisible()) {
                if (null == customFont) {
                    timeText.setFont(Locale.US == clock.getLocale() ? Fonts.robotoLight(0.5 * height) : Fonts.robotoLight(0.6 * height));
                } else {
                    timeText.setFont(Locale.US == clock.getLocale() ? new Font(customFont.getName(), 0.5 * height) : new Font(customFont.getName(), 0.6 * height));
                }
                timeText.setX((width - timeText.getLayoutBounds().getWidth()) * 0.5);
                if (clock.isDateVisible()) {
                    timeText.setY(height * 0.3);
                } else {
                    timeText.setY(height * 0.5);
                }
            }
            if (clock.isDateVisible()) {
                if (null == customFont) {
                    dateText.setFont(Fonts.robotoLight(0.3 * height));
                } else {
                    dateText.setFont(new Font(customFont.getName(), 0.3 * height));
                }
                dateText.setX((width - dateText.getLayoutBounds().getWidth()) * 0.5);
                dateText.setY(height * 0.8);
            }
        }
    }
1058088
def _resize(self, shape, format=None, internalformat=None):
        
        shape = self._normalize_shape(shape)

        # Check
        if not self._resizable:
            raise RuntimeError("Texture is not resizable")

        # Determine format
        if format is None:
            format = self._formats[shape[-1]]
            # Keep current format if channels match
            if self._format and \
               self._inv_formats[self._format] == self._inv_formats[format]:
                format = self._format
        else:
            format = check_enum(format)

        if internalformat is None:
            # Keep current internalformat if channels match
            if self._internalformat and \
               self._inv_internalformats[self._internalformat] == shape[-1]:
                internalformat = self._internalformat
        else:

            internalformat = check_enum(internalformat)

        # Check
        if format not in self._inv_formats:
            raise ValueError('Invalid texture format: %r.' % format)
        elif shape[-1] != self._inv_formats[format]:
            raise ValueError('Format does not match with given shape. '
                             '(format expects %d elements, data has %d)' %
                             (self._inv_formats[format], shape[-1]))
        
        if internalformat is None:
            pass
        elif internalformat not in self._inv_internalformats:
            raise ValueError(
                'Invalid texture internalformat: %r. Allowed formats: %r' 
                % (internalformat, self._inv_internalformats)
            )
        elif shape[-1] != self._inv_internalformats[internalformat]:
            raise ValueError('Internalformat does not match with given shape.')

        # Store and send GLIR command
        self._shape = shape
        self._format = format
        self._internalformat = internalformat
        self._glir.command('SIZE', self._id, self._shape, self._format, 
                           self._internalformat)
141543
public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false)
    {
        if ($this->getSourceWidth() <= $max_width && $this->getSourceHeight() <= $max_height && $allow_enlarge === false) {
            return $this;
        }

        $ratio  = $this->getSourceHeight() / $this->getSourceWidth();
        $width = $max_width;
        $height = $width * $ratio;

        if ($height > $max_height) {
            $height = $max_height;
            $width = $height / $ratio;
        }

        return $this->resize($width, $height, $allow_enlarge);
    }
1057983
def set_size(self, name: str, size: int):
        """"""
        if self._needs_to_be_in_name_map(name):
            if len(name) >= 128:
                raise ValueError("Name is too long")
            self.name_map[name] = size
        else:
            crc32 = binascii.crc32(name.encode())
            self.crc32_map[crc32] = size
690766
def encoding(encoding=True):
    """"""
    if isinstance(encoding, str):
        encoding = True

    def dec(f):
        f._nvim_decode = encoding
        return f
    return dec
1250850
public void setCustomFontEnabled(final boolean ENABLED) {
        if (null == customFontEnabled) {
            _customFontEnabled = ENABLED;
            fireTileEvent(RESIZE_EVENT);
        } else {
            customFontEnabled.set(ENABLED);
        }
    }
600452
@Override protected void resize() {
        double width  = gauge.getWidth() - gauge.getInsets().getLeft() - gauge.getInsets().getRight();
        double height = gauge.getHeight() - gauge.getInsets().getTop() - gauge.getInsets().getBottom();
        size = width < height ? width : height;

        if (size > 0 ) {
            double centerX   = size * 0.5;
            double centerY   = size * 0.5;
            double barRadius = size * 0.3125;
            double barWidth  = size * 0.18382353;

            pane.setMaxSize(size, size);
            pane.relocate((gauge.getWidth() - width) * 0.5, (gauge.getHeight() - height) * 0.5);

            barBackground.setCenterX(centerX);
            barBackground.setCenterY(centerY);
            barBackground.setRadiusX(barRadius);
            barBackground.setRadiusY(barRadius);
            barBackground.setStrokeWidth(barWidth);
            barBackground.setStartAngle(ANGLE_RANGE * 0.5 + 90);
            barBackground.setLength(-ANGLE_RANGE);

            sectionCanvas.setWidth(size);
            sectionCanvas.setHeight(size);

            // Areas, Sections and Tick Marks
            sectionCanvas.setCache(false);
            sectionCtx.clearRect(0, 0, size, size);
            if (gauge.isGradientBarEnabled() && gauge.getGradientLookup() != null) {
                drawGradientBar();
                if (gauge.getMajorTickMarksVisible()) drawTickMarks();
            } else if (gauge.getSectionsVisible()) {
                drawSections();
                if (gauge.getMajorTickMarksVisible()) drawTickMarks();
            }
            sectionCanvas.setCache(true);
            sectionCanvas.setCacheHint(CacheHint.QUALITY);

            double needleWidth  = size * 0.26470588;
            double needleHeight = size * 0.47426471;

            needle.setCache(false);

            needleMoveTo1.setX(0.277777777777778 * needleWidth); needleMoveTo1.setY(0.720930232558139 * needleHeight);

            needleCubicCurveTo2.setControlX1(0.277777777777778 * needleWidth); needleCubicCurveTo2.setControlY1(0.652428682170543 * needleHeight);
            needleCubicCurveTo2.setControlX2(0.377268055555556 * needleWidth); needleCubicCurveTo2.setControlY2(0.596899224806202 * needleHeight);
            needleCubicCurveTo2.setX(0.5 * needleWidth); needleCubicCurveTo2.setY(0.596899224806202 * needleHeight);

            needleCubicCurveTo3.setControlX1(0.622731944444444 * needleWidth); needleCubicCurveTo3.setControlY1(0.596899224806202 * needleHeight);
            needleCubicCurveTo3.setControlX2(0.722222222222222 * needleWidth); needleCubicCurveTo3.setControlY2(0.652428682170543 * needleHeight);
            needleCubicCurveTo3.setX(0.722222222222222 * needleWidth); needleCubicCurveTo3.setY(0.720930232558139 * needleHeight);

            needleCubicCurveTo4.setControlX1(0.722222222222222 * needleWidth); needleCubicCurveTo4.setControlY1(0.789431782945736 * needleHeight);
            needleCubicCurveTo4.setControlX2(0.622731944444444 * needleWidth); needleCubicCurveTo4.setControlY2(0.844961240310077 * needleHeight);
            needleCubicCurveTo4.setX(0.5 * needleWidth); needleCubicCurveTo4.setY(0.844961240310077 * needleHeight);

            needleCubicCurveTo5.setControlX1(0.377268055555556 * needleWidth); needleCubicCurveTo5.setControlY1(0.844961240310077 * needleHeight);
            needleCubicCurveTo5.setControlX2(0.277777777777778 * needleWidth); needleCubicCurveTo5.setControlY2(0.789431782945736 * needleHeight);
            needleCubicCurveTo5.setX(0.277777777777778 * needleWidth); needleCubicCurveTo5.setY(0.720930232558139 * needleHeight);

            needleMoveTo7.setX(0); needleMoveTo7.setY(0.720930232558139 * needleHeight);
            
            needleCubicCurveTo8.setControlX1(0); needleCubicCurveTo8.setControlY1(0.875058139534884 * needleHeight);
            needleCubicCurveTo8.setControlX2(0.223854166666667 * needleWidth); needleCubicCurveTo8.setControlY2(needleHeight);
            needleCubicCurveTo8.setX(0.5 * needleWidth); needleCubicCurveTo8.setY(needleHeight);

            needleCubicCurveTo9.setControlX1(0.776145833333333 * needleWidth); needleCubicCurveTo9.setControlY1(needleHeight);
            needleCubicCurveTo9.setControlX2(needleWidth); needleCubicCurveTo9.setControlY2(0.875058139534884 * needleHeight);
            needleCubicCurveTo9.setX(needleWidth); needleCubicCurveTo9.setY(0.720930232558139 * needleHeight);

            needleCubicCurveTo10.setControlX1(needleWidth); needleCubicCurveTo10.setControlY1(0.566860465116279 * needleHeight);
            needleCubicCurveTo10.setControlX2(0.5 * needleWidth); needleCubicCurveTo10.setControlY2(0);
            needleCubicCurveTo10.setX(0.5 * needleWidth); needleCubicCurveTo10.setY(0);

            needleCubicCurveTo11.setControlX1(0.5 * needleWidth); needleCubicCurveTo11.setControlY1(0);
            needleCubicCurveTo11.setControlX2(0); needleCubicCurveTo11.setControlY2(0.566860465116279 * needleHeight);
            needleCubicCurveTo11.setX(0); needleCubicCurveTo11.setY(0.720930232558139 * needleHeight);

            needle.setCache(true);
            needle.setCacheHint(CacheHint.ROTATE);

            needle.relocate((size - needle.getLayoutBounds().getWidth()) * 0.5, centerY - needle.getLayoutBounds().getHeight() + needle.getLayoutBounds().getWidth() * 0.5);
            needleRotate.setPivotX(needle.getLayoutBounds().getWidth() * 0.5);
            needleRotate.setPivotY(needle.getLayoutBounds().getHeight() - needle.getLayoutBounds().getWidth() * 0.5);
        }
    }
34421
def resize(self):
        """"""
        yext = self.system.dae.m - len(self.unamey)
        xext = self.system.dae.n - len(self.unamex)
        if yext > 0:
            self.unamey.extend([''] * yext)
            self.fnamey.extend([''] * yext)
        if xext > 0:
            self.unamex.extend([''] * xext)
            self.fnamex.extend([''] * xext)
543867
function makeEncoding($height = 0, $width = 0, $data = 0, $fw = 0, $bytes = 0, $datablocks = 0, $rsblocks = 0) {
        $t = array(
            'height' => $height,
            'width' => $width,
            'data' => $data,
            'fw' => $fw,
            'bytes' => $bytes,
            'datablocks' => $datablocks,
            'rsblocks' => $rsblocks
        );
        return $t;
    }
619612
private void resize(int newSize)
  {
    long []newKeys = new long[newSize];
    Object []newValues = new Object[newSize];
    byte []newFlags = new byte[newSize];

    for (int i = 0; i < newSize; i++)
      newKeys[i] = DEAD_KEY;

    mask = newKeys.length - 1;

    for (int i = 0; i < keys.length; i++) {
      if (keys[i] == DEAD_KEY || (flags[i] & DELETED) != 0)
        continue;

      int hash = (int) keys[i] & mask;

      while (true) {
        if (newKeys[hash] == DEAD_KEY) {
          newKeys[hash] = keys[i];
          newValues[hash] = values[i];
          newFlags[hash] = flags[i];
          break;
        }
        hash = (hash + 1) & mask;
      }
    }

    keys = newKeys;
    values = newValues;
    flags = newFlags;
  }
815365
def _normalize_encoding(encoding):
    
    if encoding is None:
        return None
    # lower() + '_' / '-' conversion
    encoding = encoding.replace('_', '-').lower()
    if encoding == 'utf-8' or encoding.startswith('utf-8-'):
        return 'utf-8'
    for variant in ['latin-1', 'iso-latin-1', 'iso-8859-1']:
        if (encoding == variant or
            encoding.startswith(variant + '-')):
            return 'iso-8859-1'
    return encoding