Writes grade_letters
429557
protected function write_grade_letters() {

        $this->xmlwriter->begin_tag('grade_letters');
        foreach ($this->converter->get_stash_itemids('gradebook_gradeletter') as $gradeletterid) {
            $gradeletter = $this->converter->get_stash('gradebook_gradeletter', $gradeletterid);
            $this->write_xml('grade_letter', $gradeletter, array('/grade_letter/id'));
        }
        $this->xmlwriter->end_tag('grade_letters');
    }
792572
def write_a_grad_fill(gradient)
      attributes = [
        ['flip',        'none'],
        ['rotWithShape', 1]
      ]
      attributes = [] if gradient[:type] == 'linear'

      @writer.tag_elements('a:gradFill', attributes) do

        # Write the a:gsLst element.
        write_a_gs_lst(gradient)

        if gradient[:type] == 'linear'
          # Write the a:lin element.
          write_a_lin(gradient[:angle])
        else
          # Write the a:path element.
          write_a_path(gradient[:type])

          # Write the a:tileRect element.
          write_a_tile_rect(gradient[:type])
        end
      end
    end
432552
def write(self, fd):
        
        print >>fd, self.classHead
        for t in self.items:
            print >>fd, t
        print >>fd, self.classFoot
772292
def _print_bits(self,norm=2.3, height=8.0):
        
        bits   = []
        tots   = []
        str    = []
        for i in range(self.width):
            D = {}
            tot = 0
            for letter in ['A', 'C', 'T', 'G']:
                if self.logP:
                    Pij = pow(2.0, self.logP[i][letter])
                else:
                    Pij = pow(2.0, self.ll[i][letter]) * self.background[letter]
                if Pij > 0.01:
                    '''Old'''
                    D[letter] = Pij * self.ll[i][letter]
                    #'''new'''
                    #Q = self.background[letter]
                    #D[letter] = ( Pij * math.log(Pij) - Pij * math.log(Q) ) / math.log(2.0)
                    '''for both old and new'''
                    tot = tot + D[letter]
            bits.append(D)
            tots.append(tot)
        for i in range(self.width):
            s = []
            _l = bits[i].keys()
            _l.sort(lambda x,y,D=bits[i]: cmp(D[y],D[x]))
            for key in _l:
                for j in range(int(bits[i][key] / norm * height)):
                    s.append(key)
            str.append(''.join(s))
        fmt = '%%%ds'%height
        print '#  %s'%('-'*self.width)
        for h in range(int(height)):
            sys.stdout.write("#  ")
            for i in range(self.width):
                sys.stdout.write((fmt%str[i])[h])
            if h == 0:
                sys.stdout.write(' -- %4.2f bits\n'%norm)
            elif h == height-1:
                sys.stdout.write(' -- %4.2f bits\n'%(norm/height))
            else:
                sys.stdout.write('\n')
        print '#  %s'%('-'*self.width)
        print '#  %s'%self.oneletter
686028
def write_into(self, block, level=0):
        """"""

        for line, l in self._lines:
            block.write_line(line, level + l)

        for name, obj in _compat.iteritems(self._deps):
            block.add_dependency(name, obj)
189980
protected function write_grade_categories() {

        $this->xmlwriter->begin_tag('grade_categories');
        foreach ($this->converter->get_stash_itemids('gradebook_gradecategory') as $gradecategoryid) {
            $gradecategory = $this->converter->get_stash('gradebook_gradecategory', $gradecategoryid);
            $path = $this->calculate_category_path($gradecategoryid);
            $gradecategory['depth'] = count($path);
            $gradecategory['path']  = '/'.implode('/', $path).'/';
            $this->write_xml('grade_category', $gradecategory, array('/grade_category/id'));
        }
        $this->xmlwriter->end_tag('grade_categories');
    }
1362627
def writeline(self, text):
        """"""
        log.debug('writing line %r' % text)
        self.write(text+chr(10))
1164083
def write(self, text):
        """"""
        # similar to tqdm.write()
        # https://pypi.python.org/pypi/tqdm#writing-messages
        sys.stdout.write("\r")
        self._clear_line()

        _text = to_unicode(text)
        if PY2:
            _text = _text.encode(ENCODING)

        # Ensure output is bytes for Py2 and Unicode for Py3
        assert isinstance(_text, builtin_str)

        sys.stdout.write("{0}\n".format(_text))
474301
def write(self, more):
        """"""
        if more:
            self.output += str(more).upper()
            self.output += '\n'
906182
def write_lines(self, lines, level=0):
        """"""

        for line in lines:
            self.write_line(line, level)
