Examples of PyException


Examples of org.python.core.PyException

                // Check the character for legality
                // The 64 in stead of the expected 63 is because
                // there are a few uuencodes out there that use
                // '@' as zero instead of space.
                if ( this_ch < ' ' || this_ch > (' ' + 64)) {
                    throw new PyException(Error, "Illegal char");
                }
                this_ch = (char)((this_ch - ' ') & 077);
            }
            // Shift it in on the low end, and see if there's
            // a byte ready for output.
            leftchar = (leftchar << 6) | (this_ch);
            leftbits += 6;
            if (leftbits >= 8) {
                leftbits -= 8;
                bin_data.append((char)((leftchar >> leftbits) & 0xff));
                leftchar &= ((1 << leftbits) - 1);
                bin_len--;
            }
        }
       
        // Finally, check that if there's anything left on the line
        // that it's whitespace only.
        while (ascii_len-- > 0) {
            this_ch = ascii_data.charAt(++i);
            // Extra '@' may be written as padding in some cases
            if (this_ch != ' ' && this_ch != '@' &&
                     this_ch != '\n' && this_ch != '\r') {
                throw new PyException(Error, "Trailing garbage");
            }
        }
       
        // finally, if we haven't decoded enough stuff, fill it up with zeros
        for (; i<bin_len; i++)
View Full Code Here

Examples of org.python.core.PyException

        int leftchar = 0;

        int bin_len = bin_data.length();
        if (bin_len > 45) {
            // The 45 is a limit that appears in all uuencode's
            throw new PyException(Error, "At most 45 bytes at once");
        }

        StringBuilder ascii_data = new StringBuilder();

        // Store the length */
 
View Full Code Here

Examples of org.python.core.PyException

                leftchar &= ((1 << leftbits) - 1);
            }
        }
        // Check that no bits are left
        if (leftbits != 0) {
            throw new PyException(Error, "Incorrect padding");
        }
        return new PyString(bin_data.toString());
    }
View Full Code Here

Examples of org.python.core.PyException

        StringBuilder ascii_data = new StringBuilder();

        int bin_len = bin_data.length();
        if (bin_len > BASE64_MAXBIN) {
            throw new PyException(Error,"Too much data for base64 line");
        }

        for (int i = 0; bin_len > 0 ; bin_len--, i++) {
            // Shift the data into our buffer
            leftchar = (leftchar << 8) | bin_data.charAt(i);
View Full Code Here

Examples of org.python.core.PyException

            // Get the byte and look it up
            this_ch = (char) table_a2b_hqx[ascii_data.charAt(i)];
            if (this_ch == SKIP)
                continue;
            if (this_ch == FAIL) {
                throw new PyException(Error, "Illegal char");
            }
            if (this_ch == DONE) {
                // The terminating colon
                done = true;
                break;
            }

            // Shift it into the buffer and see if any bytes are ready
            leftchar = (leftchar << 6) | (this_ch);
            leftbits += 6;
            if (leftbits >= 8) {
                leftbits -= 8;
                bin_data.append((char)((leftchar >> leftbits) & 0xff));
                leftchar &= ((1 << leftbits) - 1);
            }
        }

        if (leftbits != 0 && !done) {
            throw new PyException(Incomplete,
                                  "String has incomplete number of bytes");
        }

        return new PyTuple(Py.java2py(bin_data.toString()), Py.newInteger(done ? 1 : 0));
    }
View Full Code Here

Examples of org.python.core.PyException

        StringBuilder out_data = new StringBuilder();

        // Handle first byte separately (since we have to get angry
        // in case of an orphaned RLE code).
        if (--in_len < 0) throw new PyException(Incomplete);
        in_byte = in_data.charAt(i++);

        if (in_byte == RUNCHAR) {
            if (--in_len < 0) throw new PyException(Incomplete);
            in_repeat = in_data.charAt(i++);

            if (in_repeat != 0) {
                // Note Error, not Incomplete (which is at the end
                // of the string only). This is a programmer error.
                throw new PyException(Error, "Orphaned RLE code at start");
            }
            out_data.append(RUNCHAR);
        } else {
            out_data.append(in_byte);
        }

        while (in_len > 0) {
            if (--in_len < 0) throw new PyException(Incomplete);
            in_byte = in_data.charAt(i++);

            if (in_byte == RUNCHAR) {
                if (--in_len < 0) throw new PyException(Incomplete);
                in_repeat = in_data.charAt(i++);

                if (in_repeat == 0) {
                    // Just an escaped RUNCHAR value
                    out_data.append(RUNCHAR);
View Full Code Here

Examples of org.python.core.PyException

    public static void exit() {
        exit_thread();
    }

    public static void exit_thread() {
        throw new PyException(Py.SystemExit, new PyInteger(0));
    }
View Full Code Here

Examples of org.python.core.PyException

        "rename(old, new)\n\n" +
        "Rename a file or directory.");
    public static void rename(PyObject oldpath, PyObject newpath) {
        if (!new File(absolutePath(oldpath)).renameTo(new File(absolutePath(newpath)))) {
            PyObject args = new PyTuple(Py.Zero, new PyString("Couldn't rename file"));
            throw new PyException(Py.OSError, args);
        }
    }
View Full Code Here

Examples of org.python.core.PyException

        } else if (!file.isDirectory()) {
            throw Py.OSError(Errno.ENOTDIR, path);
        } else if (!file.delete()) {
            PyObject args = new PyTuple(Py.Zero, new PyString("Couldn't delete directory"),
                                        path);
            throw new PyException(Py.OSError, args);
        }
    }
View Full Code Here

Examples of org.python.core.PyException

        "used by the builtin import mechanism for sys.path items that are paths\n" +
        "to Zip archives.");

    public static PyObject ZipImportError;
    public static PyException ZipImportError(String message) {
        return new PyException(ZipImportError, message);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.