1072646
def write_spelling(token_folder, spelling_file):
    
    token_pattern = r'[a-z]{3,}'
    tokens = []
    for base, dirlist, fnlist in os.walk(token_folder):
        for fn in fnlist:
            fp = os.path.join(base, fn)
            with open(fp) as f:
                toks = re.findall(token_pattern, f.read())
                tokens.extend(toks)

    token_ranked, _ = zip(*Counter(tokens).most_common())
    with open(spelling_file, 'w') as f:
        f.write('\n'.join(token_ranked))
1123225
def write_corrected(self, output, clobber=False):
        """"""

        # un-apply the flatfield if necessary
        if self.flatcorr != 'COMPLETE':
            self.science = self.science / self.invflat
            self.err = self.err / self.invflat

        # un-apply the post-flash if necessary
        if self.flshcorr != 'COMPLETE':
            self.science = self.science + self.flash

        # un-apply the dark if necessary
        if self.darkcorr != 'COMPLETE':
            self.science = self.science + self.dark

        # reverse the amp merge
        if (self.ampstring == 'ABCD'):
            tmp_1, tmp_2 = np.split(self.science, 2, axis=1)
            self.hdulist['sci', 1].data = tmp_1.copy()
            self.hdulist['sci', 2].data = tmp_2[::-1, :].copy()

            tmp_1, tmp_2 = np.split(self.err, 2, axis=1)
            self.hdulist['err', 1].data = tmp_1.copy()
            self.hdulist['err', 2].data = tmp_2[::-1, :].copy()
        else:
            self.hdulist['sci', 1].data = self.science.copy()
            self.hdulist['err', 1].data = self.err.copy()

        # Write the output
        self.hdulist.writeto(output, overwrite=clobber)
726259
private static void writeBits(StringBuilder sb, boolean r, boolean w, boolean x) {
        if (r) {
            sb.append('r');
        } else {
            sb.append('-');
        }
        if (w) {
            sb.append('w');
        } else {
            sb.append('-');
        }
        if (x) {
            sb.append('x');
        } else {
            sb.append('-');
        }
    }
1340314
def _writeText(self, image, text, pos):
        """"""
        offset = 0
        x, y = pos

        for c in text:
            # Write letter
            c_size = self.font.getsize(c)
            c_image = Image.new('RGBA', c_size, (0, 0, 0, 0))
            c_draw = ImageDraw.Draw(c_image)
            c_draw.text((0, 0), c, font=self.font, fill=(0, 0, 0, 255))

            # Transform
            c_image = self._rndLetterTransform(c_image)

            # Paste onto image
            image.paste(c_image, (x+offset, y), c_image)
            offset += c_size[0]
1328187
def cprint(
    text,
    fg=Color.normal,
    bg=Color.normal,
    fg_dark=False,
    bg_dark=False,
    underlined=False,
    parse=False,
):
    
    if parse:
        color_re = Color.color_re()
        lines = text.splitlines()
        count = len(lines)
        for i, line in enumerate(lines):
            previous = 0
            end = len(line)
            for match in color_re.finditer(line):
                sys.stdout.write(line[previous : match.start()])
                d = match.groupdict()
                set_color(
                    d["color"], fg_dark=False if d["dark"] is None else True
                )
                previous = match.end()
            sys.stdout.write(
                line[previous:end]
                + ("\n" if (i < (count - 1) or text[-1] == "\n") else "")
            )
    else:
        set_color(fg, bg, fg_dark, bg_dark, underlined)
        sys.stdout.write(text)
        set_color()
866340
def write(self, s, level=0, color=None):
        """"""
        if level > self.level:
            return
        if self.timestamps:
            timestamp = time.strftime(u'%H:%M:%S ')
        else:
            timestamp = u''
        with lock:
            if self.context:
                self.stream.write(u'%s%s> ' % (timestamp, self.context))
            elif self.context is None:
                self.stream.write(u'%s%s> ' % (timestamp, get_threadname()))
            self.stream.write(u'%s' % s, color=color)
            try:
                text_type = unicode
            except NameError:
                text_type = str
            self.stream.write(text_type(os.linesep))
            self.stream.flush()
1012747
public static void indent(int num, PrintWriter out) {
        if (num <= SIXTY_FOUR) {
            out.write(SIXTY_FOUR_SPACES, 0, num);
            return;
        } else if (num <= 128){
            out.write(SIXTY_FOUR_SPACES, 0, SIXTY_FOUR);
            out.write(SIXTY_FOUR_SPACES, 0, num - SIXTY_FOUR);
        } else {
            int times = num / SIXTY_FOUR;
            int rem = num % SIXTY_FOUR;
            for (int i = 0; i< times; i++) {
                out.write(SIXTY_FOUR_SPACES, 0, SIXTY_FOUR);
            }
            out.write(SIXTY_FOUR_SPACES, 0, rem);
            return;
        }
    }