├── .gitignore ├── ConsoleWidget.h ├── Foundation.h ├── GLCamera.cpp ├── GLCamera.h ├── GLModelWidget.cpp ├── GLModelWidget.h ├── GameVoxelGrid.h ├── Global.h ├── Imath ├── IexBaseExc.cpp ├── IexBaseExc.h ├── ImathBox.cpp ├── ImathBox.h ├── ImathBoxAlgo.h ├── ImathColor.h ├── ImathColorAlgo.cpp ├── ImathColorAlgo.h ├── ImathEuler.h ├── ImathExc.h ├── ImathFrame.h ├── ImathFrustum.h ├── ImathFun.cpp ├── ImathFun.h ├── ImathGL.h ├── ImathGLU.h ├── ImathHalfLimits.h ├── ImathInt64.h ├── ImathInterval.h ├── ImathLimits.h ├── ImathLine.h ├── ImathLineAlgo.h ├── ImathMath.h ├── ImathMatrix.h ├── ImathMatrixAlgo.cpp ├── ImathMatrixAlgo.h ├── ImathPlane.h ├── ImathPlatform.h ├── ImathQuat.h ├── ImathRandom.cpp ├── ImathRandom.h ├── ImathRoots.h ├── ImathShear.cpp ├── ImathShear.h ├── ImathSphere.h ├── ImathVec.cpp ├── ImathVec.h ├── ImathVecAlgo.h ├── LICENSE └── half.h ├── ImportExport.cpp ├── ImportExport.h ├── LICENSE ├── LayersWidget.cpp ├── LayersWidget.h ├── MainWindow.cpp ├── MainWindow.h ├── NewGridDialog.cpp ├── NewGridDialog.h ├── NewGridDialog.ui ├── PaletteWidget.cpp ├── PaletteWidget.h ├── PreferencesDialog.cpp ├── PreferencesDialog.h ├── ProjectWidget.cpp ├── ProjectWidget.h ├── README.md ├── RayWalk.h ├── SproxelProject.cpp ├── SproxelProject.h ├── Tools.cpp ├── Tools.h ├── UndoManager.cpp ├── UndoManager.h ├── VoxelGridGroup.h ├── distro ├── common │ ├── lib │ │ ├── BaseHTTPServer.py │ │ ├── Bastion.py │ │ ├── CGIHTTPServer.py │ │ ├── ConfigParser.py │ │ ├── Cookie.py │ │ ├── DocXMLRPCServer.py │ │ ├── HTMLParser.py │ │ ├── MimeWriter.py │ │ ├── Queue.py │ │ ├── SimpleHTTPServer.py │ │ ├── SimpleXMLRPCServer.py │ │ ├── SocketServer.py │ │ ├── StringIO.py │ │ ├── UserDict.py │ │ ├── UserList.py │ │ ├── UserString.py │ │ ├── _LWPCookieJar.py │ │ ├── _MozillaCookieJar.py │ │ ├── __future__.py │ │ ├── __phello__.foo.py │ │ ├── _abcoll.py │ │ ├── _pyio.py │ │ ├── _strptime.py │ │ ├── _threading_local.py │ │ ├── _weakrefset.py │ │ ├── abc.py │ │ ├── aifc.py │ │ ├── antigravity.py │ │ ├── anydbm.py │ │ ├── argparse.py │ │ ├── ast.py │ │ ├── asynchat.py │ │ ├── asyncore.py │ │ ├── atexit.py │ │ ├── audiodev.py │ │ ├── base64.py │ │ ├── bdb.py │ │ ├── binhex.py │ │ ├── bisect.py │ │ ├── bsddb │ │ │ ├── __init__.py │ │ │ ├── db.py │ │ │ ├── dbobj.py │ │ │ ├── dbrecio.py │ │ │ ├── dbshelve.py │ │ │ ├── dbtables.py │ │ │ └── dbutils.py │ │ ├── cProfile.py │ │ ├── calendar.py │ │ ├── cgi.py │ │ ├── cgitb.py │ │ ├── chunk.py │ │ ├── cmd.py │ │ ├── code.py │ │ ├── codecs.py │ │ ├── codeop.py │ │ ├── collections.py │ │ ├── colorsys.py │ │ ├── commands.py │ │ ├── compileall.py │ │ ├── compiler │ │ │ ├── __init__.py │ │ │ ├── ast.py │ │ │ ├── consts.py │ │ │ ├── future.py │ │ │ ├── misc.py │ │ │ ├── pyassem.py │ │ │ ├── pycodegen.py │ │ │ ├── symbols.py │ │ │ ├── syntax.py │ │ │ ├── transformer.py │ │ │ └── visitor.py │ │ ├── contextlib.py │ │ ├── cookielib.py │ │ ├── copy.py │ │ ├── copy_reg.py │ │ ├── csv.py │ │ ├── ctypes │ │ │ ├── __init__.py │ │ │ ├── _endian.py │ │ │ ├── macholib │ │ │ │ ├── __init__.py │ │ │ │ ├── dyld.py │ │ │ │ ├── dylib.py │ │ │ │ └── framework.py │ │ │ ├── util.py │ │ │ └── wintypes.py │ │ ├── curses │ │ │ ├── __init__.py │ │ │ ├── ascii.py │ │ │ ├── has_key.py │ │ │ ├── panel.py │ │ │ ├── textpad.py │ │ │ └── wrapper.py │ │ ├── dbhash.py │ │ ├── decimal.py │ │ ├── difflib.py │ │ ├── dircache.py │ │ ├── dis.py │ │ ├── distutils │ │ │ ├── __init__.py │ │ │ ├── archive_util.py │ │ │ ├── bcppcompiler.py │ │ │ ├── ccompiler.py │ │ │ ├── cmd.py │ │ │ ├── command │ │ │ │ ├── __init__.py │ │ │ │ ├── bdist.py │ │ │ │ ├── bdist_dumb.py │ │ │ │ ├── bdist_msi.py │ │ │ │ ├── bdist_rpm.py │ │ │ │ ├── bdist_wininst.py │ │ │ │ ├── build.py │ │ │ │ ├── build_clib.py │ │ │ │ ├── build_ext.py │ │ │ │ ├── build_py.py │ │ │ │ ├── build_scripts.py │ │ │ │ ├── check.py │ │ │ │ ├── clean.py │ │ │ │ ├── config.py │ │ │ │ ├── install.py │ │ │ │ ├── install_data.py │ │ │ │ ├── install_egg_info.py │ │ │ │ ├── install_headers.py │ │ │ │ ├── install_lib.py │ │ │ │ ├── install_scripts.py │ │ │ │ ├── register.py │ │ │ │ ├── sdist.py │ │ │ │ └── upload.py │ │ │ ├── config.py │ │ │ ├── core.py │ │ │ ├── cygwinccompiler.py │ │ │ ├── debug.py │ │ │ ├── dep_util.py │ │ │ ├── dir_util.py │ │ │ ├── dist.py │ │ │ ├── emxccompiler.py │ │ │ ├── errors.py │ │ │ ├── extension.py │ │ │ ├── fancy_getopt.py │ │ │ ├── file_util.py │ │ │ ├── filelist.py │ │ │ ├── log.py │ │ │ ├── msvc9compiler.py │ │ │ ├── msvccompiler.py │ │ │ ├── spawn.py │ │ │ ├── sysconfig.py │ │ │ ├── text_file.py │ │ │ ├── unixccompiler.py │ │ │ ├── util.py │ │ │ ├── version.py │ │ │ └── versionpredicate.py │ │ ├── doctest.py │ │ ├── dumbdbm.py │ │ ├── dummy_thread.py │ │ ├── dummy_threading.py │ │ ├── email │ │ │ ├── __init__.py │ │ │ ├── _parseaddr.py │ │ │ ├── base64mime.py │ │ │ ├── charset.py │ │ │ ├── encoders.py │ │ │ ├── errors.py │ │ │ ├── feedparser.py │ │ │ ├── generator.py │ │ │ ├── header.py │ │ │ ├── iterators.py │ │ │ ├── message.py │ │ │ ├── mime │ │ │ │ ├── __init__.py │ │ │ │ ├── application.py │ │ │ │ ├── audio.py │ │ │ │ ├── base.py │ │ │ │ ├── image.py │ │ │ │ ├── message.py │ │ │ │ ├── multipart.py │ │ │ │ ├── nonmultipart.py │ │ │ │ └── text.py │ │ │ ├── parser.py │ │ │ ├── quoprimime.py │ │ │ └── utils.py │ │ ├── encodings │ │ │ ├── __init__.py │ │ │ ├── aliases.py │ │ │ ├── ascii.py │ │ │ ├── base64_codec.py │ │ │ ├── big5.py │ │ │ ├── big5hkscs.py │ │ │ ├── bz2_codec.py │ │ │ ├── charmap.py │ │ │ ├── cp037.py │ │ │ ├── cp1006.py │ │ │ ├── cp1026.py │ │ │ ├── cp1140.py │ │ │ ├── cp1250.py │ │ │ ├── cp1251.py │ │ │ ├── cp1252.py │ │ │ ├── cp1253.py │ │ │ ├── cp1254.py │ │ │ ├── cp1255.py │ │ │ ├── cp1256.py │ │ │ ├── cp1257.py │ │ │ ├── cp1258.py │ │ │ ├── cp424.py │ │ │ ├── cp437.py │ │ │ ├── cp500.py │ │ │ ├── cp720.py │ │ │ ├── cp737.py │ │ │ ├── cp775.py │ │ │ ├── cp850.py │ │ │ ├── cp852.py │ │ │ ├── cp855.py │ │ │ ├── cp856.py │ │ │ ├── cp857.py │ │ │ ├── cp858.py │ │ │ ├── cp860.py │ │ │ ├── cp861.py │ │ │ ├── cp862.py │ │ │ ├── cp863.py │ │ │ ├── cp864.py │ │ │ ├── cp865.py │ │ │ ├── cp866.py │ │ │ ├── cp869.py │ │ │ ├── cp874.py │ │ │ ├── cp875.py │ │ │ ├── cp932.py │ │ │ ├── cp949.py │ │ │ ├── cp950.py │ │ │ ├── euc_jis_2004.py │ │ │ ├── euc_jisx0213.py │ │ │ ├── euc_jp.py │ │ │ ├── euc_kr.py │ │ │ ├── gb18030.py │ │ │ ├── gb2312.py │ │ │ ├── gbk.py │ │ │ ├── hex_codec.py │ │ │ ├── hp_roman8.py │ │ │ ├── hz.py │ │ │ ├── idna.py │ │ │ ├── iso2022_jp.py │ │ │ ├── iso2022_jp_1.py │ │ │ ├── iso2022_jp_2.py │ │ │ ├── iso2022_jp_2004.py │ │ │ ├── iso2022_jp_3.py │ │ │ ├── iso2022_jp_ext.py │ │ │ ├── iso2022_kr.py │ │ │ ├── iso8859_1.py │ │ │ ├── iso8859_10.py │ │ │ ├── iso8859_11.py │ │ │ ├── iso8859_13.py │ │ │ ├── iso8859_14.py │ │ │ ├── iso8859_15.py │ │ │ ├── iso8859_16.py │ │ │ ├── iso8859_2.py │ │ │ ├── iso8859_3.py │ │ │ ├── iso8859_4.py │ │ │ ├── iso8859_5.py │ │ │ ├── iso8859_6.py │ │ │ ├── iso8859_7.py │ │ │ ├── iso8859_8.py │ │ │ ├── iso8859_9.py │ │ │ ├── johab.py │ │ │ ├── koi8_r.py │ │ │ ├── koi8_u.py │ │ │ ├── latin_1.py │ │ │ ├── mac_arabic.py │ │ │ ├── mac_centeuro.py │ │ │ ├── mac_croatian.py │ │ │ ├── mac_cyrillic.py │ │ │ ├── mac_farsi.py │ │ │ ├── mac_greek.py │ │ │ ├── mac_iceland.py │ │ │ ├── mac_latin2.py │ │ │ ├── mac_roman.py │ │ │ ├── mac_romanian.py │ │ │ ├── mac_turkish.py │ │ │ ├── mbcs.py │ │ │ ├── palmos.py │ │ │ ├── ptcp154.py │ │ │ ├── punycode.py │ │ │ ├── quopri_codec.py │ │ │ ├── raw_unicode_escape.py │ │ │ ├── rot_13.py │ │ │ ├── shift_jis.py │ │ │ ├── shift_jis_2004.py │ │ │ ├── shift_jisx0213.py │ │ │ ├── string_escape.py │ │ │ ├── tis_620.py │ │ │ ├── undefined.py │ │ │ ├── unicode_escape.py │ │ │ ├── unicode_internal.py │ │ │ ├── utf_16.py │ │ │ ├── utf_16_be.py │ │ │ ├── utf_16_le.py │ │ │ ├── utf_32.py │ │ │ ├── utf_32_be.py │ │ │ ├── utf_32_le.py │ │ │ ├── utf_7.py │ │ │ ├── utf_8.py │ │ │ ├── utf_8_sig.py │ │ │ ├── uu_codec.py │ │ │ └── zlib_codec.py │ │ ├── filecmp.py │ │ ├── fileinput.py │ │ ├── fnmatch.py │ │ ├── formatter.py │ │ ├── fpformat.py │ │ ├── fractions.py │ │ ├── ftplib.py │ │ ├── functools.py │ │ ├── genericpath.py │ │ ├── getopt.py │ │ ├── getpass.py │ │ ├── gettext.py │ │ ├── glob.py │ │ ├── gzip.py │ │ ├── hashlib.py │ │ ├── heapq.py │ │ ├── hmac.py │ │ ├── hotshot │ │ │ ├── __init__.py │ │ │ ├── log.py │ │ │ ├── stats.py │ │ │ └── stones.py │ │ ├── htmlentitydefs.py │ │ ├── htmllib.py │ │ ├── httplib.py │ │ ├── ihooks.py │ │ ├── imaplib.py │ │ ├── imghdr.py │ │ ├── importlib │ │ │ └── __init__.py │ │ ├── imputil.py │ │ ├── inspect.py │ │ ├── io.py │ │ ├── json │ │ │ ├── __init__.py │ │ │ ├── decoder.py │ │ │ ├── encoder.py │ │ │ ├── scanner.py │ │ │ └── tool.py │ │ ├── keyword.py │ │ ├── lib-tk │ │ │ └── test │ │ │ │ ├── test_tkinter │ │ │ │ ├── __init__.py │ │ │ │ ├── test_loadtk.py │ │ │ │ └── test_text.py │ │ │ │ └── test_ttk │ │ │ │ ├── __init__.py │ │ │ │ ├── support.py │ │ │ │ ├── test_extensions.py │ │ │ │ ├── test_functions.py │ │ │ │ ├── test_style.py │ │ │ │ └── test_widgets.py │ │ ├── lib2to3 │ │ │ ├── Grammar.txt │ │ │ ├── PatternGrammar.txt │ │ │ ├── __init__.py │ │ │ ├── __main__.py │ │ │ ├── btm_matcher.py │ │ │ ├── btm_utils.py │ │ │ ├── fixer_base.py │ │ │ ├── fixer_util.py │ │ │ ├── fixes │ │ │ │ ├── __init__.py │ │ │ │ ├── fix_apply.py │ │ │ │ ├── fix_basestring.py │ │ │ │ ├── fix_buffer.py │ │ │ │ ├── fix_callable.py │ │ │ │ ├── fix_dict.py │ │ │ │ ├── fix_except.py │ │ │ │ ├── fix_exec.py │ │ │ │ ├── fix_execfile.py │ │ │ │ ├── fix_exitfunc.py │ │ │ │ ├── fix_filter.py │ │ │ │ ├── fix_funcattrs.py │ │ │ │ ├── fix_future.py │ │ │ │ ├── fix_getcwdu.py │ │ │ │ ├── fix_has_key.py │ │ │ │ ├── fix_idioms.py │ │ │ │ ├── fix_import.py │ │ │ │ ├── fix_imports.py │ │ │ │ ├── fix_imports2.py │ │ │ │ ├── fix_input.py │ │ │ │ ├── fix_intern.py │ │ │ │ ├── fix_isinstance.py │ │ │ │ ├── fix_itertools.py │ │ │ │ ├── fix_itertools_imports.py │ │ │ │ ├── fix_long.py │ │ │ │ ├── fix_map.py │ │ │ │ ├── fix_metaclass.py │ │ │ │ ├── fix_methodattrs.py │ │ │ │ ├── fix_ne.py │ │ │ │ ├── fix_next.py │ │ │ │ ├── fix_nonzero.py │ │ │ │ ├── fix_numliterals.py │ │ │ │ ├── fix_operator.py │ │ │ │ ├── fix_paren.py │ │ │ │ ├── fix_print.py │ │ │ │ ├── fix_raise.py │ │ │ │ ├── fix_raw_input.py │ │ │ │ ├── fix_reduce.py │ │ │ │ ├── fix_renames.py │ │ │ │ ├── fix_repr.py │ │ │ │ ├── fix_set_literal.py │ │ │ │ ├── fix_standarderror.py │ │ │ │ ├── fix_sys_exc.py │ │ │ │ ├── fix_throw.py │ │ │ │ ├── fix_tuple_params.py │ │ │ │ ├── fix_types.py │ │ │ │ ├── fix_unicode.py │ │ │ │ ├── fix_urllib.py │ │ │ │ ├── fix_ws_comma.py │ │ │ │ ├── fix_xrange.py │ │ │ │ ├── fix_xreadlines.py │ │ │ │ └── fix_zip.py │ │ │ ├── main.py │ │ │ ├── patcomp.py │ │ │ ├── pgen2 │ │ │ │ ├── __init__.py │ │ │ │ ├── conv.py │ │ │ │ ├── driver.py │ │ │ │ ├── grammar.py │ │ │ │ ├── literals.py │ │ │ │ ├── parse.py │ │ │ │ ├── pgen.py │ │ │ │ ├── token.py │ │ │ │ └── tokenize.py │ │ │ ├── pygram.py │ │ │ ├── pytree.py │ │ │ ├── refactor.py │ │ │ └── tests │ │ │ │ └── data │ │ │ │ └── fixers │ │ │ │ ├── bad_order.py │ │ │ │ ├── myfixes │ │ │ │ ├── __init__.py │ │ │ │ ├── fix_explicit.py │ │ │ │ ├── fix_first.py │ │ │ │ ├── fix_last.py │ │ │ │ ├── fix_parrot.py │ │ │ │ └── fix_preorder.py │ │ │ │ ├── no_fixer_cls.py │ │ │ │ └── parrot_example.py │ │ ├── linecache.py │ │ ├── locale.py │ │ ├── logging │ │ │ ├── __init__.py │ │ │ ├── config.py │ │ │ └── handlers.py │ │ ├── macpath.py │ │ ├── macurl2path.py │ │ ├── mailbox.py │ │ ├── mailcap.py │ │ ├── markupbase.py │ │ ├── md5.py │ │ ├── mhlib.py │ │ ├── mimetools.py │ │ ├── mimetypes.py │ │ ├── mimify.py │ │ ├── modulefinder.py │ │ ├── msilib │ │ │ ├── __init__.py │ │ │ ├── schema.py │ │ │ ├── sequence.py │ │ │ └── text.py │ │ ├── multifile.py │ │ ├── multiprocessing │ │ │ ├── __init__.py │ │ │ ├── connection.py │ │ │ ├── dummy │ │ │ │ ├── __init__.py │ │ │ │ └── connection.py │ │ │ ├── forking.py │ │ │ ├── heap.py │ │ │ ├── managers.py │ │ │ ├── pool.py │ │ │ ├── process.py │ │ │ ├── queues.py │ │ │ ├── reduction.py │ │ │ ├── sharedctypes.py │ │ │ ├── synchronize.py │ │ │ └── util.py │ │ ├── mutex.py │ │ ├── netrc.py │ │ ├── new.py │ │ ├── nntplib.py │ │ ├── ntpath.py │ │ ├── nturl2path.py │ │ ├── numbers.py │ │ ├── opcode.py │ │ ├── optparse.py │ │ ├── os.py │ │ ├── os2emxpath.py │ │ ├── pdb.py │ │ ├── pickle.py │ │ ├── pickletools.py │ │ ├── pipes.py │ │ ├── pkgutil.py │ │ ├── platform.py │ │ ├── plistlib.py │ │ ├── popen2.py │ │ ├── poplib.py │ │ ├── posixfile.py │ │ ├── posixpath.py │ │ ├── pprint.py │ │ ├── profile.py │ │ ├── pstats.py │ │ ├── pty.py │ │ ├── py_compile.py │ │ ├── pyclbr.py │ │ ├── pydoc.py │ │ ├── pydoc_data │ │ │ ├── __init__.py │ │ │ └── topics.py │ │ ├── quopri.py │ │ ├── random.py │ │ ├── re.py │ │ ├── repr.py │ │ ├── rexec.py │ │ ├── rfc822.py │ │ ├── rlcompleter.py │ │ ├── robotparser.py │ │ ├── runpy.py │ │ ├── sched.py │ │ ├── sets.py │ │ ├── sgmllib.py │ │ ├── sha.py │ │ ├── shelve.py │ │ ├── shlex.py │ │ ├── shutil.py │ │ ├── site-packages │ │ │ └── README.txt │ │ ├── site.py │ │ ├── smtpd.py │ │ ├── smtplib.py │ │ ├── sndhdr.py │ │ ├── socket.py │ │ ├── sqlite3 │ │ │ ├── __init__.py │ │ │ ├── dbapi2.py │ │ │ └── dump.py │ │ ├── sre.py │ │ ├── sre_compile.py │ │ ├── sre_constants.py │ │ ├── sre_parse.py │ │ ├── ssl.py │ │ ├── stat.py │ │ ├── statvfs.py │ │ ├── string.py │ │ ├── stringold.py │ │ ├── stringprep.py │ │ ├── struct.py │ │ ├── subprocess.py │ │ ├── sunau.py │ │ ├── sunaudio.py │ │ ├── symbol.py │ │ ├── symtable.py │ │ ├── sysconfig.py │ │ ├── tabnanny.py │ │ ├── tarfile.py │ │ ├── telnetlib.py │ │ ├── tempfile.py │ │ ├── textwrap.py │ │ ├── this.py │ │ ├── threading.py │ │ ├── timeit.py │ │ ├── toaiff.py │ │ ├── token.py │ │ ├── tokenize.py │ │ ├── trace.py │ │ ├── traceback.py │ │ ├── tty.py │ │ ├── types.py │ │ ├── unittest │ │ │ ├── __init__.py │ │ │ ├── __main__.py │ │ │ ├── case.py │ │ │ ├── loader.py │ │ │ ├── main.py │ │ │ ├── result.py │ │ │ ├── runner.py │ │ │ ├── signals.py │ │ │ ├── suite.py │ │ │ └── util.py │ │ ├── urllib.py │ │ ├── urllib2.py │ │ ├── urlparse.py │ │ ├── user.py │ │ ├── uu.py │ │ ├── uuid.py │ │ ├── warnings.py │ │ ├── wave.py │ │ ├── weakref.py │ │ ├── webbrowser.py │ │ ├── whichdb.py │ │ ├── wsgiref │ │ │ ├── __init__.py │ │ │ ├── handlers.py │ │ │ ├── headers.py │ │ │ ├── simple_server.py │ │ │ ├── util.py │ │ │ └── validate.py │ │ ├── xdrlib.py │ │ ├── xml │ │ │ ├── __init__.py │ │ │ ├── dom │ │ │ │ ├── NodeFilter.py │ │ │ │ ├── __init__.py │ │ │ │ ├── domreg.py │ │ │ │ ├── expatbuilder.py │ │ │ │ ├── minicompat.py │ │ │ │ ├── minidom.py │ │ │ │ ├── pulldom.py │ │ │ │ └── xmlbuilder.py │ │ │ ├── etree │ │ │ │ ├── ElementInclude.py │ │ │ │ ├── ElementPath.py │ │ │ │ ├── ElementTree.py │ │ │ │ ├── __init__.py │ │ │ │ └── cElementTree.py │ │ │ ├── parsers │ │ │ │ ├── __init__.py │ │ │ │ └── expat.py │ │ │ └── sax │ │ │ │ ├── __init__.py │ │ │ │ ├── _exceptions.py │ │ │ │ ├── expatreader.py │ │ │ │ ├── handler.py │ │ │ │ ├── saxutils.py │ │ │ │ └── xmlreader.py │ │ ├── xmllib.py │ │ ├── xmlrpclib.py │ │ └── zipfile.py │ ├── plugins │ │ ├── levelup_export.py │ │ └── paint3d_io.py │ ├── sproxel_utils.py │ └── test.py └── readme.txt ├── glue ├── classGlue.h ├── glue.cpp └── glue.pro ├── icons ├── box.png ├── eraser.png ├── extrude.png ├── eyeDropper.png ├── layerDelete.png ├── layerDuplicate.png ├── layerEye.png ├── layerNew.png ├── line.png ├── paintBucket.png ├── pencil.png ├── redo.png ├── slab.png ├── splat.png └── undo.png ├── main.cpp ├── pyBindings.cpp ├── pyBindings.h ├── pyConsole.cpp ├── pyConsole.h ├── pyImportExport.cpp ├── script.cpp ├── script.h ├── sproxel.icns ├── sproxel.ico ├── sproxel.png ├── sproxel.pro ├── sproxel.qrc ├── sproxel.rc └── util └── blendercubes.py /.gitignore: -------------------------------------------------------------------------------- 1 | sproxel.pro.user 2 | -------------------------------------------------------------------------------- /ConsoleWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPROXEL_CONSOLE_WIDGET_H__ 2 | #define __SPROXEL_CONSOLE_WIDGET_H__ 3 | #ifdef SPROXEL_USE_PYTHON 4 | 5 | #include 6 | #include 7 | 8 | 9 | class ConsoleWidget : public QPlainTextEdit 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | 15 | ConsoleWidget(const QString &title, QWidget *parent=NULL); 16 | 17 | QAction* toggleViewAction() const { return viewAction; } 18 | 19 | QSize sizeHint() const; 20 | 21 | protected: 22 | 23 | QAction *viewAction; 24 | 25 | void closeEvent(QCloseEvent* event) 26 | { 27 | hide(); 28 | if (viewAction) viewAction->setChecked(false); 29 | event->ignore(); 30 | } 31 | }; 32 | 33 | #endif // SPROXEL_USE_PYTHON 34 | #endif 35 | -------------------------------------------------------------------------------- /Foundation.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2009-2010, Industrial Light & Magic, 4 | // a division of Lucasfilm Entertainment Company Ltd. 5 | // 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // * Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // * Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following disclaimer 15 | // in the documentation and/or other materials provided with the 16 | // distribution. 17 | // * Neither the name of Industrial Light & Magic nor the names of 18 | // its contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | //-***************************************************************************** 34 | 35 | #ifndef _SPROXEL_FOUNDATION_H_ 36 | #define _SPROXEL_FOUNDATION_H_ 37 | 38 | #include 39 | 40 | //-***************************************************************************** 41 | template 42 | inline T degrees( const T &rads ) { return 180.0 * rads / M_PI; } 43 | 44 | //-***************************************************************************** 45 | template 46 | inline T radians( const T °s ) { return M_PI * degs / 180.0; } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Global.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLOBAL_H__ 2 | #define __GLOBAL_H__ 3 | 4 | #include 5 | #include "VoxelGridGroup.h" 6 | 7 | enum SproxelAxis { X_AXIS, Y_AXIS, Z_AXIS }; 8 | 9 | enum SproxelTool { TOOL_SPLAT, 10 | TOOL_FLOOD, 11 | TOOL_RAY, 12 | TOOL_DROPPER, 13 | TOOL_ERASER, 14 | TOOL_REPLACE, 15 | TOOL_SLAB, 16 | TOOL_LINE, 17 | TOOL_BOX, 18 | TOOL_EXTRUDE, 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Imath/ImathBox.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2004, Industrial Light & Magic, a division of Lucas 4 | // Digital Ltd. LLC 5 | // 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // * Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // * Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following disclaimer 15 | // in the documentation and/or other materials provided with the 16 | // distribution. 17 | // * Neither the name of Industrial Light & Magic nor the names of 18 | // its contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | /////////////////////////////////////////////////////////////////////////// 34 | 35 | #include "ImathBox.h" 36 | 37 | // this file is necessary for template instantiation on windows 38 | -------------------------------------------------------------------------------- /Imath/ImathGLU.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas 4 | // Digital Ltd. LLC 5 | // 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // * Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // * Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following disclaimer 15 | // in the documentation and/or other materials provided with the 16 | // distribution. 17 | // * Neither the name of Industrial Light & Magic nor the names of 18 | // its contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | /////////////////////////////////////////////////////////////////////////// 34 | 35 | 36 | 37 | #ifndef INCLUDED_IMATHGLU_H 38 | #define INCLUDED_IMATHGLU_H 39 | 40 | #include 41 | #include 42 | 43 | #include "ImathVec.h" 44 | 45 | inline 46 | void 47 | gluLookAt(const Imath::V3f &pos, const Imath::V3f &interest, const Imath::V3f &up) 48 | { 49 | gluLookAt(pos.x, pos.y, pos.z, 50 | interest.x, interest.y, interest.z, 51 | up.x, up.y, up.z); 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Imath/ImathShear.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas 4 | // Digital Ltd. LLC 5 | // 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // * Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // * Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following disclaimer 15 | // in the documentation and/or other materials provided with the 16 | // distribution. 17 | // * Neither the name of Industrial Light & Magic nor the names of 18 | // its contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | /////////////////////////////////////////////////////////////////////////// 34 | 35 | 36 | 37 | 38 | //---------------------------------------------------------------------------- 39 | // 40 | // Specializations of the Shear6 template. 41 | // 42 | //---------------------------------------------------------------------------- 43 | 44 | #include "ImathShear.h" 45 | 46 | namespace Imath { 47 | 48 | 49 | 50 | // empty 51 | 52 | 53 | 54 | } // namespace Imath 55 | -------------------------------------------------------------------------------- /Imath/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006, Industrial Light & Magic, a division of Lucasfilm 2 | Entertainment Company Ltd. Portions contributed and copyright held by 3 | others as indicated. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following 15 | disclaimer in the documentation and/or other materials provided with 16 | the distribution. 17 | 18 | * Neither the name of Industrial Light & Magic nor the names of 19 | any other contributors to this software may be used to endorse or 20 | promote products derived from this software without specific prior 21 | written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 24 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 25 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | 35 | -------------------------------------------------------------------------------- /ImportExport.h: -------------------------------------------------------------------------------- 1 | #ifndef __IMPORT_EXPORT_H__ 2 | #define __IMPORT_EXPORT_H__ 3 | 4 | 5 | #include "SproxelProject.h" 6 | #include "UndoManager.h" 7 | 8 | 9 | class Importer 10 | { 11 | public: 12 | virtual QString name()=0; 13 | virtual QString filter()=0; 14 | virtual bool doImport(const QString &filename, UndoManager *um, 15 | SproxelProjectPtr project, VoxelGridGroupPtr current_sprite)=0; 16 | }; 17 | 18 | 19 | void register_importer(Importer*); 20 | void unregister_importer(Importer*); 21 | 22 | const QList& get_importers(); 23 | 24 | 25 | class Exporter 26 | { 27 | public: 28 | virtual QString name()=0; 29 | virtual QString filter()=0; 30 | virtual bool doExport(const QString &filename, SproxelProjectPtr project, VoxelGridGroupPtr current_sprite)=0; 31 | }; 32 | 33 | 34 | void register_exporter(Exporter*); 35 | void unregister_exporter(Exporter*); 36 | 37 | const QList& get_exporters(); 38 | 39 | 40 | void register_builtin_importers_exporters(); 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012, Andrew Gardner, Joel Davis, Alexey Volynskov, Jason Kozak 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | Neither the name of any contributing organization nor the individual names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /NewGridDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "NewGridDialog.h" 2 | #include "ui_NewGridDialog.h" 3 | 4 | 5 | Imath::V3i NewGridDialog::lastSize(16); 6 | bool NewGridDialog::lastIndexed=false; 7 | 8 | 9 | NewGridDialog::NewGridDialog(QWidget *parent) : 10 | QDialog(parent), 11 | ui(new Ui::NewGridDialog) 12 | { 13 | ui->setupUi(this); 14 | ui->width ->setValue(lastSize.x); 15 | ui->height->setValue(lastSize.y); 16 | ui->depth ->setValue(lastSize.z); 17 | 18 | if (lastIndexed) 19 | ui->dataIndexed->setChecked(true); 20 | else 21 | ui->dataRGBA->setChecked(true); 22 | } 23 | 24 | NewGridDialog::~NewGridDialog() 25 | { 26 | delete ui; 27 | } 28 | 29 | int NewGridDialog::exec() 30 | { 31 | int r=QDialog::exec(); 32 | 33 | if (r) 34 | { 35 | lastSize=getVoxelSize(); 36 | lastIndexed=isIndexed(); 37 | } 38 | 39 | return r; 40 | } 41 | 42 | Imath::V3i NewGridDialog::getVoxelSize() 43 | { 44 | return Imath::V3i(ui->width->value(), 45 | ui->height->value(), 46 | ui->depth->value()); 47 | } 48 | 49 | bool NewGridDialog::isIndexed() 50 | { 51 | return ui->dataIndexed->isChecked(); 52 | } 53 | -------------------------------------------------------------------------------- /NewGridDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef NEWGRIDDIALOG_H 2 | #define NEWGRIDDIALOG_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class NewGridDialog; 10 | } 11 | 12 | class NewGridDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit NewGridDialog(QWidget *parent = 0); 18 | ~NewGridDialog(); 19 | 20 | Imath::V3i getVoxelSize(); 21 | bool isIndexed(); 22 | 23 | public slots: 24 | int exec(); 25 | 26 | private: 27 | Ui::NewGridDialog *ui; 28 | 29 | static Imath::V3i lastSize; 30 | static bool lastIndexed; 31 | }; 32 | 33 | #endif // NEWGRIDDIALOG_H 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Sproxel 2 | ======= 3 | 4 | Sproxel is a 3d interface designed to let the user quickly create and edit voxel-based 3d models. The creation process and resulting geometry can be thought of as an extension to 2d pixel art. 5 | 6 | Sproxel is in its infancy, but can already generate sprites for custom game engines. 7 | 8 | 9 | Building 10 | -------- 11 | 12 | Sproxel requires [Qt](http://qt-project.org/downloads), and on Windows, [Visual Studio 2010](http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express). 13 | -------------------------------------------------------------------------------- /SproxelProject.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPROXEL_PROJECT_H__ 2 | #define __SPROXEL_PROJECT_H__ 3 | 4 | 5 | #include "VoxelGridGroup.h" 6 | 7 | 8 | class SproxelProject : public QSharedData 9 | { 10 | public: 11 | QVector sprites; 12 | QVector palettes; 13 | ColorPalettePtr mainPalette; 14 | 15 | SproxelProject(); 16 | }; 17 | 18 | 19 | typedef QExplicitlySharedDataPointer SproxelProjectPtr; 20 | 21 | 22 | bool save_project(QString filename, SproxelProjectPtr project); 23 | SproxelProjectPtr load_project(QString filename); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /distro/common/lib/__phello__.foo.py: -------------------------------------------------------------------------------- 1 | # This file exists as a helper for the test.test_frozen module. 2 | -------------------------------------------------------------------------------- /distro/common/lib/antigravity.py: -------------------------------------------------------------------------------- 1 | 2 | import webbrowser 3 | 4 | webbrowser.open("http://xkcd.com/353/") 5 | -------------------------------------------------------------------------------- /distro/common/lib/atexit.py: -------------------------------------------------------------------------------- 1 | """ 2 | atexit.py - allow programmer to define multiple exit functions to be executed 3 | upon normal program termination. 4 | 5 | One public function, register, is defined. 6 | """ 7 | 8 | __all__ = ["register"] 9 | 10 | import sys 11 | 12 | _exithandlers = [] 13 | def _run_exitfuncs(): 14 | """run any registered exit functions 15 | 16 | _exithandlers is traversed in reverse order so functions are executed 17 | last in, first out. 18 | """ 19 | 20 | exc_info = None 21 | while _exithandlers: 22 | func, targs, kargs = _exithandlers.pop() 23 | try: 24 | func(*targs, **kargs) 25 | except SystemExit: 26 | exc_info = sys.exc_info() 27 | except: 28 | import traceback 29 | print >> sys.stderr, "Error in atexit._run_exitfuncs:" 30 | traceback.print_exc() 31 | exc_info = sys.exc_info() 32 | 33 | if exc_info is not None: 34 | raise exc_info[0], exc_info[1], exc_info[2] 35 | 36 | 37 | def register(func, *targs, **kargs): 38 | """register a function to be executed upon normal program termination 39 | 40 | func - function to be called at exit 41 | targs - optional arguments to pass to func 42 | kargs - optional keyword arguments to pass to func 43 | 44 | func is returned to facilitate usage as a decorator. 45 | """ 46 | _exithandlers.append((func, targs, kargs)) 47 | return func 48 | 49 | if hasattr(sys, "exitfunc"): 50 | # Assume it's another registered exit function - append it to our list 51 | register(sys.exitfunc) 52 | sys.exitfunc = _run_exitfuncs 53 | 54 | if __name__ == "__main__": 55 | def x1(): 56 | print "running x1" 57 | def x2(n): 58 | print "running x2(%r)" % (n,) 59 | def x3(n, kwd=None): 60 | print "running x3(%r, kwd=%r)" % (n, kwd) 61 | 62 | register(x1) 63 | register(x2, 12) 64 | register(x3, 5, "bar") 65 | register(x3, "no kwd args") 66 | -------------------------------------------------------------------------------- /distro/common/lib/compiler/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for parsing and compiling Python source code 2 | 3 | There are several functions defined at the top level that are imported 4 | from modules contained in the package. 5 | 6 | parse(buf, mode="exec") -> AST 7 | Converts a string containing Python source code to an abstract 8 | syntax tree (AST). The AST is defined in compiler.ast. 9 | 10 | parseFile(path) -> AST 11 | The same as parse(open(path)) 12 | 13 | walk(ast, visitor, verbose=None) 14 | Does a pre-order walk over the ast using the visitor instance. 15 | See compiler.visitor for details. 16 | 17 | compile(source, filename, mode, flags=None, dont_inherit=None) 18 | Returns a code object. A replacement for the builtin compile() function. 19 | 20 | compileFile(filename) 21 | Generates a .pyc file by compiling filename. 22 | """ 23 | 24 | import warnings 25 | 26 | warnings.warn("The compiler package is deprecated and removed in Python 3.x.", 27 | DeprecationWarning, stacklevel=2) 28 | 29 | from compiler.transformer import parse, parseFile 30 | from compiler.visitor import walk 31 | from compiler.pycodegen import compile, compileFile 32 | -------------------------------------------------------------------------------- /distro/common/lib/compiler/consts.py: -------------------------------------------------------------------------------- 1 | # operation flags 2 | OP_ASSIGN = 'OP_ASSIGN' 3 | OP_DELETE = 'OP_DELETE' 4 | OP_APPLY = 'OP_APPLY' 5 | 6 | SC_LOCAL = 1 7 | SC_GLOBAL_IMPLICIT = 2 8 | SC_GLOBAL_EXPLICT = 3 9 | SC_FREE = 4 10 | SC_CELL = 5 11 | SC_UNKNOWN = 6 12 | 13 | CO_OPTIMIZED = 0x0001 14 | CO_NEWLOCALS = 0x0002 15 | CO_VARARGS = 0x0004 16 | CO_VARKEYWORDS = 0x0008 17 | CO_NESTED = 0x0010 18 | CO_GENERATOR = 0x0020 19 | CO_GENERATOR_ALLOWED = 0 20 | CO_FUTURE_DIVISION = 0x2000 21 | CO_FUTURE_ABSIMPORT = 0x4000 22 | CO_FUTURE_WITH_STATEMENT = 0x8000 23 | CO_FUTURE_PRINT_FUNCTION = 0x10000 24 | -------------------------------------------------------------------------------- /distro/common/lib/compiler/future.py: -------------------------------------------------------------------------------- 1 | """Parser for future statements 2 | 3 | """ 4 | 5 | from compiler import ast, walk 6 | 7 | def is_future(stmt): 8 | """Return true if statement is a well-formed future statement""" 9 | if not isinstance(stmt, ast.From): 10 | return 0 11 | if stmt.modname == "__future__": 12 | return 1 13 | else: 14 | return 0 15 | 16 | class FutureParser: 17 | 18 | features = ("nested_scopes", "generators", "division", 19 | "absolute_import", "with_statement", "print_function", 20 | "unicode_literals") 21 | 22 | def __init__(self): 23 | self.found = {} # set 24 | 25 | def visitModule(self, node): 26 | stmt = node.node 27 | for s in stmt.nodes: 28 | if not self.check_stmt(s): 29 | break 30 | 31 | def check_stmt(self, stmt): 32 | if is_future(stmt): 33 | for name, asname in stmt.names: 34 | if name in self.features: 35 | self.found[name] = 1 36 | else: 37 | raise SyntaxError, \ 38 | "future feature %s is not defined" % name 39 | stmt.valid_future = 1 40 | return 1 41 | return 0 42 | 43 | def get_features(self): 44 | """Return list of features enabled by future statements""" 45 | return self.found.keys() 46 | 47 | class BadFutureParser: 48 | """Check for invalid future statements""" 49 | 50 | def visitFrom(self, node): 51 | if hasattr(node, 'valid_future'): 52 | return 53 | if node.modname != "__future__": 54 | return 55 | raise SyntaxError, "invalid future statement " + repr(node) 56 | 57 | def find_futures(node): 58 | p1 = FutureParser() 59 | p2 = BadFutureParser() 60 | walk(node, p1) 61 | walk(node, p2) 62 | return p1.get_features() 63 | 64 | if __name__ == "__main__": 65 | import sys 66 | from compiler import parseFile, walk 67 | 68 | for file in sys.argv[1:]: 69 | print file 70 | tree = parseFile(file) 71 | v = FutureParser() 72 | walk(tree, v) 73 | print v.found 74 | print 75 | -------------------------------------------------------------------------------- /distro/common/lib/compiler/misc.py: -------------------------------------------------------------------------------- 1 | 2 | def flatten(tup): 3 | elts = [] 4 | for elt in tup: 5 | if isinstance(elt, tuple): 6 | elts = elts + flatten(elt) 7 | else: 8 | elts.append(elt) 9 | return elts 10 | 11 | class Set: 12 | def __init__(self): 13 | self.elts = {} 14 | def __len__(self): 15 | return len(self.elts) 16 | def __contains__(self, elt): 17 | return elt in self.elts 18 | def add(self, elt): 19 | self.elts[elt] = elt 20 | def elements(self): 21 | return self.elts.keys() 22 | def has_elt(self, elt): 23 | return elt in self.elts 24 | def remove(self, elt): 25 | del self.elts[elt] 26 | def copy(self): 27 | c = Set() 28 | c.elts.update(self.elts) 29 | return c 30 | 31 | class Stack: 32 | def __init__(self): 33 | self.stack = [] 34 | self.pop = self.stack.pop 35 | def __len__(self): 36 | return len(self.stack) 37 | def push(self, elt): 38 | self.stack.append(elt) 39 | def top(self): 40 | return self.stack[-1] 41 | def __getitem__(self, index): # needed by visitContinue() 42 | return self.stack[index] 43 | 44 | MANGLE_LEN = 256 # magic constant from compile.c 45 | 46 | def mangle(name, klass): 47 | if not name.startswith('__'): 48 | return name 49 | if len(name) + 2 >= MANGLE_LEN: 50 | return name 51 | if name.endswith('__'): 52 | return name 53 | try: 54 | i = 0 55 | while klass[i] == '_': 56 | i = i + 1 57 | except IndexError: 58 | return name 59 | klass = klass[i:] 60 | 61 | tlen = len(klass) + len(name) 62 | if tlen > MANGLE_LEN: 63 | klass = klass[:MANGLE_LEN-tlen] 64 | 65 | return "_%s%s" % (klass, name) 66 | 67 | def set_filename(filename, tree): 68 | """Set the filename attribute to filename on every node in tree""" 69 | worklist = [tree] 70 | while worklist: 71 | node = worklist.pop(0) 72 | node.filename = filename 73 | worklist.extend(node.getChildNodes()) 74 | -------------------------------------------------------------------------------- /distro/common/lib/compiler/syntax.py: -------------------------------------------------------------------------------- 1 | """Check for errs in the AST. 2 | 3 | The Python parser does not catch all syntax errors. Others, like 4 | assignments with invalid targets, are caught in the code generation 5 | phase. 6 | 7 | The compiler package catches some errors in the transformer module. 8 | But it seems clearer to write checkers that use the AST to detect 9 | errors. 10 | """ 11 | 12 | from compiler import ast, walk 13 | 14 | def check(tree, multi=None): 15 | v = SyntaxErrorChecker(multi) 16 | walk(tree, v) 17 | return v.errors 18 | 19 | class SyntaxErrorChecker: 20 | """A visitor to find syntax errors in the AST.""" 21 | 22 | def __init__(self, multi=None): 23 | """Create new visitor object. 24 | 25 | If optional argument multi is not None, then print messages 26 | for each error rather than raising a SyntaxError for the 27 | first. 28 | """ 29 | self.multi = multi 30 | self.errors = 0 31 | 32 | def error(self, node, msg): 33 | self.errors = self.errors + 1 34 | if self.multi is not None: 35 | print "%s:%s: %s" % (node.filename, node.lineno, msg) 36 | else: 37 | raise SyntaxError, "%s (%s:%s)" % (msg, node.filename, node.lineno) 38 | 39 | def visitAssign(self, node): 40 | # the transformer module handles many of these 41 | pass 42 | ## for target in node.nodes: 43 | ## if isinstance(target, ast.AssList): 44 | ## if target.lineno is None: 45 | ## target.lineno = node.lineno 46 | ## self.error(target, "can't assign to list comprehension") 47 | -------------------------------------------------------------------------------- /distro/common/lib/ctypes/_endian.py: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # This file should be kept compatible with Python 2.3, see PEP 291. # 3 | ###################################################################### 4 | import sys 5 | from ctypes import * 6 | 7 | _array_type = type(c_int * 3) 8 | 9 | def _other_endian(typ): 10 | """Return the type with the 'other' byte order. Simple types like 11 | c_int and so on already have __ctype_be__ and __ctype_le__ 12 | attributes which contain the types, for more complicated types 13 | only arrays are supported. 14 | """ 15 | try: 16 | return getattr(typ, _OTHER_ENDIAN) 17 | except AttributeError: 18 | if type(typ) == _array_type: 19 | return _other_endian(typ._type_) * typ._length_ 20 | raise TypeError("This type does not support other endian: %s" % typ) 21 | 22 | class _swapped_meta(type(Structure)): 23 | def __setattr__(self, attrname, value): 24 | if attrname == "_fields_": 25 | fields = [] 26 | for desc in value: 27 | name = desc[0] 28 | typ = desc[1] 29 | rest = desc[2:] 30 | fields.append((name, _other_endian(typ)) + rest) 31 | value = fields 32 | super(_swapped_meta, self).__setattr__(attrname, value) 33 | 34 | ################################################################ 35 | 36 | # Note: The Structure metaclass checks for the *presence* (not the 37 | # value!) of a _swapped_bytes_ attribute to determine the bit order in 38 | # structures containing bit fields. 39 | 40 | if sys.byteorder == "little": 41 | _OTHER_ENDIAN = "__ctype_be__" 42 | 43 | LittleEndianStructure = Structure 44 | 45 | class BigEndianStructure(Structure): 46 | """Structure with big endian byte order""" 47 | __metaclass__ = _swapped_meta 48 | _swappedbytes_ = None 49 | 50 | elif sys.byteorder == "big": 51 | _OTHER_ENDIAN = "__ctype_le__" 52 | 53 | BigEndianStructure = Structure 54 | class LittleEndianStructure(Structure): 55 | """Structure with little endian byte order""" 56 | __metaclass__ = _swapped_meta 57 | _swappedbytes_ = None 58 | 59 | else: 60 | raise RuntimeError("Invalid byteorder") 61 | -------------------------------------------------------------------------------- /distro/common/lib/ctypes/macholib/__init__.py: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # This file should be kept compatible with Python 2.3, see PEP 291. # 3 | ###################################################################### 4 | """ 5 | Enough Mach-O to make your head spin. 6 | 7 | See the relevant header files in /usr/include/mach-o 8 | 9 | And also Apple's documentation. 10 | """ 11 | 12 | __version__ = '1.0' 13 | -------------------------------------------------------------------------------- /distro/common/lib/ctypes/macholib/dylib.py: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # This file should be kept compatible with Python 2.3, see PEP 291. # 3 | ###################################################################### 4 | """ 5 | Generic dylib path manipulation 6 | """ 7 | 8 | import re 9 | 10 | __all__ = ['dylib_info'] 11 | 12 | DYLIB_RE = re.compile(r"""(?x) 13 | (?P^.*)(?:^|/) 14 | (?P 15 | (?P\w+?) 16 | (?:\.(?P[^._]+))? 17 | (?:_(?P[^._]+))? 18 | \.dylib$ 19 | ) 20 | """) 21 | 22 | def dylib_info(filename): 23 | """ 24 | A dylib name can take one of the following four forms: 25 | Location/Name.SomeVersion_Suffix.dylib 26 | Location/Name.SomeVersion.dylib 27 | Location/Name_Suffix.dylib 28 | Location/Name.dylib 29 | 30 | returns None if not found or a mapping equivalent to: 31 | dict( 32 | location='Location', 33 | name='Name.SomeVersion_Suffix.dylib', 34 | shortname='Name', 35 | version='SomeVersion', 36 | suffix='Suffix', 37 | ) 38 | 39 | Note that SomeVersion and Suffix are optional and may be None 40 | if not present. 41 | """ 42 | is_dylib = DYLIB_RE.match(filename) 43 | if not is_dylib: 44 | return None 45 | return is_dylib.groupdict() 46 | 47 | 48 | def test_dylib_info(): 49 | def d(location=None, name=None, shortname=None, version=None, suffix=None): 50 | return dict( 51 | location=location, 52 | name=name, 53 | shortname=shortname, 54 | version=version, 55 | suffix=suffix 56 | ) 57 | assert dylib_info('completely/invalid') is None 58 | assert dylib_info('completely/invalide_debug') is None 59 | assert dylib_info('P/Foo.dylib') == d('P', 'Foo.dylib', 'Foo') 60 | assert dylib_info('P/Foo_debug.dylib') == d('P', 'Foo_debug.dylib', 'Foo', suffix='debug') 61 | assert dylib_info('P/Foo.A.dylib') == d('P', 'Foo.A.dylib', 'Foo', 'A') 62 | assert dylib_info('P/Foo_debug.A.dylib') == d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A') 63 | assert dylib_info('P/Foo.A_debug.dylib') == d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug') 64 | 65 | if __name__ == '__main__': 66 | test_dylib_info() 67 | -------------------------------------------------------------------------------- /distro/common/lib/curses/__init__.py: -------------------------------------------------------------------------------- 1 | """curses 2 | 3 | The main package for curses support for Python. Normally used by importing 4 | the package, and perhaps a particular module inside it. 5 | 6 | import curses 7 | from curses import textpad 8 | curses.initwin() 9 | ... 10 | 11 | """ 12 | 13 | __revision__ = "$Id$" 14 | 15 | from _curses import * 16 | from curses.wrapper import wrapper 17 | import os as _os 18 | import sys as _sys 19 | 20 | # Some constants, most notably the ACS_* ones, are only added to the C 21 | # _curses module's dictionary after initscr() is called. (Some 22 | # versions of SGI's curses don't define values for those constants 23 | # until initscr() has been called.) This wrapper function calls the 24 | # underlying C initscr(), and then copies the constants from the 25 | # _curses module to the curses package's dictionary. Don't do 'from 26 | # curses import *' if you'll be needing the ACS_* constants. 27 | 28 | def initscr(): 29 | import _curses, curses 30 | # we call setupterm() here because it raises an error 31 | # instead of calling exit() in error cases. 32 | setupterm(term=_os.environ.get("TERM", "unknown"), 33 | fd=_sys.__stdout__.fileno()) 34 | stdscr = _curses.initscr() 35 | for key, value in _curses.__dict__.items(): 36 | if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): 37 | setattr(curses, key, value) 38 | 39 | return stdscr 40 | 41 | # This is a similar wrapper for start_color(), which adds the COLORS and 42 | # COLOR_PAIRS variables which are only available after start_color() is 43 | # called. 44 | 45 | def start_color(): 46 | import _curses, curses 47 | retval = _curses.start_color() 48 | if hasattr(_curses, 'COLORS'): 49 | curses.COLORS = _curses.COLORS 50 | if hasattr(_curses, 'COLOR_PAIRS'): 51 | curses.COLOR_PAIRS = _curses.COLOR_PAIRS 52 | return retval 53 | 54 | # Import Python has_key() implementation if _curses doesn't contain has_key() 55 | 56 | try: 57 | has_key 58 | except NameError: 59 | from has_key import has_key 60 | -------------------------------------------------------------------------------- /distro/common/lib/curses/panel.py: -------------------------------------------------------------------------------- 1 | """curses.panel 2 | 3 | Module for using panels with curses. 4 | """ 5 | 6 | __revision__ = "$Id$" 7 | 8 | from _curses_panel import * 9 | -------------------------------------------------------------------------------- /distro/common/lib/curses/wrapper.py: -------------------------------------------------------------------------------- 1 | """curses.wrapper 2 | 3 | Contains one function, wrapper(), which runs another function which 4 | should be the rest of your curses-based application. If the 5 | application raises an exception, wrapper() will restore the terminal 6 | to a sane state so you can read the resulting traceback. 7 | 8 | """ 9 | 10 | import curses 11 | 12 | def wrapper(func, *args, **kwds): 13 | """Wrapper function that initializes curses and calls another function, 14 | restoring normal keyboard/screen behavior on error. 15 | The callable object 'func' is then passed the main window 'stdscr' 16 | as its first argument, followed by any other arguments passed to 17 | wrapper(). 18 | """ 19 | 20 | try: 21 | # Initialize curses 22 | stdscr = curses.initscr() 23 | 24 | # Turn off echoing of keys, and enter cbreak mode, 25 | # where no buffering is performed on keyboard input 26 | curses.noecho() 27 | curses.cbreak() 28 | 29 | # In keypad mode, escape sequences for special keys 30 | # (like the cursor keys) will be interpreted and 31 | # a special value like curses.KEY_LEFT will be returned 32 | stdscr.keypad(1) 33 | 34 | # Start color, too. Harmless if the terminal doesn't have 35 | # color; user can test with has_color() later on. The try/catch 36 | # works around a minor bit of over-conscientiousness in the curses 37 | # module -- the error return from C start_color() is ignorable. 38 | try: 39 | curses.start_color() 40 | except: 41 | pass 42 | 43 | return func(stdscr, *args, **kwds) 44 | finally: 45 | # Set everything back to normal 46 | if 'stdscr' in locals(): 47 | stdscr.keypad(0) 48 | curses.echo() 49 | curses.nocbreak() 50 | curses.endwin() 51 | -------------------------------------------------------------------------------- /distro/common/lib/dbhash.py: -------------------------------------------------------------------------------- 1 | """Provide a (g)dbm-compatible interface to bsddb.hashopen.""" 2 | 3 | import sys 4 | import warnings 5 | warnings.warnpy3k("in 3.x, the dbhash module has been removed", stacklevel=2) 6 | try: 7 | import bsddb 8 | except ImportError: 9 | # prevent a second import of this module from spuriously succeeding 10 | del sys.modules[__name__] 11 | raise 12 | 13 | __all__ = ["error","open"] 14 | 15 | error = bsddb.error # Exported for anydbm 16 | 17 | def open(file, flag = 'r', mode=0666): 18 | return bsddb.hashopen(file, flag, mode) 19 | -------------------------------------------------------------------------------- /distro/common/lib/dircache.py: -------------------------------------------------------------------------------- 1 | """Read and cache directory listings. 2 | 3 | The listdir() routine returns a sorted list of the files in a directory, 4 | using a cache to avoid reading the directory more often than necessary. 5 | The annotate() routine appends slashes to directories.""" 6 | from warnings import warnpy3k 7 | warnpy3k("the dircache module has been removed in Python 3.0", stacklevel=2) 8 | del warnpy3k 9 | 10 | import os 11 | 12 | __all__ = ["listdir", "opendir", "annotate", "reset"] 13 | 14 | cache = {} 15 | 16 | def reset(): 17 | """Reset the cache completely.""" 18 | global cache 19 | cache = {} 20 | 21 | def listdir(path): 22 | """List directory contents, using cache.""" 23 | try: 24 | cached_mtime, list = cache[path] 25 | del cache[path] 26 | except KeyError: 27 | cached_mtime, list = -1, [] 28 | mtime = os.stat(path).st_mtime 29 | if mtime != cached_mtime: 30 | list = os.listdir(path) 31 | list.sort() 32 | cache[path] = mtime, list 33 | return list 34 | 35 | opendir = listdir # XXX backward compatibility 36 | 37 | def annotate(head, list): 38 | """Add '/' suffixes to directories.""" 39 | for i in range(len(list)): 40 | if os.path.isdir(os.path.join(head, list[i])): 41 | list[i] = list[i] + '/' 42 | -------------------------------------------------------------------------------- /distro/common/lib/distutils/__init__.py: -------------------------------------------------------------------------------- 1 | """distutils 2 | 3 | The main package for the Python Module Distribution Utilities. Normally 4 | used from a setup script as 5 | 6 | from distutils.core import setup 7 | 8 | setup (...) 9 | """ 10 | 11 | __revision__ = "$Id$" 12 | 13 | # Distutils version 14 | # 15 | # Updated automatically by the Python release process. 16 | # 17 | #--start constants-- 18 | __version__ = "2.7.2" 19 | #--end constants-- 20 | -------------------------------------------------------------------------------- /distro/common/lib/distutils/command/__init__.py: -------------------------------------------------------------------------------- 1 | """distutils.command 2 | 3 | Package containing implementation of all the standard Distutils 4 | commands.""" 5 | 6 | __revision__ = "$Id$" 7 | 8 | __all__ = ['build', 9 | 'build_py', 10 | 'build_ext', 11 | 'build_clib', 12 | 'build_scripts', 13 | 'clean', 14 | 'install', 15 | 'install_lib', 16 | 'install_headers', 17 | 'install_scripts', 18 | 'install_data', 19 | 'sdist', 20 | 'register', 21 | 'bdist', 22 | 'bdist_dumb', 23 | 'bdist_rpm', 24 | 'bdist_wininst', 25 | 'upload', 26 | 'check', 27 | # These two are reserved for future use: 28 | #'bdist_sdux', 29 | #'bdist_pkgtool', 30 | # Note: 31 | # bdist_packager is not included because it only provides 32 | # an abstract base class 33 | ] 34 | -------------------------------------------------------------------------------- /distro/common/lib/distutils/command/bdist_msi.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/distutils/command/bdist_msi.py -------------------------------------------------------------------------------- /distro/common/lib/distutils/command/install_headers.py: -------------------------------------------------------------------------------- 1 | """distutils.command.install_headers 2 | 3 | Implements the Distutils 'install_headers' command, to install C/C++ header 4 | files to the Python include directory.""" 5 | 6 | __revision__ = "$Id$" 7 | 8 | from distutils.core import Command 9 | 10 | 11 | # XXX force is never used 12 | class install_headers(Command): 13 | 14 | description = "install C/C++ header files" 15 | 16 | user_options = [('install-dir=', 'd', 17 | "directory to install header files to"), 18 | ('force', 'f', 19 | "force installation (overwrite existing files)"), 20 | ] 21 | 22 | boolean_options = ['force'] 23 | 24 | def initialize_options(self): 25 | self.install_dir = None 26 | self.force = 0 27 | self.outfiles = [] 28 | 29 | def finalize_options(self): 30 | self.set_undefined_options('install', 31 | ('install_headers', 'install_dir'), 32 | ('force', 'force')) 33 | 34 | 35 | def run(self): 36 | headers = self.distribution.headers 37 | if not headers: 38 | return 39 | 40 | self.mkpath(self.install_dir) 41 | for header in headers: 42 | (out, _) = self.copy_file(header, self.install_dir) 43 | self.outfiles.append(out) 44 | 45 | def get_inputs(self): 46 | return self.distribution.headers or [] 47 | 48 | def get_outputs(self): 49 | return self.outfiles 50 | 51 | # class install_headers 52 | -------------------------------------------------------------------------------- /distro/common/lib/distutils/command/install_scripts.py: -------------------------------------------------------------------------------- 1 | """distutils.command.install_scripts 2 | 3 | Implements the Distutils 'install_scripts' command, for installing 4 | Python scripts.""" 5 | 6 | # contributed by Bastian Kleineidam 7 | 8 | __revision__ = "$Id$" 9 | 10 | import os 11 | from distutils.core import Command 12 | from distutils import log 13 | from stat import ST_MODE 14 | 15 | class install_scripts (Command): 16 | 17 | description = "install scripts (Python or otherwise)" 18 | 19 | user_options = [ 20 | ('install-dir=', 'd', "directory to install scripts to"), 21 | ('build-dir=','b', "build directory (where to install from)"), 22 | ('force', 'f', "force installation (overwrite existing files)"), 23 | ('skip-build', None, "skip the build steps"), 24 | ] 25 | 26 | boolean_options = ['force', 'skip-build'] 27 | 28 | 29 | def initialize_options (self): 30 | self.install_dir = None 31 | self.force = 0 32 | self.build_dir = None 33 | self.skip_build = None 34 | 35 | def finalize_options (self): 36 | self.set_undefined_options('build', ('build_scripts', 'build_dir')) 37 | self.set_undefined_options('install', 38 | ('install_scripts', 'install_dir'), 39 | ('force', 'force'), 40 | ('skip_build', 'skip_build'), 41 | ) 42 | 43 | def run (self): 44 | if not self.skip_build: 45 | self.run_command('build_scripts') 46 | self.outfiles = self.copy_tree(self.build_dir, self.install_dir) 47 | if os.name == 'posix': 48 | # Set the executable bits (owner, group, and world) on 49 | # all the scripts we just installed. 50 | for file in self.get_outputs(): 51 | if self.dry_run: 52 | log.info("changing mode of %s", file) 53 | else: 54 | mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 55 | log.info("changing mode of %s to %o", file, mode) 56 | os.chmod(file, mode) 57 | 58 | def get_inputs (self): 59 | return self.distribution.scripts or [] 60 | 61 | def get_outputs(self): 62 | return self.outfiles or [] 63 | 64 | # class install_scripts 65 | -------------------------------------------------------------------------------- /distro/common/lib/distutils/debug.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | __revision__ = "$Id$" 4 | 5 | # If DISTUTILS_DEBUG is anything other than the empty string, we run in 6 | # debug mode. 7 | DEBUG = os.environ.get('DISTUTILS_DEBUG') 8 | -------------------------------------------------------------------------------- /distro/common/lib/distutils/log.py: -------------------------------------------------------------------------------- 1 | """A simple log mechanism styled after PEP 282.""" 2 | 3 | # The class here is styled after PEP 282 so that it could later be 4 | # replaced with a standard Python logging implementation. 5 | 6 | DEBUG = 1 7 | INFO = 2 8 | WARN = 3 9 | ERROR = 4 10 | FATAL = 5 11 | 12 | import sys 13 | 14 | class Log: 15 | 16 | def __init__(self, threshold=WARN): 17 | self.threshold = threshold 18 | 19 | def _log(self, level, msg, args): 20 | if level not in (DEBUG, INFO, WARN, ERROR, FATAL): 21 | raise ValueError('%s wrong log level' % str(level)) 22 | 23 | if level >= self.threshold: 24 | if args: 25 | msg = msg % args 26 | if level in (WARN, ERROR, FATAL): 27 | stream = sys.stderr 28 | else: 29 | stream = sys.stdout 30 | stream.write('%s\n' % msg) 31 | stream.flush() 32 | 33 | def log(self, level, msg, *args): 34 | self._log(level, msg, args) 35 | 36 | def debug(self, msg, *args): 37 | self._log(DEBUG, msg, args) 38 | 39 | def info(self, msg, *args): 40 | self._log(INFO, msg, args) 41 | 42 | def warn(self, msg, *args): 43 | self._log(WARN, msg, args) 44 | 45 | def error(self, msg, *args): 46 | self._log(ERROR, msg, args) 47 | 48 | def fatal(self, msg, *args): 49 | self._log(FATAL, msg, args) 50 | 51 | _global_log = Log() 52 | log = _global_log.log 53 | debug = _global_log.debug 54 | info = _global_log.info 55 | warn = _global_log.warn 56 | error = _global_log.error 57 | fatal = _global_log.fatal 58 | 59 | def set_threshold(level): 60 | # return the old threshold for use from tests 61 | old = _global_log.threshold 62 | _global_log.threshold = level 63 | return old 64 | 65 | def set_verbosity(v): 66 | if v <= 0: 67 | set_threshold(WARN) 68 | elif v == 1: 69 | set_threshold(INFO) 70 | elif v >= 2: 71 | set_threshold(DEBUG) 72 | -------------------------------------------------------------------------------- /distro/common/lib/email/encoders.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Encodings and related functions.""" 6 | 7 | __all__ = [ 8 | 'encode_7or8bit', 9 | 'encode_base64', 10 | 'encode_noop', 11 | 'encode_quopri', 12 | ] 13 | 14 | import base64 15 | 16 | from quopri import encodestring as _encodestring 17 | 18 | 19 | 20 | def _qencode(s): 21 | enc = _encodestring(s, quotetabs=True) 22 | # Must encode spaces, which quopri.encodestring() doesn't do 23 | return enc.replace(' ', '=20') 24 | 25 | 26 | def _bencode(s): 27 | # We can't quite use base64.encodestring() since it tacks on a "courtesy 28 | # newline". Blech! 29 | if not s: 30 | return s 31 | hasnewline = (s[-1] == '\n') 32 | value = base64.encodestring(s) 33 | if not hasnewline and value[-1] == '\n': 34 | return value[:-1] 35 | return value 36 | 37 | 38 | 39 | def encode_base64(msg): 40 | """Encode the message's payload in Base64. 41 | 42 | Also, add an appropriate Content-Transfer-Encoding header. 43 | """ 44 | orig = msg.get_payload() 45 | encdata = _bencode(orig) 46 | msg.set_payload(encdata) 47 | msg['Content-Transfer-Encoding'] = 'base64' 48 | 49 | 50 | 51 | def encode_quopri(msg): 52 | """Encode the message's payload in quoted-printable. 53 | 54 | Also, add an appropriate Content-Transfer-Encoding header. 55 | """ 56 | orig = msg.get_payload() 57 | encdata = _qencode(orig) 58 | msg.set_payload(encdata) 59 | msg['Content-Transfer-Encoding'] = 'quoted-printable' 60 | 61 | 62 | 63 | def encode_7or8bit(msg): 64 | """Set the Content-Transfer-Encoding header to 7bit or 8bit.""" 65 | orig = msg.get_payload() 66 | if orig is None: 67 | # There's no payload. For backwards compatibility we use 7bit 68 | msg['Content-Transfer-Encoding'] = '7bit' 69 | return 70 | # We play a trick to make this go fast. If encoding to ASCII succeeds, we 71 | # know the data must be 7bit, otherwise treat it as 8bit. 72 | try: 73 | orig.encode('ascii') 74 | except UnicodeError: 75 | msg['Content-Transfer-Encoding'] = '8bit' 76 | else: 77 | msg['Content-Transfer-Encoding'] = '7bit' 78 | 79 | 80 | 81 | def encode_noop(msg): 82 | """Do nothing.""" 83 | -------------------------------------------------------------------------------- /distro/common/lib/email/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """email package exception classes.""" 6 | 7 | 8 | 9 | class MessageError(Exception): 10 | """Base class for errors in the email package.""" 11 | 12 | 13 | class MessageParseError(MessageError): 14 | """Base class for message parsing errors.""" 15 | 16 | 17 | class HeaderParseError(MessageParseError): 18 | """Error while parsing headers.""" 19 | 20 | 21 | class BoundaryError(MessageParseError): 22 | """Couldn't find terminating boundary.""" 23 | 24 | 25 | class MultipartConversionError(MessageError, TypeError): 26 | """Conversion to a multipart is prohibited.""" 27 | 28 | 29 | class CharsetError(MessageError): 30 | """An illegal charset was given.""" 31 | 32 | 33 | 34 | # These are parsing defects which the parser was able to work around. 35 | class MessageDefect: 36 | """Base class for a message defect.""" 37 | 38 | def __init__(self, line=None): 39 | self.line = line 40 | 41 | class NoBoundaryInMultipartDefect(MessageDefect): 42 | """A message claimed to be a multipart but had no boundary parameter.""" 43 | 44 | class StartBoundaryNotFoundDefect(MessageDefect): 45 | """The claimed start boundary was never found.""" 46 | 47 | class FirstHeaderLineIsContinuationDefect(MessageDefect): 48 | """A message had a continuation line as its first header line.""" 49 | 50 | class MisplacedEnvelopeHeaderDefect(MessageDefect): 51 | """A 'Unix-from' header was found in the middle of a header block.""" 52 | 53 | class MalformedHeaderDefect(MessageDefect): 54 | """Found a header that was missing a colon, or was otherwise malformed.""" 55 | 56 | class MultipartInvariantViolationDefect(MessageDefect): 57 | """A message claimed to be a multipart but no subparts were found.""" 58 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/email/mime/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/email/mime/application.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Keith Dart 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing application/* type MIME documents.""" 6 | 7 | __all__ = ["MIMEApplication"] 8 | 9 | from email import encoders 10 | from email.mime.nonmultipart import MIMENonMultipart 11 | 12 | 13 | class MIMEApplication(MIMENonMultipart): 14 | """Class for generating application/* MIME documents.""" 15 | 16 | def __init__(self, _data, _subtype='octet-stream', 17 | _encoder=encoders.encode_base64, **_params): 18 | """Create an application/* type MIME document. 19 | 20 | _data is a string containing the raw application data. 21 | 22 | _subtype is the MIME content type subtype, defaulting to 23 | 'octet-stream'. 24 | 25 | _encoder is a function which will perform the actual encoding for 26 | transport of the application data, defaulting to base64 encoding. 27 | 28 | Any additional keyword arguments are passed to the base class 29 | constructor, which turns them into parameters on the Content-Type 30 | header. 31 | """ 32 | if _subtype is None: 33 | raise TypeError('Invalid application MIME subtype') 34 | MIMENonMultipart.__init__(self, 'application', _subtype, **_params) 35 | self.set_payload(_data) 36 | _encoder(self) 37 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Base class for MIME specializations.""" 6 | 7 | __all__ = ['MIMEBase'] 8 | 9 | from email import message 10 | 11 | 12 | 13 | class MIMEBase(message.Message): 14 | """Base class for MIME specializations.""" 15 | 16 | def __init__(self, _maintype, _subtype, **_params): 17 | """This constructor adds a Content-Type: and a MIME-Version: header. 18 | 19 | The Content-Type: header is taken from the _maintype and _subtype 20 | arguments. Additional parameters for this header are taken from the 21 | keyword arguments. 22 | """ 23 | message.Message.__init__(self) 24 | ctype = '%s/%s' % (_maintype, _subtype) 25 | self.add_header('Content-Type', ctype, **_params) 26 | self['MIME-Version'] = '1.0' 27 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/image.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing image/* type MIME documents.""" 6 | 7 | __all__ = ['MIMEImage'] 8 | 9 | import imghdr 10 | 11 | from email import encoders 12 | from email.mime.nonmultipart import MIMENonMultipart 13 | 14 | 15 | 16 | class MIMEImage(MIMENonMultipart): 17 | """Class for generating image/* type MIME documents.""" 18 | 19 | def __init__(self, _imagedata, _subtype=None, 20 | _encoder=encoders.encode_base64, **_params): 21 | """Create an image/* type MIME document. 22 | 23 | _imagedata is a string containing the raw image data. If this data 24 | can be decoded by the standard Python `imghdr' module, then the 25 | subtype will be automatically included in the Content-Type header. 26 | Otherwise, you can specify the specific image subtype via the _subtype 27 | parameter. 28 | 29 | _encoder is a function which will perform the actual encoding for 30 | transport of the image data. It takes one argument, which is this 31 | Image instance. It should use get_payload() and set_payload() to 32 | change the payload to the encoded form. It should also add any 33 | Content-Transfer-Encoding or other headers to the message as 34 | necessary. The default encoding is Base64. 35 | 36 | Any additional keyword arguments are passed to the base class 37 | constructor, which turns them into parameters on the Content-Type 38 | header. 39 | """ 40 | if _subtype is None: 41 | _subtype = imghdr.what(None, _imagedata) 42 | if _subtype is None: 43 | raise TypeError('Could not guess image MIME subtype') 44 | MIMENonMultipart.__init__(self, 'image', _subtype, **_params) 45 | self.set_payload(_imagedata) 46 | _encoder(self) 47 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/message.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing message/* MIME documents.""" 6 | 7 | __all__ = ['MIMEMessage'] 8 | 9 | from email import message 10 | from email.mime.nonmultipart import MIMENonMultipart 11 | 12 | 13 | 14 | class MIMEMessage(MIMENonMultipart): 15 | """Class representing message/* MIME documents.""" 16 | 17 | def __init__(self, _msg, _subtype='rfc822'): 18 | """Create a message/* type MIME document. 19 | 20 | _msg is a message object and must be an instance of Message, or a 21 | derived class of Message, otherwise a TypeError is raised. 22 | 23 | Optional _subtype defines the subtype of the contained message. The 24 | default is "rfc822" (this is defined by the MIME standard, even though 25 | the term "rfc822" is technically outdated by RFC 2822). 26 | """ 27 | MIMENonMultipart.__init__(self, 'message', _subtype) 28 | if not isinstance(_msg, message.Message): 29 | raise TypeError('Argument is not an instance of Message') 30 | # It's convenient to use this base class method. We need to do it 31 | # this way or we'll get an exception 32 | message.Message.attach(self, _msg) 33 | # And be sure our default type is set correctly 34 | self.set_default_type('message/rfc822') 35 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/multipart.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2002-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Base class for MIME multipart/* type messages.""" 6 | 7 | __all__ = ['MIMEMultipart'] 8 | 9 | from email.mime.base import MIMEBase 10 | 11 | 12 | 13 | class MIMEMultipart(MIMEBase): 14 | """Base class for MIME multipart/* type messages.""" 15 | 16 | def __init__(self, _subtype='mixed', boundary=None, _subparts=None, 17 | **_params): 18 | """Creates a multipart/* type message. 19 | 20 | By default, creates a multipart/mixed message, with proper 21 | Content-Type and MIME-Version headers. 22 | 23 | _subtype is the subtype of the multipart content type, defaulting to 24 | `mixed'. 25 | 26 | boundary is the multipart boundary string. By default it is 27 | calculated as needed. 28 | 29 | _subparts is a sequence of initial subparts for the payload. It 30 | must be an iterable object, such as a list. You can always 31 | attach new subparts to the message by using the attach() method. 32 | 33 | Additional parameters for the Content-Type header are taken from the 34 | keyword arguments (or passed into the _params argument). 35 | """ 36 | MIMEBase.__init__(self, 'multipart', _subtype, **_params) 37 | 38 | # Initialise _payload to an empty list as the Message superclass's 39 | # implementation of is_multipart assumes that _payload is a list for 40 | # multipart messages. 41 | self._payload = [] 42 | 43 | if _subparts: 44 | for p in _subparts: 45 | self.attach(p) 46 | if boundary: 47 | self.set_boundary(boundary) 48 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/nonmultipart.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2002-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Base class for MIME type messages that are not multipart.""" 6 | 7 | __all__ = ['MIMENonMultipart'] 8 | 9 | from email import errors 10 | from email.mime.base import MIMEBase 11 | 12 | 13 | 14 | class MIMENonMultipart(MIMEBase): 15 | """Base class for MIME multipart/* type messages.""" 16 | 17 | def attach(self, payload): 18 | # The public API prohibits attaching multiple subparts to MIMEBase 19 | # derived subtypes since none of them are, by definition, of content 20 | # type multipart/* 21 | raise errors.MultipartConversionError( 22 | 'Cannot attach additional subparts to non-multipart/*') 23 | -------------------------------------------------------------------------------- /distro/common/lib/email/mime/text.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2001-2006 Python Software Foundation 2 | # Author: Barry Warsaw 3 | # Contact: email-sig@python.org 4 | 5 | """Class representing text/* type MIME documents.""" 6 | 7 | __all__ = ['MIMEText'] 8 | 9 | from email.encoders import encode_7or8bit 10 | from email.mime.nonmultipart import MIMENonMultipart 11 | 12 | 13 | 14 | class MIMEText(MIMENonMultipart): 15 | """Class for generating text/* type MIME documents.""" 16 | 17 | def __init__(self, _text, _subtype='plain', _charset='us-ascii'): 18 | """Create a text/* type MIME document. 19 | 20 | _text is the string for this message object. 21 | 22 | _subtype is the MIME sub content type, defaulting to "plain". 23 | 24 | _charset is the character set parameter added to the Content-Type 25 | header. This defaults to "us-ascii". Note that as a side-effect, the 26 | Content-Transfer-Encoding header will also be set. 27 | """ 28 | MIMENonMultipart.__init__(self, 'text', _subtype, 29 | **{'charset': _charset}) 30 | self.set_payload(_text, _charset) 31 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/ascii.py: -------------------------------------------------------------------------------- 1 | """ Python 'ascii' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.ascii_encode 18 | decode = codecs.ascii_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.ascii_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.ascii_decode(input, self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | class StreamConverter(StreamWriter,StreamReader): 35 | 36 | encode = codecs.ascii_decode 37 | decode = codecs.ascii_encode 38 | 39 | ### encodings module API 40 | 41 | def getregentry(): 42 | return codecs.CodecInfo( 43 | name='ascii', 44 | encode=Codec.encode, 45 | decode=Codec.decode, 46 | incrementalencoder=IncrementalEncoder, 47 | incrementaldecoder=IncrementalDecoder, 48 | streamwriter=StreamWriter, 49 | streamreader=StreamReader, 50 | ) 51 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/big5.py: -------------------------------------------------------------------------------- 1 | # 2 | # big5.py: Python Unicode Codec for BIG5 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_tw, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_tw.getcodec('big5') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='big5', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/big5hkscs.py: -------------------------------------------------------------------------------- 1 | # 2 | # big5hkscs.py: Python Unicode Codec for BIG5HKSCS 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_hk, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_hk.getcodec('big5hkscs') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='big5hkscs', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/charmap.py: -------------------------------------------------------------------------------- 1 | """ Generic Python Character Mapping Codec. 2 | 3 | Use this codec directly rather than through the automatic 4 | conversion mechanisms supplied by unicode() and .encode(). 5 | 6 | 7 | Written by Marc-Andre Lemburg (mal@lemburg.com). 8 | 9 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 10 | 11 | """#" 12 | 13 | import codecs 14 | 15 | ### Codec APIs 16 | 17 | class Codec(codecs.Codec): 18 | 19 | # Note: Binding these as C functions will result in the class not 20 | # converting them to methods. This is intended. 21 | encode = codecs.charmap_encode 22 | decode = codecs.charmap_decode 23 | 24 | class IncrementalEncoder(codecs.IncrementalEncoder): 25 | def __init__(self, errors='strict', mapping=None): 26 | codecs.IncrementalEncoder.__init__(self, errors) 27 | self.mapping = mapping 28 | 29 | def encode(self, input, final=False): 30 | return codecs.charmap_encode(input, self.errors, self.mapping)[0] 31 | 32 | class IncrementalDecoder(codecs.IncrementalDecoder): 33 | def __init__(self, errors='strict', mapping=None): 34 | codecs.IncrementalDecoder.__init__(self, errors) 35 | self.mapping = mapping 36 | 37 | def decode(self, input, final=False): 38 | return codecs.charmap_decode(input, self.errors, self.mapping)[0] 39 | 40 | class StreamWriter(Codec,codecs.StreamWriter): 41 | 42 | def __init__(self,stream,errors='strict',mapping=None): 43 | codecs.StreamWriter.__init__(self,stream,errors) 44 | self.mapping = mapping 45 | 46 | def encode(self,input,errors='strict'): 47 | return Codec.encode(input,errors,self.mapping) 48 | 49 | class StreamReader(Codec,codecs.StreamReader): 50 | 51 | def __init__(self,stream,errors='strict',mapping=None): 52 | codecs.StreamReader.__init__(self,stream,errors) 53 | self.mapping = mapping 54 | 55 | def decode(self,input,errors='strict'): 56 | return Codec.decode(input,errors,self.mapping) 57 | 58 | ### encodings module API 59 | 60 | def getregentry(): 61 | return codecs.CodecInfo( 62 | name='charmap', 63 | encode=Codec.encode, 64 | decode=Codec.decode, 65 | incrementalencoder=IncrementalEncoder, 66 | incrementaldecoder=IncrementalDecoder, 67 | streamwriter=StreamWriter, 68 | streamreader=StreamReader, 69 | ) 70 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/cp932.py: -------------------------------------------------------------------------------- 1 | # 2 | # cp932.py: Python Unicode Codec for CP932 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('cp932') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='cp932', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/cp949.py: -------------------------------------------------------------------------------- 1 | # 2 | # cp949.py: Python Unicode Codec for CP949 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_kr, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_kr.getcodec('cp949') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='cp949', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/cp950.py: -------------------------------------------------------------------------------- 1 | # 2 | # cp950.py: Python Unicode Codec for CP950 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_tw, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_tw.getcodec('cp950') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='cp950', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/euc_jis_2004.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_jis_2004.py: Python Unicode Codec for EUC_JIS_2004 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('euc_jis_2004') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_jis_2004', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/euc_jisx0213.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_jisx0213.py: Python Unicode Codec for EUC_JISX0213 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('euc_jisx0213') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_jisx0213', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/euc_jp.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_jp.py: Python Unicode Codec for EUC_JP 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('euc_jp') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_jp', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/euc_kr.py: -------------------------------------------------------------------------------- 1 | # 2 | # euc_kr.py: Python Unicode Codec for EUC_KR 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_kr, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_kr.getcodec('euc_kr') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='euc_kr', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/gb18030.py: -------------------------------------------------------------------------------- 1 | # 2 | # gb18030.py: Python Unicode Codec for GB18030 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('gb18030') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='gb18030', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/gb2312.py: -------------------------------------------------------------------------------- 1 | # 2 | # gb2312.py: Python Unicode Codec for GB2312 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('gb2312') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='gb2312', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/gbk.py: -------------------------------------------------------------------------------- 1 | # 2 | # gbk.py: Python Unicode Codec for GBK 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('gbk') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='gbk', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/hz.py: -------------------------------------------------------------------------------- 1 | # 2 | # hz.py: Python Unicode Codec for HZ 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_cn, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_cn.getcodec('hz') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='hz', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_jp.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp.py: Python Unicode Codec for ISO2022_JP 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_jp_1.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_1.py: Python Unicode Codec for ISO2022_JP_1 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_1') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_1', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_jp_2.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_2.py: Python Unicode Codec for ISO2022_JP_2 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_2') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_2', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_jp_2004.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_2004.py: Python Unicode Codec for ISO2022_JP_2004 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_2004') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_2004', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_jp_3.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_3.py: Python Unicode Codec for ISO2022_JP_3 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_3') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_3', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_jp_ext.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_jp_ext.py: Python Unicode Codec for ISO2022_JP_EXT 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_jp_ext') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_jp_ext', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/iso2022_kr.py: -------------------------------------------------------------------------------- 1 | # 2 | # iso2022_kr.py: Python Unicode Codec for ISO2022_KR 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_iso2022, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_iso2022.getcodec('iso2022_kr') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='iso2022_kr', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/johab.py: -------------------------------------------------------------------------------- 1 | # 2 | # johab.py: Python Unicode Codec for JOHAB 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_kr, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_kr.getcodec('johab') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='johab', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/latin_1.py: -------------------------------------------------------------------------------- 1 | """ Python 'latin-1' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.latin_1_encode 18 | decode = codecs.latin_1_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.latin_1_encode(input,self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.latin_1_decode(input,self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | class StreamConverter(StreamWriter,StreamReader): 35 | 36 | encode = codecs.latin_1_decode 37 | decode = codecs.latin_1_encode 38 | 39 | ### encodings module API 40 | 41 | def getregentry(): 42 | return codecs.CodecInfo( 43 | name='iso8859-1', 44 | encode=Codec.encode, 45 | decode=Codec.decode, 46 | incrementalencoder=IncrementalEncoder, 47 | incrementaldecoder=IncrementalDecoder, 48 | streamreader=StreamReader, 49 | streamwriter=StreamWriter, 50 | ) 51 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/mbcs.py: -------------------------------------------------------------------------------- 1 | """ Python 'mbcs' Codec for Windows 2 | 3 | 4 | Cloned by Mark Hammond (mhammond@skippinet.com.au) from ascii.py, 5 | which was written by Marc-Andre Lemburg (mal@lemburg.com). 6 | 7 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 8 | 9 | """ 10 | # Import them explicitly to cause an ImportError 11 | # on non-Windows systems 12 | from codecs import mbcs_encode, mbcs_decode 13 | # for IncrementalDecoder, IncrementalEncoder, ... 14 | import codecs 15 | 16 | ### Codec APIs 17 | 18 | encode = mbcs_encode 19 | 20 | def decode(input, errors='strict'): 21 | return mbcs_decode(input, errors, True) 22 | 23 | class IncrementalEncoder(codecs.IncrementalEncoder): 24 | def encode(self, input, final=False): 25 | return mbcs_encode(input, self.errors)[0] 26 | 27 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 28 | _buffer_decode = mbcs_decode 29 | 30 | class StreamWriter(codecs.StreamWriter): 31 | encode = mbcs_encode 32 | 33 | class StreamReader(codecs.StreamReader): 34 | decode = mbcs_decode 35 | 36 | ### encodings module API 37 | 38 | def getregentry(): 39 | return codecs.CodecInfo( 40 | name='mbcs', 41 | encode=encode, 42 | decode=decode, 43 | incrementalencoder=IncrementalEncoder, 44 | incrementaldecoder=IncrementalDecoder, 45 | streamreader=StreamReader, 46 | streamwriter=StreamWriter, 47 | ) 48 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/punycode.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/encodings/punycode.py -------------------------------------------------------------------------------- /distro/common/lib/encodings/raw_unicode_escape.py: -------------------------------------------------------------------------------- 1 | """ Python 'raw-unicode-escape' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.raw_unicode_escape_encode 18 | decode = codecs.raw_unicode_escape_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.raw_unicode_escape_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.raw_unicode_escape_decode(input, self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | ### encodings module API 35 | 36 | def getregentry(): 37 | return codecs.CodecInfo( 38 | name='raw-unicode-escape', 39 | encode=Codec.encode, 40 | decode=Codec.decode, 41 | incrementalencoder=IncrementalEncoder, 42 | incrementaldecoder=IncrementalDecoder, 43 | streamwriter=StreamWriter, 44 | streamreader=StreamReader, 45 | ) 46 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/shift_jis.py: -------------------------------------------------------------------------------- 1 | # 2 | # shift_jis.py: Python Unicode Codec for SHIFT_JIS 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('shift_jis') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='shift_jis', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/shift_jis_2004.py: -------------------------------------------------------------------------------- 1 | # 2 | # shift_jis_2004.py: Python Unicode Codec for SHIFT_JIS_2004 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('shift_jis_2004') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='shift_jis_2004', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/shift_jisx0213.py: -------------------------------------------------------------------------------- 1 | # 2 | # shift_jisx0213.py: Python Unicode Codec for SHIFT_JISX0213 3 | # 4 | # Written by Hye-Shik Chang 5 | # 6 | 7 | import _codecs_jp, codecs 8 | import _multibytecodec as mbc 9 | 10 | codec = _codecs_jp.getcodec('shift_jisx0213') 11 | 12 | class Codec(codecs.Codec): 13 | encode = codec.encode 14 | decode = codec.decode 15 | 16 | class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, 17 | codecs.IncrementalEncoder): 18 | codec = codec 19 | 20 | class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, 21 | codecs.IncrementalDecoder): 22 | codec = codec 23 | 24 | class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): 25 | codec = codec 26 | 27 | class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): 28 | codec = codec 29 | 30 | def getregentry(): 31 | return codecs.CodecInfo( 32 | name='shift_jisx0213', 33 | encode=Codec().encode, 34 | decode=Codec().decode, 35 | incrementalencoder=IncrementalEncoder, 36 | incrementaldecoder=IncrementalDecoder, 37 | streamreader=StreamReader, 38 | streamwriter=StreamWriter, 39 | ) 40 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/string_escape.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/encodings/string_escape.py -------------------------------------------------------------------------------- /distro/common/lib/encodings/undefined.py: -------------------------------------------------------------------------------- 1 | """ Python 'undefined' Codec 2 | 3 | This codec will always raise a ValueError exception when being 4 | used. It is intended for use by the site.py file to switch off 5 | automatic string to Unicode coercion. 6 | 7 | Written by Marc-Andre Lemburg (mal@lemburg.com). 8 | 9 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 10 | 11 | """ 12 | import codecs 13 | 14 | ### Codec APIs 15 | 16 | class Codec(codecs.Codec): 17 | 18 | def encode(self,input,errors='strict'): 19 | raise UnicodeError("undefined encoding") 20 | 21 | def decode(self,input,errors='strict'): 22 | raise UnicodeError("undefined encoding") 23 | 24 | class IncrementalEncoder(codecs.IncrementalEncoder): 25 | def encode(self, input, final=False): 26 | raise UnicodeError("undefined encoding") 27 | 28 | class IncrementalDecoder(codecs.IncrementalDecoder): 29 | def decode(self, input, final=False): 30 | raise UnicodeError("undefined encoding") 31 | 32 | class StreamWriter(Codec,codecs.StreamWriter): 33 | pass 34 | 35 | class StreamReader(Codec,codecs.StreamReader): 36 | pass 37 | 38 | ### encodings module API 39 | 40 | def getregentry(): 41 | return codecs.CodecInfo( 42 | name='undefined', 43 | encode=Codec().encode, 44 | decode=Codec().decode, 45 | incrementalencoder=IncrementalEncoder, 46 | incrementaldecoder=IncrementalDecoder, 47 | streamwriter=StreamWriter, 48 | streamreader=StreamReader, 49 | ) 50 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/unicode_escape.py: -------------------------------------------------------------------------------- 1 | """ Python 'unicode-escape' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.unicode_escape_encode 18 | decode = codecs.unicode_escape_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.unicode_escape_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.unicode_escape_decode(input, self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | ### encodings module API 35 | 36 | def getregentry(): 37 | return codecs.CodecInfo( 38 | name='unicode-escape', 39 | encode=Codec.encode, 40 | decode=Codec.decode, 41 | incrementalencoder=IncrementalEncoder, 42 | incrementaldecoder=IncrementalDecoder, 43 | streamwriter=StreamWriter, 44 | streamreader=StreamReader, 45 | ) 46 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/unicode_internal.py: -------------------------------------------------------------------------------- 1 | """ Python 'unicode-internal' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | class Codec(codecs.Codec): 14 | 15 | # Note: Binding these as C functions will result in the class not 16 | # converting them to methods. This is intended. 17 | encode = codecs.unicode_internal_encode 18 | decode = codecs.unicode_internal_decode 19 | 20 | class IncrementalEncoder(codecs.IncrementalEncoder): 21 | def encode(self, input, final=False): 22 | return codecs.unicode_internal_encode(input, self.errors)[0] 23 | 24 | class IncrementalDecoder(codecs.IncrementalDecoder): 25 | def decode(self, input, final=False): 26 | return codecs.unicode_internal_decode(input, self.errors)[0] 27 | 28 | class StreamWriter(Codec,codecs.StreamWriter): 29 | pass 30 | 31 | class StreamReader(Codec,codecs.StreamReader): 32 | pass 33 | 34 | ### encodings module API 35 | 36 | def getregentry(): 37 | return codecs.CodecInfo( 38 | name='unicode-internal', 39 | encode=Codec.encode, 40 | decode=Codec.decode, 41 | incrementalencoder=IncrementalEncoder, 42 | incrementaldecoder=IncrementalDecoder, 43 | streamwriter=StreamWriter, 44 | streamreader=StreamReader, 45 | ) 46 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/utf_16_be.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-16-be' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | encode = codecs.utf_16_be_encode 14 | 15 | def decode(input, errors='strict'): 16 | return codecs.utf_16_be_decode(input, errors, True) 17 | 18 | class IncrementalEncoder(codecs.IncrementalEncoder): 19 | def encode(self, input, final=False): 20 | return codecs.utf_16_be_encode(input, self.errors)[0] 21 | 22 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 23 | _buffer_decode = codecs.utf_16_be_decode 24 | 25 | class StreamWriter(codecs.StreamWriter): 26 | encode = codecs.utf_16_be_encode 27 | 28 | class StreamReader(codecs.StreamReader): 29 | decode = codecs.utf_16_be_decode 30 | 31 | ### encodings module API 32 | 33 | def getregentry(): 34 | return codecs.CodecInfo( 35 | name='utf-16-be', 36 | encode=encode, 37 | decode=decode, 38 | incrementalencoder=IncrementalEncoder, 39 | incrementaldecoder=IncrementalDecoder, 40 | streamreader=StreamReader, 41 | streamwriter=StreamWriter, 42 | ) 43 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/utf_16_le.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-16-le' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | encode = codecs.utf_16_le_encode 14 | 15 | def decode(input, errors='strict'): 16 | return codecs.utf_16_le_decode(input, errors, True) 17 | 18 | class IncrementalEncoder(codecs.IncrementalEncoder): 19 | def encode(self, input, final=False): 20 | return codecs.utf_16_le_encode(input, self.errors)[0] 21 | 22 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 23 | _buffer_decode = codecs.utf_16_le_decode 24 | 25 | class StreamWriter(codecs.StreamWriter): 26 | encode = codecs.utf_16_le_encode 27 | 28 | class StreamReader(codecs.StreamReader): 29 | decode = codecs.utf_16_le_decode 30 | 31 | ### encodings module API 32 | 33 | def getregentry(): 34 | return codecs.CodecInfo( 35 | name='utf-16-le', 36 | encode=encode, 37 | decode=decode, 38 | incrementalencoder=IncrementalEncoder, 39 | incrementaldecoder=IncrementalDecoder, 40 | streamreader=StreamReader, 41 | streamwriter=StreamWriter, 42 | ) 43 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/utf_32_be.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python 'utf-32-be' Codec 3 | """ 4 | import codecs 5 | 6 | ### Codec APIs 7 | 8 | encode = codecs.utf_32_be_encode 9 | 10 | def decode(input, errors='strict'): 11 | return codecs.utf_32_be_decode(input, errors, True) 12 | 13 | class IncrementalEncoder(codecs.IncrementalEncoder): 14 | def encode(self, input, final=False): 15 | return codecs.utf_32_be_encode(input, self.errors)[0] 16 | 17 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 18 | _buffer_decode = codecs.utf_32_be_decode 19 | 20 | class StreamWriter(codecs.StreamWriter): 21 | encode = codecs.utf_32_be_encode 22 | 23 | class StreamReader(codecs.StreamReader): 24 | decode = codecs.utf_32_be_decode 25 | 26 | ### encodings module API 27 | 28 | def getregentry(): 29 | return codecs.CodecInfo( 30 | name='utf-32-be', 31 | encode=encode, 32 | decode=decode, 33 | incrementalencoder=IncrementalEncoder, 34 | incrementaldecoder=IncrementalDecoder, 35 | streamreader=StreamReader, 36 | streamwriter=StreamWriter, 37 | ) 38 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/utf_32_le.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python 'utf-32-le' Codec 3 | """ 4 | import codecs 5 | 6 | ### Codec APIs 7 | 8 | encode = codecs.utf_32_le_encode 9 | 10 | def decode(input, errors='strict'): 11 | return codecs.utf_32_le_decode(input, errors, True) 12 | 13 | class IncrementalEncoder(codecs.IncrementalEncoder): 14 | def encode(self, input, final=False): 15 | return codecs.utf_32_le_encode(input, self.errors)[0] 16 | 17 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 18 | _buffer_decode = codecs.utf_32_le_decode 19 | 20 | class StreamWriter(codecs.StreamWriter): 21 | encode = codecs.utf_32_le_encode 22 | 23 | class StreamReader(codecs.StreamReader): 24 | decode = codecs.utf_32_le_decode 25 | 26 | ### encodings module API 27 | 28 | def getregentry(): 29 | return codecs.CodecInfo( 30 | name='utf-32-le', 31 | encode=encode, 32 | decode=decode, 33 | incrementalencoder=IncrementalEncoder, 34 | incrementaldecoder=IncrementalDecoder, 35 | streamreader=StreamReader, 36 | streamwriter=StreamWriter, 37 | ) 38 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/utf_7.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-7' Codec 2 | 3 | Written by Brian Quinlan (brian@sweetapp.com). 4 | """ 5 | import codecs 6 | 7 | ### Codec APIs 8 | 9 | encode = codecs.utf_7_encode 10 | 11 | def decode(input, errors='strict'): 12 | return codecs.utf_7_decode(input, errors, True) 13 | 14 | class IncrementalEncoder(codecs.IncrementalEncoder): 15 | def encode(self, input, final=False): 16 | return codecs.utf_7_encode(input, self.errors)[0] 17 | 18 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 19 | _buffer_decode = codecs.utf_7_decode 20 | 21 | class StreamWriter(codecs.StreamWriter): 22 | encode = codecs.utf_7_encode 23 | 24 | class StreamReader(codecs.StreamReader): 25 | decode = codecs.utf_7_decode 26 | 27 | ### encodings module API 28 | 29 | def getregentry(): 30 | return codecs.CodecInfo( 31 | name='utf-7', 32 | encode=encode, 33 | decode=decode, 34 | incrementalencoder=IncrementalEncoder, 35 | incrementaldecoder=IncrementalDecoder, 36 | streamreader=StreamReader, 37 | streamwriter=StreamWriter, 38 | ) 39 | -------------------------------------------------------------------------------- /distro/common/lib/encodings/utf_8.py: -------------------------------------------------------------------------------- 1 | """ Python 'utf-8' Codec 2 | 3 | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). 5 | 6 | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 7 | 8 | """ 9 | import codecs 10 | 11 | ### Codec APIs 12 | 13 | encode = codecs.utf_8_encode 14 | 15 | def decode(input, errors='strict'): 16 | return codecs.utf_8_decode(input, errors, True) 17 | 18 | class IncrementalEncoder(codecs.IncrementalEncoder): 19 | def encode(self, input, final=False): 20 | return codecs.utf_8_encode(input, self.errors)[0] 21 | 22 | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): 23 | _buffer_decode = codecs.utf_8_decode 24 | 25 | class StreamWriter(codecs.StreamWriter): 26 | encode = codecs.utf_8_encode 27 | 28 | class StreamReader(codecs.StreamReader): 29 | decode = codecs.utf_8_decode 30 | 31 | ### encodings module API 32 | 33 | def getregentry(): 34 | return codecs.CodecInfo( 35 | name='utf-8', 36 | encode=encode, 37 | decode=decode, 38 | incrementalencoder=IncrementalEncoder, 39 | incrementaldecoder=IncrementalDecoder, 40 | streamreader=StreamReader, 41 | streamwriter=StreamWriter, 42 | ) 43 | -------------------------------------------------------------------------------- /distro/common/lib/heapq.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/heapq.py -------------------------------------------------------------------------------- /distro/common/lib/hotshot/stones.py: -------------------------------------------------------------------------------- 1 | import errno 2 | import hotshot 3 | import hotshot.stats 4 | import sys 5 | import test.pystone 6 | 7 | def main(logfile): 8 | p = hotshot.Profile(logfile) 9 | benchtime, stones = p.runcall(test.pystone.pystones) 10 | p.close() 11 | 12 | print "Pystone(%s) time for %d passes = %g" % \ 13 | (test.pystone.__version__, test.pystone.LOOPS, benchtime) 14 | print "This machine benchmarks at %g pystones/second" % stones 15 | 16 | stats = hotshot.stats.load(logfile) 17 | stats.strip_dirs() 18 | stats.sort_stats('time', 'calls') 19 | try: 20 | stats.print_stats(20) 21 | except IOError, e: 22 | if e.errno != errno.EPIPE: 23 | raise 24 | 25 | if __name__ == '__main__': 26 | if sys.argv[1:]: 27 | main(sys.argv[1]) 28 | else: 29 | import tempfile 30 | main(tempfile.NamedTemporaryFile().name) 31 | -------------------------------------------------------------------------------- /distro/common/lib/importlib/__init__.py: -------------------------------------------------------------------------------- 1 | """Backport of importlib.import_module from 3.x.""" 2 | # While not critical (and in no way guaranteed!), it would be nice to keep this 3 | # code compatible with Python 2.3. 4 | import sys 5 | 6 | def _resolve_name(name, package, level): 7 | """Return the absolute name of the module to be imported.""" 8 | if not hasattr(package, 'rindex'): 9 | raise ValueError("'package' not set to a string") 10 | dot = len(package) 11 | for x in xrange(level, 1, -1): 12 | try: 13 | dot = package.rindex('.', 0, dot) 14 | except ValueError: 15 | raise ValueError("attempted relative import beyond top-level " 16 | "package") 17 | return "%s.%s" % (package[:dot], name) 18 | 19 | 20 | def import_module(name, package=None): 21 | """Import a module. 22 | 23 | The 'package' argument is required when performing a relative import. It 24 | specifies the package to use as the anchor point from which to resolve the 25 | relative import to an absolute import. 26 | 27 | """ 28 | if name.startswith('.'): 29 | if not package: 30 | raise TypeError("relative imports require the 'package' argument") 31 | level = 0 32 | for character in name: 33 | if character != '.': 34 | break 35 | level += 1 36 | name = _resolve_name(name[level:], package, level) 37 | __import__(name) 38 | return sys.modules[name] 39 | -------------------------------------------------------------------------------- /distro/common/lib/json/tool.py: -------------------------------------------------------------------------------- 1 | r"""Command-line tool to validate and pretty-print JSON 2 | 3 | Usage:: 4 | 5 | $ echo '{"json":"obj"}' | python -m json.tool 6 | { 7 | "json": "obj" 8 | } 9 | $ echo '{ 1.2:3.4}' | python -m json.tool 10 | Expecting property name: line 1 column 2 (char 2) 11 | 12 | """ 13 | import sys 14 | import json 15 | 16 | def main(): 17 | if len(sys.argv) == 1: 18 | infile = sys.stdin 19 | outfile = sys.stdout 20 | elif len(sys.argv) == 2: 21 | infile = open(sys.argv[1], 'rb') 22 | outfile = sys.stdout 23 | elif len(sys.argv) == 3: 24 | infile = open(sys.argv[1], 'rb') 25 | outfile = open(sys.argv[2], 'wb') 26 | else: 27 | raise SystemExit(sys.argv[0] + " [infile [outfile]]") 28 | try: 29 | obj = json.load(infile) 30 | except ValueError, e: 31 | raise SystemExit(e) 32 | json.dump(obj, outfile, sort_keys=True, indent=4) 33 | outfile.write('\n') 34 | 35 | 36 | if __name__ == '__main__': 37 | main() 38 | -------------------------------------------------------------------------------- /distro/common/lib/lib-tk/test/test_tkinter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/lib-tk/test/test_tkinter/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/lib-tk/test/test_tkinter/test_loadtk.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import unittest 4 | from test import test_support 5 | from Tkinter import Tcl, TclError 6 | 7 | test_support.requires('gui') 8 | 9 | class TkLoadTest(unittest.TestCase): 10 | 11 | @unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.') 12 | def testLoadTk(self): 13 | tcl = Tcl() 14 | self.assertRaises(TclError,tcl.winfo_geometry) 15 | tcl.loadtk() 16 | self.assertEqual('1x1+0+0', tcl.winfo_geometry()) 17 | tcl.destroy() 18 | 19 | def testLoadTkFailure(self): 20 | old_display = None 21 | if sys.platform.startswith(('win', 'darwin', 'cygwin')): 22 | # no failure possible on windows? 23 | 24 | # XXX Maybe on tk older than 8.4.13 it would be possible, 25 | # see tkinter.h. 26 | return 27 | with test_support.EnvironmentVarGuard() as env: 28 | if 'DISPLAY' in os.environ: 29 | del env['DISPLAY'] 30 | # on some platforms, deleting environment variables 31 | # doesn't actually carry through to the process level 32 | # because they don't support unsetenv 33 | # If that's the case, abort. 34 | display = os.popen('echo $DISPLAY').read().strip() 35 | if display: 36 | return 37 | 38 | tcl = Tcl() 39 | self.assertRaises(TclError, tcl.winfo_geometry) 40 | self.assertRaises(TclError, tcl.loadtk) 41 | 42 | tests_gui = (TkLoadTest, ) 43 | 44 | if __name__ == "__main__": 45 | test_support.run_unittest(*tests_gui) 46 | -------------------------------------------------------------------------------- /distro/common/lib/lib-tk/test/test_tkinter/test_text.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import Tkinter 3 | from test.test_support import requires, run_unittest 4 | from ttk import setup_master 5 | 6 | requires('gui') 7 | 8 | class TextTest(unittest.TestCase): 9 | 10 | def setUp(self): 11 | self.root = setup_master() 12 | self.text = Tkinter.Text(self.root) 13 | 14 | def tearDown(self): 15 | self.text.destroy() 16 | 17 | 18 | def test_search(self): 19 | text = self.text 20 | 21 | # pattern and index are obligatory arguments. 22 | self.assertRaises(Tkinter.TclError, text.search, None, '1.0') 23 | self.assertRaises(Tkinter.TclError, text.search, 'a', None) 24 | self.assertRaises(Tkinter.TclError, text.search, None, None) 25 | 26 | # Invalid text index. 27 | self.assertRaises(Tkinter.TclError, text.search, '', 0) 28 | 29 | # Check if we are getting the indices as strings -- you are likely 30 | # to get Tcl_Obj under Tk 8.5 if Tkinter doesn't convert it. 31 | text.insert('1.0', 'hi-test') 32 | self.assertEqual(text.search('-test', '1.0', 'end'), '1.2') 33 | self.assertEqual(text.search('test', '1.0', 'end'), '1.3') 34 | 35 | 36 | tests_gui = (TextTest, ) 37 | 38 | if __name__ == "__main__": 39 | run_unittest(*tests_gui) 40 | -------------------------------------------------------------------------------- /distro/common/lib/lib-tk/test/test_ttk/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/lib-tk/test/test_ttk/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/lib-tk/test/test_ttk/support.py: -------------------------------------------------------------------------------- 1 | import Tkinter 2 | 3 | def get_tk_root(): 4 | try: 5 | root = Tkinter._default_root 6 | except AttributeError: 7 | # it is possible to disable default root in Tkinter, although 8 | # I haven't seen people doing it (but apparently someone did it 9 | # here). 10 | root = None 11 | 12 | if root is None: 13 | # create a new master only if there isn't one already 14 | root = Tkinter.Tk() 15 | 16 | return root 17 | 18 | def root_deiconify(): 19 | root = get_tk_root() 20 | root.deiconify() 21 | 22 | def root_withdraw(): 23 | root = get_tk_root() 24 | root.withdraw() 25 | 26 | 27 | def simulate_mouse_click(widget, x, y): 28 | """Generate proper events to click at the x, y position (tries to act 29 | like an X server).""" 30 | widget.event_generate('', x=0, y=0) 31 | widget.event_generate('', x=x, y=y) 32 | widget.event_generate('', x=x, y=y) 33 | widget.event_generate('', x=x, y=y) 34 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/PatternGrammar.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | # A grammar to describe tree matching patterns. 5 | # Not shown here: 6 | # - 'TOKEN' stands for any token (leaf node) 7 | # - 'any' stands for any node (leaf or interior) 8 | # With 'any' we can still specify the sub-structure. 9 | 10 | # The start symbol is 'Matcher'. 11 | 12 | Matcher: Alternatives ENDMARKER 13 | 14 | Alternatives: Alternative ('|' Alternative)* 15 | 16 | Alternative: (Unit | NegatedUnit)+ 17 | 18 | Unit: [NAME '='] ( STRING [Repeater] 19 | | NAME [Details] [Repeater] 20 | | '(' Alternatives ')' [Repeater] 21 | | '[' Alternatives ']' 22 | ) 23 | 24 | NegatedUnit: 'not' (STRING | NAME [Details] | '(' Alternatives ')') 25 | 26 | Repeater: '*' | '+' | '{' NUMBER [',' NUMBER] '}' 27 | 28 | Details: '<' Alternatives '>' 29 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/__init__.py: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from .main import main 3 | 4 | sys.exit(main("lib2to3.fixes")) 5 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/__init__.py: -------------------------------------------------------------------------------- 1 | # Dummy file to make this directory a package. 2 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_apply.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for apply(). 5 | 6 | This converts apply(func, v, k) into (func)(*v, **k).""" 7 | 8 | # Local imports 9 | from .. import pytree 10 | from ..pgen2 import token 11 | from .. import fixer_base 12 | from ..fixer_util import Call, Comma, parenthesize 13 | 14 | class FixApply(fixer_base.BaseFix): 15 | BM_compatible = True 16 | 17 | PATTERN = """ 18 | power< 'apply' 19 | trailer< 20 | '(' 21 | arglist< 22 | (not argument 26 | ')' 27 | > 28 | > 29 | """ 30 | 31 | def transform(self, node, results): 32 | syms = self.syms 33 | assert results 34 | func = results["func"] 35 | args = results["args"] 36 | kwds = results.get("kwds") 37 | prefix = node.prefix 38 | func = func.clone() 39 | if (func.type not in (token.NAME, syms.atom) and 40 | (func.type != syms.power or 41 | func.children[-2].type == token.DOUBLESTAR)): 42 | # Need to parenthesize 43 | func = parenthesize(func) 44 | func.prefix = "" 45 | args = args.clone() 46 | args.prefix = "" 47 | if kwds is not None: 48 | kwds = kwds.clone() 49 | kwds.prefix = "" 50 | l_newargs = [pytree.Leaf(token.STAR, u"*"), args] 51 | if kwds is not None: 52 | l_newargs.extend([Comma(), 53 | pytree.Leaf(token.DOUBLESTAR, u"**"), 54 | kwds]) 55 | l_newargs[-2].prefix = u" " # that's the ** token 56 | # XXX Sometimes we could be cleverer, e.g. apply(f, (x, y) + t) 57 | # can be translated into f(x, y, *t) instead of f(*(x, y) + t) 58 | #new = pytree.Node(syms.power, (func, ArgList(l_newargs))) 59 | return Call(func, l_newargs, prefix=prefix) 60 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_basestring.py: -------------------------------------------------------------------------------- 1 | """Fixer for basestring -> str.""" 2 | # Author: Christian Heimes 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name 7 | 8 | class FixBasestring(fixer_base.BaseFix): 9 | BM_compatible = True 10 | 11 | PATTERN = "'basestring'" 12 | 13 | def transform(self, node, results): 14 | return Name(u"str", prefix=node.prefix) 15 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_buffer.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that changes buffer(...) into memoryview(...).""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | 11 | class FixBuffer(fixer_base.BaseFix): 12 | BM_compatible = True 13 | 14 | explicit = True # The user must ask for this fixer 15 | 16 | PATTERN = """ 17 | power< name='buffer' trailer< '(' [any] ')' > any* > 18 | """ 19 | 20 | def transform(self, node, results): 21 | name = results["name"] 22 | name.replace(Name(u"memoryview", prefix=name.prefix)) 23 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_callable.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for callable(). 5 | 6 | This converts callable(obj) into isinstance(obj, collections.Callable), adding a 7 | collections import if needed.""" 8 | 9 | # Local imports 10 | from lib2to3 import fixer_base 11 | from lib2to3.fixer_util import Call, Name, String, Attr, touch_import 12 | 13 | class FixCallable(fixer_base.BaseFix): 14 | BM_compatible = True 15 | 16 | order = "pre" 17 | 18 | # Ignore callable(*args) or use of keywords. 19 | # Either could be a hint that the builtin callable() is not being used. 20 | PATTERN = """ 21 | power< 'callable' 22 | trailer< lpar='(' 23 | ( not(arglist | argument) any ','> ) 25 | rpar=')' > 26 | after=any* 27 | > 28 | """ 29 | 30 | def transform(self, node, results): 31 | func = results['func'] 32 | 33 | touch_import(None, u'collections', node=node) 34 | 35 | args = [func.clone(), String(u', ')] 36 | args.extend(Attr(Name(u'collections'), Name(u'Callable'))) 37 | return Call(Name(u'isinstance'), args, prefix=node.prefix) 38 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_exec.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for exec. 5 | 6 | This converts usages of the exec statement into calls to a built-in 7 | exec() function. 8 | 9 | exec code in ns1, ns2 -> exec(code, ns1, ns2) 10 | """ 11 | 12 | # Local imports 13 | from .. import pytree 14 | from .. import fixer_base 15 | from ..fixer_util import Comma, Name, Call 16 | 17 | 18 | class FixExec(fixer_base.BaseFix): 19 | BM_compatible = True 20 | 21 | PATTERN = """ 22 | exec_stmt< 'exec' a=any 'in' b=any [',' c=any] > 23 | | 24 | exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any > 25 | """ 26 | 27 | def transform(self, node, results): 28 | assert results 29 | syms = self.syms 30 | a = results["a"] 31 | b = results.get("b") 32 | c = results.get("c") 33 | args = [a.clone()] 34 | args[0].prefix = "" 35 | if b is not None: 36 | args.extend([Comma(), b.clone()]) 37 | if c is not None: 38 | args.extend([Comma(), c.clone()]) 39 | 40 | return Call(Name(u"exec"), args, prefix=node.prefix) 41 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_execfile.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for execfile. 5 | 6 | This converts usages of the execfile function into calls to the built-in 7 | exec() function. 8 | """ 9 | 10 | from .. import fixer_base 11 | from ..fixer_util import (Comma, Name, Call, LParen, RParen, Dot, Node, 12 | ArgList, String, syms) 13 | 14 | 15 | class FixExecfile(fixer_base.BaseFix): 16 | BM_compatible = True 17 | 18 | PATTERN = """ 19 | power< 'execfile' trailer< '(' arglist< filename=any [',' globals=any [',' locals=any ] ] > ')' > > 20 | | 21 | power< 'execfile' trailer< '(' filename=any ')' > > 22 | """ 23 | 24 | def transform(self, node, results): 25 | assert results 26 | filename = results["filename"] 27 | globals = results.get("globals") 28 | locals = results.get("locals") 29 | 30 | # Copy over the prefix from the right parentheses end of the execfile 31 | # call. 32 | execfile_paren = node.children[-1].children[-1].clone() 33 | # Construct open().read(). 34 | open_args = ArgList([filename.clone()], rparen=execfile_paren) 35 | open_call = Node(syms.power, [Name(u"open"), open_args]) 36 | read = [Node(syms.trailer, [Dot(), Name(u'read')]), 37 | Node(syms.trailer, [LParen(), RParen()])] 38 | open_expr = [open_call] + read 39 | # Wrap the open call in a compile call. This is so the filename will be 40 | # preserved in the execed code. 41 | filename_arg = filename.clone() 42 | filename_arg.prefix = u" " 43 | exec_str = String(u"'exec'", u" ") 44 | compile_args = open_expr + [Comma(), filename_arg, Comma(), exec_str] 45 | compile_call = Call(Name(u"compile"), compile_args, u"") 46 | # Finally, replace the execfile call with an exec call. 47 | args = [compile_call] 48 | if globals is not None: 49 | args.extend([Comma(), globals.clone()]) 50 | if locals is not None: 51 | args.extend([Comma(), locals.clone()]) 52 | return Call(Name(u"exec"), args, prefix=node.prefix) 53 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_funcattrs.py: -------------------------------------------------------------------------------- 1 | """Fix function attribute names (f.func_x -> f.__x__).""" 2 | # Author: Collin Winter 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name 7 | 8 | 9 | class FixFuncattrs(fixer_base.BaseFix): 10 | BM_compatible = True 11 | 12 | PATTERN = """ 13 | power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals' 14 | | 'func_name' | 'func_defaults' | 'func_code' 15 | | 'func_dict') > any* > 16 | """ 17 | 18 | def transform(self, node, results): 19 | attr = results["attr"][0] 20 | attr.replace(Name((u"__%s__" % attr.value[5:]), 21 | prefix=attr.prefix)) 22 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_future.py: -------------------------------------------------------------------------------- 1 | """Remove __future__ imports 2 | 3 | from __future__ import foo is replaced with an empty line. 4 | """ 5 | # Author: Christian Heimes 6 | 7 | # Local imports 8 | from .. import fixer_base 9 | from ..fixer_util import BlankLine 10 | 11 | class FixFuture(fixer_base.BaseFix): 12 | BM_compatible = True 13 | 14 | PATTERN = """import_from< 'from' module_name="__future__" 'import' any >""" 15 | 16 | # This should be run last -- some things check for the import 17 | run_order = 10 18 | 19 | def transform(self, node, results): 20 | new = BlankLine() 21 | new.prefix = node.prefix 22 | return new 23 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_getcwdu.py: -------------------------------------------------------------------------------- 1 | """ 2 | Fixer that changes os.getcwdu() to os.getcwd(). 3 | """ 4 | # Author: Victor Stinner 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | class FixGetcwdu(fixer_base.BaseFix): 11 | BM_compatible = True 12 | 13 | PATTERN = """ 14 | power< 'os' trailer< dot='.' name='getcwdu' > any* > 15 | """ 16 | 17 | def transform(self, node, results): 18 | name = results["name"] 19 | name.replace(Name(u"getcwd", prefix=name.prefix)) 20 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_imports2.py: -------------------------------------------------------------------------------- 1 | """Fix incompatible imports and module references that must be fixed after 2 | fix_imports.""" 3 | from . import fix_imports 4 | 5 | 6 | MAPPING = { 7 | 'whichdb': 'dbm', 8 | 'anydbm': 'dbm', 9 | } 10 | 11 | 12 | class FixImports2(fix_imports.FixImports): 13 | 14 | run_order = 7 15 | 16 | mapping = MAPPING 17 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_input.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes input(...) into eval(input(...)).""" 2 | # Author: Andre Roberge 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Call, Name 7 | from .. import patcomp 8 | 9 | 10 | context = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >") 11 | 12 | 13 | class FixInput(fixer_base.BaseFix): 14 | BM_compatible = True 15 | PATTERN = """ 16 | power< 'input' args=trailer< '(' [any] ')' > > 17 | """ 18 | 19 | def transform(self, node, results): 20 | # If we're already wrapped in a eval() call, we're done. 21 | if context.match(node.parent.parent): 22 | return 23 | 24 | new = node.clone() 25 | new.prefix = u"" 26 | return Call(Name(u"eval"), [new], prefix=node.prefix) 27 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_intern.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Georg Brandl. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for intern(). 5 | 6 | intern(s) -> sys.intern(s)""" 7 | 8 | # Local imports 9 | from .. import pytree 10 | from .. import fixer_base 11 | from ..fixer_util import Name, Attr, touch_import 12 | 13 | 14 | class FixIntern(fixer_base.BaseFix): 15 | BM_compatible = True 16 | order = "pre" 17 | 18 | PATTERN = """ 19 | power< 'intern' 20 | trailer< lpar='(' 21 | ( not(arglist | argument) any ','> ) 23 | rpar=')' > 24 | after=any* 25 | > 26 | """ 27 | 28 | def transform(self, node, results): 29 | syms = self.syms 30 | obj = results["obj"].clone() 31 | if obj.type == syms.arglist: 32 | newarglist = obj.clone() 33 | else: 34 | newarglist = pytree.Node(syms.arglist, [obj.clone()]) 35 | after = results["after"] 36 | if after: 37 | after = [n.clone() for n in after] 38 | new = pytree.Node(syms.power, 39 | Attr(Name(u"sys"), Name(u"intern")) + 40 | [pytree.Node(syms.trailer, 41 | [results["lpar"].clone(), 42 | newarglist, 43 | results["rpar"].clone()])] + after) 44 | new.prefix = node.prefix 45 | touch_import(None, u'sys', node) 46 | return new 47 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_isinstance.py: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Armin Ronacher. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that cleans up a tuple argument to isinstance after the tokens 5 | in it were fixed. This is mainly used to remove double occurrences of 6 | tokens as a leftover of the long -> int / unicode -> str conversion. 7 | 8 | eg. isinstance(x, (int, long)) -> isinstance(x, (int, int)) 9 | -> isinstance(x, int) 10 | """ 11 | 12 | from .. import fixer_base 13 | from ..fixer_util import token 14 | 15 | 16 | class FixIsinstance(fixer_base.BaseFix): 17 | BM_compatible = True 18 | PATTERN = """ 19 | power< 20 | 'isinstance' 21 | trailer< '(' arglist< any ',' atom< '(' 22 | args=testlist_gexp< any+ > 23 | ')' > > ')' > 24 | > 25 | """ 26 | 27 | run_order = 6 28 | 29 | def transform(self, node, results): 30 | names_inserted = set() 31 | testlist = results["args"] 32 | args = testlist.children 33 | new_args = [] 34 | iterator = enumerate(args) 35 | for idx, arg in iterator: 36 | if arg.type == token.NAME and arg.value in names_inserted: 37 | if idx < len(args) - 1 and args[idx + 1].type == token.COMMA: 38 | iterator.next() 39 | continue 40 | else: 41 | new_args.append(arg) 42 | if arg.type == token.NAME: 43 | names_inserted.add(arg.value) 44 | if new_args and new_args[-1].type == token.COMMA: 45 | del new_args[-1] 46 | if len(new_args) == 1: 47 | atom = testlist.parent 48 | new_args[0].prefix = atom.prefix 49 | atom.replace(new_args[0]) 50 | else: 51 | args[:] = new_args 52 | node.changed() 53 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_itertools.py: -------------------------------------------------------------------------------- 1 | """ Fixer for itertools.(imap|ifilter|izip) --> (map|filter|zip) and 2 | itertools.ifilterfalse --> itertools.filterfalse (bugs 2360-2363) 3 | 4 | imports from itertools are fixed in fix_itertools_import.py 5 | 6 | If itertools is imported as something else (ie: import itertools as it; 7 | it.izip(spam, eggs)) method calls will not get fixed. 8 | """ 9 | 10 | # Local imports 11 | from .. import fixer_base 12 | from ..fixer_util import Name 13 | 14 | class FixItertools(fixer_base.BaseFix): 15 | BM_compatible = True 16 | it_funcs = "('imap'|'ifilter'|'izip'|'izip_longest'|'ifilterfalse')" 17 | PATTERN = """ 18 | power< it='itertools' 19 | trailer< 20 | dot='.' func=%(it_funcs)s > trailer< '(' [any] ')' > > 21 | | 22 | power< func=%(it_funcs)s trailer< '(' [any] ')' > > 23 | """ %(locals()) 24 | 25 | # Needs to be run after fix_(map|zip|filter) 26 | run_order = 6 27 | 28 | def transform(self, node, results): 29 | prefix = None 30 | func = results['func'][0] 31 | if ('it' in results and 32 | func.value not in (u'ifilterfalse', u'izip_longest')): 33 | dot, it = (results['dot'], results['it']) 34 | # Remove the 'itertools' 35 | prefix = it.prefix 36 | it.remove() 37 | # Replace the node wich contains ('.', 'function') with the 38 | # function (to be consistant with the second part of the pattern) 39 | dot.remove() 40 | func.parent.replace(func) 41 | 42 | prefix = prefix or func.prefix 43 | func.replace(Name(func.value[1:], prefix=prefix)) 44 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_itertools_imports.py: -------------------------------------------------------------------------------- 1 | """ Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ 2 | 3 | # Local imports 4 | from lib2to3 import fixer_base 5 | from lib2to3.fixer_util import BlankLine, syms, token 6 | 7 | 8 | class FixItertoolsImports(fixer_base.BaseFix): 9 | BM_compatible = True 10 | PATTERN = """ 11 | import_from< 'from' 'itertools' 'import' imports=any > 12 | """ %(locals()) 13 | 14 | def transform(self, node, results): 15 | imports = results['imports'] 16 | if imports.type == syms.import_as_name or not imports.children: 17 | children = [imports] 18 | else: 19 | children = imports.children 20 | for child in children[::2]: 21 | if child.type == token.NAME: 22 | member = child.value 23 | name_node = child 24 | elif child.type == token.STAR: 25 | # Just leave the import as is. 26 | return 27 | else: 28 | assert child.type == syms.import_as_name 29 | name_node = child.children[0] 30 | member_name = name_node.value 31 | if member_name in (u'imap', u'izip', u'ifilter'): 32 | child.value = None 33 | child.remove() 34 | elif member_name in (u'ifilterfalse', u'izip_longest'): 35 | node.changed() 36 | name_node.value = (u'filterfalse' if member_name[1] == u'f' 37 | else u'zip_longest') 38 | 39 | # Make sure the import statement is still sane 40 | children = imports.children[:] or [imports] 41 | remove_comma = True 42 | for child in children: 43 | if remove_comma and child.type == token.COMMA: 44 | child.remove() 45 | else: 46 | remove_comma ^= True 47 | 48 | while children and children[-1].type == token.COMMA: 49 | children.pop().remove() 50 | 51 | # If there are no imports left, just get rid of the entire statement 52 | if (not (imports.children or getattr(imports, 'value', None)) or 53 | imports.parent is None): 54 | p = node.prefix 55 | node = BlankLine() 56 | node.prefix = p 57 | return node 58 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_long.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that turns 'long' into 'int' everywhere. 5 | """ 6 | 7 | # Local imports 8 | from lib2to3 import fixer_base 9 | from lib2to3.fixer_util import is_probably_builtin 10 | 11 | 12 | class FixLong(fixer_base.BaseFix): 13 | BM_compatible = True 14 | PATTERN = "'long'" 15 | 16 | def transform(self, node, results): 17 | if is_probably_builtin(node): 18 | node.value = u"int" 19 | node.changed() 20 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_methodattrs.py: -------------------------------------------------------------------------------- 1 | """Fix bound method attributes (method.im_? -> method.__?__). 2 | """ 3 | # Author: Christian Heimes 4 | 5 | # Local imports 6 | from .. import fixer_base 7 | from ..fixer_util import Name 8 | 9 | MAP = { 10 | "im_func" : "__func__", 11 | "im_self" : "__self__", 12 | "im_class" : "__self__.__class__" 13 | } 14 | 15 | class FixMethodattrs(fixer_base.BaseFix): 16 | BM_compatible = True 17 | PATTERN = """ 18 | power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* > 19 | """ 20 | 21 | def transform(self, node, results): 22 | attr = results["attr"][0] 23 | new = unicode(MAP[attr.value]) 24 | attr.replace(Name(new, prefix=attr.prefix)) 25 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_ne.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that turns <> into !=.""" 5 | 6 | # Local imports 7 | from .. import pytree 8 | from ..pgen2 import token 9 | from .. import fixer_base 10 | 11 | 12 | class FixNe(fixer_base.BaseFix): 13 | # This is so simple that we don't need the pattern compiler. 14 | 15 | _accept_type = token.NOTEQUAL 16 | 17 | def match(self, node): 18 | # Override 19 | return node.value == u"<>" 20 | 21 | def transform(self, node, results): 22 | new = pytree.Leaf(token.NOTEQUAL, u"!=", prefix=node.prefix) 23 | return new 24 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_nonzero.py: -------------------------------------------------------------------------------- 1 | """Fixer for __nonzero__ -> __bool__ methods.""" 2 | # Author: Collin Winter 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name, syms 7 | 8 | class FixNonzero(fixer_base.BaseFix): 9 | BM_compatible = True 10 | PATTERN = """ 11 | classdef< 'class' any+ ':' 12 | suite< any* 13 | funcdef< 'def' name='__nonzero__' 14 | parameters< '(' NAME ')' > any+ > 15 | any* > > 16 | """ 17 | 18 | def transform(self, node, results): 19 | name = results["name"] 20 | new = Name(u"__bool__", prefix=name.prefix) 21 | name.replace(new) 22 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_numliterals.py: -------------------------------------------------------------------------------- 1 | """Fixer that turns 1L into 1, 0755 into 0o755. 2 | """ 3 | # Copyright 2007 Georg Brandl. 4 | # Licensed to PSF under a Contributor Agreement. 5 | 6 | # Local imports 7 | from ..pgen2 import token 8 | from .. import fixer_base 9 | from ..fixer_util import Number 10 | 11 | 12 | class FixNumliterals(fixer_base.BaseFix): 13 | # This is so simple that we don't need the pattern compiler. 14 | 15 | _accept_type = token.NUMBER 16 | 17 | def match(self, node): 18 | # Override 19 | return (node.value.startswith(u"0") or node.value[-1] in u"Ll") 20 | 21 | def transform(self, node, results): 22 | val = node.value 23 | if val[-1] in u'Ll': 24 | val = val[:-1] 25 | elif val.startswith(u'0') and val.isdigit() and len(set(val)) > 1: 26 | val = u"0o" + val[1:] 27 | 28 | return Number(val, prefix=node.prefix) 29 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_paren.py: -------------------------------------------------------------------------------- 1 | """Fixer that addes parentheses where they are required 2 | 3 | This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.""" 4 | 5 | # By Taek Joo Kim and Benjamin Peterson 6 | 7 | # Local imports 8 | from .. import fixer_base 9 | from ..fixer_util import LParen, RParen 10 | 11 | # XXX This doesn't support nested for loops like [x for x in 1, 2 for x in 1, 2] 12 | class FixParen(fixer_base.BaseFix): 13 | BM_compatible = True 14 | 15 | PATTERN = """ 16 | atom< ('[' | '(') 17 | (listmaker< any 18 | comp_for< 19 | 'for' NAME 'in' 20 | target=testlist_safe< any (',' any)+ [','] 21 | > 22 | [any] 23 | > 24 | > 25 | | 26 | testlist_gexp< any 27 | comp_for< 28 | 'for' NAME 'in' 29 | target=testlist_safe< any (',' any)+ [','] 30 | > 31 | [any] 32 | > 33 | >) 34 | (']' | ')') > 35 | """ 36 | 37 | def transform(self, node, results): 38 | target = results["target"] 39 | 40 | lparen = LParen() 41 | lparen.prefix = target.prefix 42 | target.prefix = u"" # Make it hug the parentheses 43 | target.insert_child(0, lparen) 44 | target.append_child(RParen()) 45 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_raw_input.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes raw_input(...) into input(...).""" 2 | # Author: Andre Roberge 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name 7 | 8 | class FixRawInput(fixer_base.BaseFix): 9 | 10 | BM_compatible = True 11 | PATTERN = """ 12 | power< name='raw_input' trailer< '(' [any] ')' > any* > 13 | """ 14 | 15 | def transform(self, node, results): 16 | name = results["name"] 17 | name.replace(Name(u"input", prefix=name.prefix)) 18 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_reduce.py: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Armin Ronacher. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for reduce(). 5 | 6 | Makes sure reduce() is imported from the functools module if reduce is 7 | used in that module. 8 | """ 9 | 10 | from lib2to3 import fixer_base 11 | from lib2to3.fixer_util import touch_import 12 | 13 | 14 | 15 | class FixReduce(fixer_base.BaseFix): 16 | 17 | BM_compatible = True 18 | order = "pre" 19 | 20 | PATTERN = """ 21 | power< 'reduce' 22 | trailer< '(' 23 | arglist< ( 24 | (not(argument) any ',' 27 | not(argument 31 | > 32 | """ 33 | 34 | def transform(self, node, results): 35 | touch_import(u'functools', u'reduce', node) 36 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_repr.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that transforms `xyzzy` into repr(xyzzy).""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Call, Name, parenthesize 9 | 10 | 11 | class FixRepr(fixer_base.BaseFix): 12 | 13 | BM_compatible = True 14 | PATTERN = """ 15 | atom < '`' expr=any '`' > 16 | """ 17 | 18 | def transform(self, node, results): 19 | expr = results["expr"].clone() 20 | 21 | if expr.type == self.syms.testlist1: 22 | expr = parenthesize(expr) 23 | return Call(Name(u"repr"), [expr], prefix=node.prefix) 24 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_set_literal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Optional fixer to transform set() calls to set literals. 3 | """ 4 | 5 | # Author: Benjamin Peterson 6 | 7 | from lib2to3 import fixer_base, pytree 8 | from lib2to3.fixer_util import token, syms 9 | 10 | 11 | 12 | class FixSetLiteral(fixer_base.BaseFix): 13 | 14 | BM_compatible = True 15 | explicit = True 16 | 17 | PATTERN = """power< 'set' trailer< '(' 18 | (atom=atom< '[' (items=listmaker< any ((',' any)* [',']) > 19 | | 20 | single=any) ']' > 21 | | 22 | atom< '(' items=testlist_gexp< any ((',' any)* [',']) > ')' > 23 | ) 24 | ')' > > 25 | """ 26 | 27 | def transform(self, node, results): 28 | single = results.get("single") 29 | if single: 30 | # Make a fake listmaker 31 | fake = pytree.Node(syms.listmaker, [single.clone()]) 32 | single.replace(fake) 33 | items = fake 34 | else: 35 | items = results["items"] 36 | 37 | # Build the contents of the literal 38 | literal = [pytree.Leaf(token.LBRACE, u"{")] 39 | literal.extend(n.clone() for n in items.children) 40 | literal.append(pytree.Leaf(token.RBRACE, u"}")) 41 | # Set the prefix of the right brace to that of the ')' or ']' 42 | literal[-1].prefix = items.next_sibling.prefix 43 | maker = pytree.Node(syms.dictsetmaker, literal) 44 | maker.prefix = node.prefix 45 | 46 | # If the original was a one tuple, we need to remove the extra comma. 47 | if len(maker.children) == 4: 48 | n = maker.children[2] 49 | n.remove() 50 | maker.children[-1].prefix = n.prefix 51 | 52 | # Finally, replace the set call with our shiny new literal. 53 | return maker 54 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_standarderror.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for StandardError -> Exception.""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | 11 | class FixStandarderror(fixer_base.BaseFix): 12 | BM_compatible = True 13 | PATTERN = """ 14 | 'StandardError' 15 | """ 16 | 17 | def transform(self, node, results): 18 | return Name(u"Exception", prefix=node.prefix) 19 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_sys_exc.py: -------------------------------------------------------------------------------- 1 | """Fixer for sys.exc_{type, value, traceback} 2 | 3 | sys.exc_type -> sys.exc_info()[0] 4 | sys.exc_value -> sys.exc_info()[1] 5 | sys.exc_traceback -> sys.exc_info()[2] 6 | """ 7 | 8 | # By Jeff Balogh and Benjamin Peterson 9 | 10 | # Local imports 11 | from .. import fixer_base 12 | from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms 13 | 14 | class FixSysExc(fixer_base.BaseFix): 15 | # This order matches the ordering of sys.exc_info(). 16 | exc_info = [u"exc_type", u"exc_value", u"exc_traceback"] 17 | BM_compatible = True 18 | PATTERN = """ 19 | power< 'sys' trailer< dot='.' attribute=(%s) > > 20 | """ % '|'.join("'%s'" % e for e in exc_info) 21 | 22 | def transform(self, node, results): 23 | sys_attr = results["attribute"][0] 24 | index = Number(self.exc_info.index(sys_attr.value)) 25 | 26 | call = Call(Name(u"exc_info"), prefix=sys_attr.prefix) 27 | attr = Attr(Name(u"sys"), call) 28 | attr[1].children[0].prefix = results["dot"].prefix 29 | attr.append(Subscript(index)) 30 | return Node(syms.power, attr, prefix=node.prefix) 31 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_throw.py: -------------------------------------------------------------------------------- 1 | """Fixer for generator.throw(E, V, T). 2 | 3 | g.throw(E) -> g.throw(E) 4 | g.throw(E, V) -> g.throw(E(V)) 5 | g.throw(E, V, T) -> g.throw(E(V).with_traceback(T)) 6 | 7 | g.throw("foo"[, V[, T]]) will warn about string exceptions.""" 8 | # Author: Collin Winter 9 | 10 | # Local imports 11 | from .. import pytree 12 | from ..pgen2 import token 13 | from .. import fixer_base 14 | from ..fixer_util import Name, Call, ArgList, Attr, is_tuple 15 | 16 | class FixThrow(fixer_base.BaseFix): 17 | BM_compatible = True 18 | PATTERN = """ 19 | power< any trailer< '.' 'throw' > 20 | trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' > 21 | > 22 | | 23 | power< any trailer< '.' 'throw' > trailer< '(' exc=any ')' > > 24 | """ 25 | 26 | def transform(self, node, results): 27 | syms = self.syms 28 | 29 | exc = results["exc"].clone() 30 | if exc.type is token.STRING: 31 | self.cannot_convert(node, "Python 3 does not support string exceptions") 32 | return 33 | 34 | # Leave "g.throw(E)" alone 35 | val = results.get(u"val") 36 | if val is None: 37 | return 38 | 39 | val = val.clone() 40 | if is_tuple(val): 41 | args = [c.clone() for c in val.children[1:-1]] 42 | else: 43 | val.prefix = u"" 44 | args = [val] 45 | 46 | throw_args = results["args"] 47 | 48 | if "tb" in results: 49 | tb = results["tb"].clone() 50 | tb.prefix = u"" 51 | 52 | e = Call(exc, args) 53 | with_tb = Attr(e, Name(u'with_traceback')) + [ArgList([tb])] 54 | throw_args.replace(pytree.Node(syms.power, with_tb)) 55 | else: 56 | throw_args.replace(Call(exc, args)) 57 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_types.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for removing uses of the types module. 5 | 6 | These work for only the known names in the types module. The forms above 7 | can include types. or not. ie, It is assumed the module is imported either as: 8 | 9 | import types 10 | from types import ... # either * or specific types 11 | 12 | The import statements are not modified. 13 | 14 | There should be another fixer that handles at least the following constants: 15 | 16 | type([]) -> list 17 | type(()) -> tuple 18 | type('') -> str 19 | 20 | """ 21 | 22 | # Local imports 23 | from ..pgen2 import token 24 | from .. import fixer_base 25 | from ..fixer_util import Name 26 | 27 | _TYPE_MAPPING = { 28 | 'BooleanType' : 'bool', 29 | 'BufferType' : 'memoryview', 30 | 'ClassType' : 'type', 31 | 'ComplexType' : 'complex', 32 | 'DictType': 'dict', 33 | 'DictionaryType' : 'dict', 34 | 'EllipsisType' : 'type(Ellipsis)', 35 | #'FileType' : 'io.IOBase', 36 | 'FloatType': 'float', 37 | 'IntType': 'int', 38 | 'ListType': 'list', 39 | 'LongType': 'int', 40 | 'ObjectType' : 'object', 41 | 'NoneType': 'type(None)', 42 | 'NotImplementedType' : 'type(NotImplemented)', 43 | 'SliceType' : 'slice', 44 | 'StringType': 'bytes', # XXX ? 45 | 'StringTypes' : 'str', # XXX ? 46 | 'TupleType': 'tuple', 47 | 'TypeType' : 'type', 48 | 'UnicodeType': 'str', 49 | 'XRangeType' : 'range', 50 | } 51 | 52 | _pats = ["power< 'types' trailer< '.' name='%s' > >" % t for t in _TYPE_MAPPING] 53 | 54 | class FixTypes(fixer_base.BaseFix): 55 | BM_compatible = True 56 | PATTERN = '|'.join(_pats) 57 | 58 | def transform(self, node, results): 59 | new_value = unicode(_TYPE_MAPPING.get(results["name"].value)) 60 | if new_value: 61 | return Name(new_value, prefix=node.prefix) 62 | return None 63 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_unicode.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes unicode to str, unichr to chr, and u"..." into "...". 2 | 3 | """ 4 | 5 | import re 6 | from ..pgen2 import token 7 | from .. import fixer_base 8 | 9 | _mapping = {u"unichr" : u"chr", u"unicode" : u"str"} 10 | _literal_re = re.compile(ur"[uU][rR]?[\'\"]") 11 | 12 | class FixUnicode(fixer_base.BaseFix): 13 | BM_compatible = True 14 | PATTERN = "STRING | 'unicode' | 'unichr'" 15 | 16 | def transform(self, node, results): 17 | if node.type == token.NAME: 18 | new = node.clone() 19 | new.value = _mapping[node.value] 20 | return new 21 | elif node.type == token.STRING: 22 | if _literal_re.match(node.value): 23 | new = node.clone() 24 | new.value = new.value[1:] 25 | return new 26 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_ws_comma.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes 'a ,b' into 'a, b'. 2 | 3 | This also changes '{a :b}' into '{a: b}', but does not touch other 4 | uses of colons. It does not touch other uses of whitespace. 5 | 6 | """ 7 | 8 | from .. import pytree 9 | from ..pgen2 import token 10 | from .. import fixer_base 11 | 12 | class FixWsComma(fixer_base.BaseFix): 13 | 14 | explicit = True # The user must ask for this fixers 15 | 16 | PATTERN = """ 17 | any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]> 18 | """ 19 | 20 | COMMA = pytree.Leaf(token.COMMA, u",") 21 | COLON = pytree.Leaf(token.COLON, u":") 22 | SEPS = (COMMA, COLON) 23 | 24 | def transform(self, node, results): 25 | new = node.clone() 26 | comma = False 27 | for child in new.children: 28 | if child in self.SEPS: 29 | prefix = child.prefix 30 | if prefix.isspace() and u"\n" not in prefix: 31 | child.prefix = u"" 32 | comma = True 33 | else: 34 | if comma: 35 | prefix = child.prefix 36 | if not prefix: 37 | child.prefix = u" " 38 | comma = False 39 | return new 40 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_xreadlines.py: -------------------------------------------------------------------------------- 1 | """Fix "for x in f.xreadlines()" -> "for x in f". 2 | 3 | This fixer will also convert g(f.xreadlines) into g(f.__iter__).""" 4 | # Author: Collin Winter 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | 11 | class FixXreadlines(fixer_base.BaseFix): 12 | BM_compatible = True 13 | PATTERN = """ 14 | power< call=any+ trailer< '.' 'xreadlines' > trailer< '(' ')' > > 15 | | 16 | power< any+ trailer< '.' no_call='xreadlines' > > 17 | """ 18 | 19 | def transform(self, node, results): 20 | no_call = results.get("no_call") 21 | 22 | if no_call: 23 | no_call.replace(Name(u"__iter__", prefix=no_call.prefix)) 24 | else: 25 | node.replace([x.clone() for x in results["call"]]) 26 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/fixes/fix_zip.py: -------------------------------------------------------------------------------- 1 | """ 2 | Fixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...) 3 | unless there exists a 'from future_builtins import zip' statement in the 4 | top-level namespace. 5 | 6 | We avoid the transformation if the zip() call is directly contained in 7 | iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:. 8 | """ 9 | 10 | # Local imports 11 | from .. import fixer_base 12 | from ..fixer_util import Name, Call, in_special_context 13 | 14 | class FixZip(fixer_base.ConditionalFix): 15 | 16 | BM_compatible = True 17 | PATTERN = """ 18 | power< 'zip' args=trailer< '(' [any] ')' > 19 | > 20 | """ 21 | 22 | skip_on = "future_builtins.zip" 23 | 24 | def transform(self, node, results): 25 | if self.should_skip(node): 26 | return 27 | 28 | if in_special_context(node): 29 | return None 30 | 31 | new = node.clone() 32 | new.prefix = u"" 33 | new = Call(Name(u"list"), [new]) 34 | new.prefix = node.prefix 35 | return new 36 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/pgen2/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """The pgen2 package.""" 5 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/pgen2/literals.py: -------------------------------------------------------------------------------- 1 | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Safely evaluate Python string literals without using eval().""" 5 | 6 | import re 7 | 8 | simple_escapes = {"a": "\a", 9 | "b": "\b", 10 | "f": "\f", 11 | "n": "\n", 12 | "r": "\r", 13 | "t": "\t", 14 | "v": "\v", 15 | "'": "'", 16 | '"': '"', 17 | "\\": "\\"} 18 | 19 | def escape(m): 20 | all, tail = m.group(0, 1) 21 | assert all.startswith("\\") 22 | esc = simple_escapes.get(tail) 23 | if esc is not None: 24 | return esc 25 | if tail.startswith("x"): 26 | hexes = tail[1:] 27 | if len(hexes) < 2: 28 | raise ValueError("invalid hex string escape ('\\%s')" % tail) 29 | try: 30 | i = int(hexes, 16) 31 | except ValueError: 32 | raise ValueError("invalid hex string escape ('\\%s')" % tail) 33 | else: 34 | try: 35 | i = int(tail, 8) 36 | except ValueError: 37 | raise ValueError("invalid octal string escape ('\\%s')" % tail) 38 | return chr(i) 39 | 40 | def evalString(s): 41 | assert s.startswith("'") or s.startswith('"'), repr(s[:1]) 42 | q = s[0] 43 | if s[:3] == q*3: 44 | q = q*3 45 | assert s.endswith(q), repr(s[-len(q):]) 46 | assert len(s) >= 2*len(q) 47 | s = s[len(q):-len(q)] 48 | return re.sub(r"\\(\'|\"|\\|[abfnrtv]|x.{0,2}|[0-7]{1,3})", escape, s) 49 | 50 | def test(): 51 | for i in range(256): 52 | c = chr(i) 53 | s = repr(c) 54 | e = evalString(s) 55 | if e != c: 56 | print i, c, s, e 57 | 58 | 59 | if __name__ == "__main__": 60 | test() 61 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/pgen2/token.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """Token constants (from "token.h").""" 4 | 5 | # Taken from Python (r53757) and modified to include some tokens 6 | # originally monkeypatched in by pgen2.tokenize 7 | 8 | #--start constants-- 9 | ENDMARKER = 0 10 | NAME = 1 11 | NUMBER = 2 12 | STRING = 3 13 | NEWLINE = 4 14 | INDENT = 5 15 | DEDENT = 6 16 | LPAR = 7 17 | RPAR = 8 18 | LSQB = 9 19 | RSQB = 10 20 | COLON = 11 21 | COMMA = 12 22 | SEMI = 13 23 | PLUS = 14 24 | MINUS = 15 25 | STAR = 16 26 | SLASH = 17 27 | VBAR = 18 28 | AMPER = 19 29 | LESS = 20 30 | GREATER = 21 31 | EQUAL = 22 32 | DOT = 23 33 | PERCENT = 24 34 | BACKQUOTE = 25 35 | LBRACE = 26 36 | RBRACE = 27 37 | EQEQUAL = 28 38 | NOTEQUAL = 29 39 | LESSEQUAL = 30 40 | GREATEREQUAL = 31 41 | TILDE = 32 42 | CIRCUMFLEX = 33 43 | LEFTSHIFT = 34 44 | RIGHTSHIFT = 35 45 | DOUBLESTAR = 36 46 | PLUSEQUAL = 37 47 | MINEQUAL = 38 48 | STAREQUAL = 39 49 | SLASHEQUAL = 40 50 | PERCENTEQUAL = 41 51 | AMPEREQUAL = 42 52 | VBAREQUAL = 43 53 | CIRCUMFLEXEQUAL = 44 54 | LEFTSHIFTEQUAL = 45 55 | RIGHTSHIFTEQUAL = 46 56 | DOUBLESTAREQUAL = 47 57 | DOUBLESLASH = 48 58 | DOUBLESLASHEQUAL = 49 59 | AT = 50 60 | OP = 51 61 | COMMENT = 52 62 | NL = 53 63 | RARROW = 54 64 | ERRORTOKEN = 55 65 | N_TOKENS = 56 66 | NT_OFFSET = 256 67 | #--end constants-- 68 | 69 | tok_name = {} 70 | for _name, _value in globals().items(): 71 | if type(_value) is type(0): 72 | tok_name[_value] = _name 73 | 74 | 75 | def ISTERMINAL(x): 76 | return x < NT_OFFSET 77 | 78 | def ISNONTERMINAL(x): 79 | return x >= NT_OFFSET 80 | 81 | def ISEOF(x): 82 | return x == ENDMARKER 83 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/pygram.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Export the Python grammar and symbols.""" 5 | 6 | # Python imports 7 | import os 8 | 9 | # Local imports 10 | from .pgen2 import token 11 | from .pgen2 import driver 12 | from . import pytree 13 | 14 | # The grammar file 15 | _GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt") 16 | _PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), 17 | "PatternGrammar.txt") 18 | 19 | 20 | class Symbols(object): 21 | 22 | def __init__(self, grammar): 23 | """Initializer. 24 | 25 | Creates an attribute for each grammar symbol (nonterminal), 26 | whose value is the symbol's type (an int >= 256). 27 | """ 28 | for name, symbol in grammar.symbol2number.iteritems(): 29 | setattr(self, name, symbol) 30 | 31 | 32 | python_grammar = driver.load_grammar(_GRAMMAR_FILE) 33 | 34 | python_symbols = Symbols(python_grammar) 35 | 36 | python_grammar_no_print_statement = python_grammar.copy() 37 | del python_grammar_no_print_statement.keywords["print"] 38 | 39 | pattern_grammar = driver.load_grammar(_PATTERN_GRAMMAR_FILE) 40 | pattern_symbols = Symbols(pattern_grammar) 41 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/bad_order.py: -------------------------------------------------------------------------------- 1 | from lib2to3.fixer_base import BaseFix 2 | 3 | class FixBadOrder(BaseFix): 4 | 5 | order = "crazy" 6 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/myfixes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/lib2to3/tests/data/fixers/myfixes/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/myfixes/fix_explicit.py: -------------------------------------------------------------------------------- 1 | from lib2to3.fixer_base import BaseFix 2 | 3 | class FixExplicit(BaseFix): 4 | explicit = True 5 | 6 | def match(self): return False 7 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/myfixes/fix_first.py: -------------------------------------------------------------------------------- 1 | from lib2to3.fixer_base import BaseFix 2 | 3 | class FixFirst(BaseFix): 4 | run_order = 1 5 | 6 | def match(self, node): return False 7 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/myfixes/fix_last.py: -------------------------------------------------------------------------------- 1 | from lib2to3.fixer_base import BaseFix 2 | 3 | class FixLast(BaseFix): 4 | 5 | run_order = 10 6 | 7 | def match(self, node): return False 8 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/myfixes/fix_parrot.py: -------------------------------------------------------------------------------- 1 | from lib2to3.fixer_base import BaseFix 2 | from lib2to3.fixer_util import Name 3 | 4 | class FixParrot(BaseFix): 5 | """ 6 | Change functions named 'parrot' to 'cheese'. 7 | """ 8 | 9 | PATTERN = """funcdef < 'def' name='parrot' any* >""" 10 | 11 | def transform(self, node, results): 12 | name = results["name"] 13 | name.replace(Name("cheese", name.prefix)) 14 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py: -------------------------------------------------------------------------------- 1 | from lib2to3.fixer_base import BaseFix 2 | 3 | class FixPreorder(BaseFix): 4 | order = "pre" 5 | 6 | def match(self, node): return False 7 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/no_fixer_cls.py: -------------------------------------------------------------------------------- 1 | # This is empty so trying to fetch the fixer class gives an AttributeError 2 | -------------------------------------------------------------------------------- /distro/common/lib/lib2to3/tests/data/fixers/parrot_example.py: -------------------------------------------------------------------------------- 1 | def parrot(): 2 | pass 3 | -------------------------------------------------------------------------------- /distro/common/lib/md5.py: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Copyright (C) 2005 Gregory P. Smith (greg@krypto.org) 4 | # Licensed to PSF under a Contributor Agreement. 5 | 6 | import warnings 7 | warnings.warn("the md5 module is deprecated; use hashlib instead", 8 | DeprecationWarning, 2) 9 | 10 | from hashlib import md5 11 | new = md5 12 | 13 | blocksize = 1 # legacy value (wrong in any useful sense) 14 | digest_size = 16 15 | -------------------------------------------------------------------------------- /distro/common/lib/msilib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/msilib/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/mutex.py: -------------------------------------------------------------------------------- 1 | """Mutual exclusion -- for use with module sched 2 | 3 | A mutex has two pieces of state -- a 'locked' bit and a queue. 4 | When the mutex is not locked, the queue is empty. 5 | Otherwise, the queue contains 0 or more (function, argument) pairs 6 | representing functions (or methods) waiting to acquire the lock. 7 | When the mutex is unlocked while the queue is not empty, 8 | the first queue entry is removed and its function(argument) pair called, 9 | implying it now has the lock. 10 | 11 | Of course, no multi-threading is implied -- hence the funny interface 12 | for lock, where a function is called once the lock is aquired. 13 | """ 14 | from warnings import warnpy3k 15 | warnpy3k("the mutex module has been removed in Python 3.0", stacklevel=2) 16 | del warnpy3k 17 | 18 | from collections import deque 19 | 20 | class mutex: 21 | def __init__(self): 22 | """Create a new mutex -- initially unlocked.""" 23 | self.locked = False 24 | self.queue = deque() 25 | 26 | def test(self): 27 | """Test the locked bit of the mutex.""" 28 | return self.locked 29 | 30 | def testandset(self): 31 | """Atomic test-and-set -- grab the lock if it is not set, 32 | return True if it succeeded.""" 33 | if not self.locked: 34 | self.locked = True 35 | return True 36 | else: 37 | return False 38 | 39 | def lock(self, function, argument): 40 | """Lock a mutex, call the function with supplied argument 41 | when it is acquired. If the mutex is already locked, place 42 | function and argument in the queue.""" 43 | if self.testandset(): 44 | function(argument) 45 | else: 46 | self.queue.append((function, argument)) 47 | 48 | def unlock(self): 49 | """Unlock a mutex. If the queue is not empty, call the next 50 | function with its argument.""" 51 | if self.queue: 52 | function, argument = self.queue.popleft() 53 | function(argument) 54 | else: 55 | self.locked = False 56 | -------------------------------------------------------------------------------- /distro/common/lib/new.py: -------------------------------------------------------------------------------- 1 | """Create new objects of various types. Deprecated. 2 | 3 | This module is no longer required except for backward compatibility. 4 | Objects of most types can now be created by calling the type object. 5 | """ 6 | from warnings import warnpy3k 7 | warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' " 8 | "module instead.", stacklevel=2) 9 | del warnpy3k 10 | 11 | from types import ClassType as classobj 12 | from types import FunctionType as function 13 | from types import InstanceType as instance 14 | from types import MethodType as instancemethod 15 | from types import ModuleType as module 16 | 17 | from types import CodeType as code 18 | -------------------------------------------------------------------------------- /distro/common/lib/pydoc_data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/pydoc_data/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/sha.py: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Copyright (C) 2005 Gregory P. Smith (greg@krypto.org) 4 | # Licensed to PSF under a Contributor Agreement. 5 | 6 | import warnings 7 | warnings.warn("the sha module is deprecated; use the hashlib module instead", 8 | DeprecationWarning, 2) 9 | 10 | from hashlib import sha1 as sha 11 | new = sha 12 | 13 | blocksize = 1 # legacy value (wrong in any useful sense) 14 | digest_size = 20 15 | digestsize = 20 16 | -------------------------------------------------------------------------------- /distro/common/lib/shlex.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/shlex.py -------------------------------------------------------------------------------- /distro/common/lib/site-packages/README.txt: -------------------------------------------------------------------------------- 1 | This directory exists so that 3rd party packages can be installed 2 | here. Read the source for site.py for more details. 3 | -------------------------------------------------------------------------------- /distro/common/lib/sqlite3/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/sqlite3/__init__.py -------------------------------------------------------------------------------- /distro/common/lib/sqlite3/dbapi2.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/sqlite3/dbapi2.py -------------------------------------------------------------------------------- /distro/common/lib/sre.py: -------------------------------------------------------------------------------- 1 | """This file is only retained for backwards compatibility. 2 | It will be removed in the future. sre was moved to re in version 2.5. 3 | """ 4 | 5 | import warnings 6 | warnings.warn("The sre module is deprecated, please import re.", 7 | DeprecationWarning, 2) 8 | 9 | from re import * 10 | from re import __all__ 11 | 12 | # old pickles expect the _compile() reconstructor in this module 13 | from re import _compile 14 | -------------------------------------------------------------------------------- /distro/common/lib/stat.py: -------------------------------------------------------------------------------- 1 | """Constants/functions for interpreting results of os.stat() and os.lstat(). 2 | 3 | Suggested usage: from stat import * 4 | """ 5 | 6 | # Indices for stat struct members in the tuple returned by os.stat() 7 | 8 | ST_MODE = 0 9 | ST_INO = 1 10 | ST_DEV = 2 11 | ST_NLINK = 3 12 | ST_UID = 4 13 | ST_GID = 5 14 | ST_SIZE = 6 15 | ST_ATIME = 7 16 | ST_MTIME = 8 17 | ST_CTIME = 9 18 | 19 | # Extract bits from the mode 20 | 21 | def S_IMODE(mode): 22 | return mode & 07777 23 | 24 | def S_IFMT(mode): 25 | return mode & 0170000 26 | 27 | # Constants used as S_IFMT() for various file types 28 | # (not all are implemented on all systems) 29 | 30 | S_IFDIR = 0040000 31 | S_IFCHR = 0020000 32 | S_IFBLK = 0060000 33 | S_IFREG = 0100000 34 | S_IFIFO = 0010000 35 | S_IFLNK = 0120000 36 | S_IFSOCK = 0140000 37 | 38 | # Functions to test for each file type 39 | 40 | def S_ISDIR(mode): 41 | return S_IFMT(mode) == S_IFDIR 42 | 43 | def S_ISCHR(mode): 44 | return S_IFMT(mode) == S_IFCHR 45 | 46 | def S_ISBLK(mode): 47 | return S_IFMT(mode) == S_IFBLK 48 | 49 | def S_ISREG(mode): 50 | return S_IFMT(mode) == S_IFREG 51 | 52 | def S_ISFIFO(mode): 53 | return S_IFMT(mode) == S_IFIFO 54 | 55 | def S_ISLNK(mode): 56 | return S_IFMT(mode) == S_IFLNK 57 | 58 | def S_ISSOCK(mode): 59 | return S_IFMT(mode) == S_IFSOCK 60 | 61 | # Names for permission bits 62 | 63 | S_ISUID = 04000 64 | S_ISGID = 02000 65 | S_ENFMT = S_ISGID 66 | S_ISVTX = 01000 67 | S_IREAD = 00400 68 | S_IWRITE = 00200 69 | S_IEXEC = 00100 70 | S_IRWXU = 00700 71 | S_IRUSR = 00400 72 | S_IWUSR = 00200 73 | S_IXUSR = 00100 74 | S_IRWXG = 00070 75 | S_IRGRP = 00040 76 | S_IWGRP = 00020 77 | S_IXGRP = 00010 78 | S_IRWXO = 00007 79 | S_IROTH = 00004 80 | S_IWOTH = 00002 81 | S_IXOTH = 00001 82 | 83 | # Names for file flags 84 | 85 | UF_NODUMP = 0x00000001 86 | UF_IMMUTABLE = 0x00000002 87 | UF_APPEND = 0x00000004 88 | UF_OPAQUE = 0x00000008 89 | UF_NOUNLINK = 0x00000010 90 | SF_ARCHIVED = 0x00010000 91 | SF_IMMUTABLE = 0x00020000 92 | SF_APPEND = 0x00040000 93 | SF_NOUNLINK = 0x00100000 94 | SF_SNAPSHOT = 0x00200000 95 | -------------------------------------------------------------------------------- /distro/common/lib/statvfs.py: -------------------------------------------------------------------------------- 1 | """Constants for interpreting the results of os.statvfs() and os.fstatvfs().""" 2 | from warnings import warnpy3k 3 | warnpy3k("the statvfs module has been removed in Python 3.0", stacklevel=2) 4 | del warnpy3k 5 | 6 | # Indices for statvfs struct members in the tuple returned by 7 | # os.statvfs() and os.fstatvfs(). 8 | 9 | F_BSIZE = 0 # Preferred file system block size 10 | F_FRSIZE = 1 # Fundamental file system block size 11 | F_BLOCKS = 2 # Total number of file system blocks (FRSIZE) 12 | F_BFREE = 3 # Total number of free blocks 13 | F_BAVAIL = 4 # Free blocks available to non-superuser 14 | F_FILES = 5 # Total number of file nodes 15 | F_FFREE = 6 # Total number of free file nodes 16 | F_FAVAIL = 7 # Free nodes available to non-superuser 17 | F_FLAG = 8 # Flags (see your local statvfs man page) 18 | F_NAMEMAX = 9 # Maximum file name length 19 | -------------------------------------------------------------------------------- /distro/common/lib/struct.py: -------------------------------------------------------------------------------- 1 | from _struct import * 2 | from _struct import _clearcache 3 | from _struct import __doc__ 4 | -------------------------------------------------------------------------------- /distro/common/lib/sunaudio.py: -------------------------------------------------------------------------------- 1 | """Interpret sun audio headers.""" 2 | from warnings import warnpy3k 3 | warnpy3k("the sunaudio module has been removed in Python 3.0; " 4 | "use the sunau module instead", stacklevel=2) 5 | del warnpy3k 6 | 7 | 8 | MAGIC = '.snd' 9 | 10 | class error(Exception): 11 | pass 12 | 13 | 14 | def get_long_be(s): 15 | """Convert a 4-char value to integer.""" 16 | return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3]) 17 | 18 | 19 | def gethdr(fp): 20 | """Read a sound header from an open file.""" 21 | if fp.read(4) != MAGIC: 22 | raise error, 'gethdr: bad magic word' 23 | hdr_size = get_long_be(fp.read(4)) 24 | data_size = get_long_be(fp.read(4)) 25 | encoding = get_long_be(fp.read(4)) 26 | sample_rate = get_long_be(fp.read(4)) 27 | channels = get_long_be(fp.read(4)) 28 | excess = hdr_size - 24 29 | if excess < 0: 30 | raise error, 'gethdr: bad hdr_size' 31 | if excess > 0: 32 | info = fp.read(excess) 33 | else: 34 | info = '' 35 | return (data_size, encoding, sample_rate, channels, info) 36 | 37 | 38 | def printhdr(file): 39 | """Read and print the sound header of a named file.""" 40 | hdr = gethdr(open(file, 'r')) 41 | data_size, encoding, sample_rate, channels, info = hdr 42 | while info[-1:] == '\0': 43 | info = info[:-1] 44 | print 'File name: ', file 45 | print 'Data size: ', data_size 46 | print 'Encoding: ', encoding 47 | print 'Sample rate:', sample_rate 48 | print 'Channels: ', channels 49 | print 'Info: ', repr(info) 50 | -------------------------------------------------------------------------------- /distro/common/lib/tarfile.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/distro/common/lib/tarfile.py -------------------------------------------------------------------------------- /distro/common/lib/this.py: -------------------------------------------------------------------------------- 1 | s = """Gur Mra bs Clguba, ol Gvz Crgref 2 | 3 | Ornhgvshy vf orggre guna htyl. 4 | Rkcyvpvg vf orggre guna vzcyvpvg. 5 | Fvzcyr vf orggre guna pbzcyrk. 6 | Pbzcyrk vf orggre guna pbzcyvpngrq. 7 | Syng vf orggre guna arfgrq. 8 | Fcnefr vf orggre guna qrafr. 9 | Ernqnovyvgl pbhagf. 10 | Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf. 11 | Nygubhtu cenpgvpnyvgl orngf chevgl. 12 | Reebef fubhyq arire cnff fvyragyl. 13 | Hayrff rkcyvpvgyl fvyraprq. 14 | Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff. 15 | Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg. 16 | Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu. 17 | Abj vf orggre guna arire. 18 | Nygubhtu arire vf bsgra orggre guna *evtug* abj. 19 | Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn. 20 | Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn. 21 | Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!""" 22 | 23 | d = {} 24 | for c in (65, 97): 25 | for i in range(26): 26 | d[chr(i+c)] = chr((i+13) % 26 + c) 27 | 28 | print "".join([d.get(c, c) for c in s]) 29 | -------------------------------------------------------------------------------- /distro/common/lib/tty.py: -------------------------------------------------------------------------------- 1 | """Terminal utilities.""" 2 | 3 | # Author: Steen Lumholt. 4 | 5 | from termios import * 6 | 7 | __all__ = ["setraw", "setcbreak"] 8 | 9 | # Indexes for termios list. 10 | IFLAG = 0 11 | OFLAG = 1 12 | CFLAG = 2 13 | LFLAG = 3 14 | ISPEED = 4 15 | OSPEED = 5 16 | CC = 6 17 | 18 | def setraw(fd, when=TCSAFLUSH): 19 | """Put terminal into a raw mode.""" 20 | mode = tcgetattr(fd) 21 | mode[IFLAG] = mode[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON) 22 | mode[OFLAG] = mode[OFLAG] & ~(OPOST) 23 | mode[CFLAG] = mode[CFLAG] & ~(CSIZE | PARENB) 24 | mode[CFLAG] = mode[CFLAG] | CS8 25 | mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG) 26 | mode[CC][VMIN] = 1 27 | mode[CC][VTIME] = 0 28 | tcsetattr(fd, when, mode) 29 | 30 | def setcbreak(fd, when=TCSAFLUSH): 31 | """Put terminal into a cbreak mode.""" 32 | mode = tcgetattr(fd) 33 | mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON) 34 | mode[CC][VMIN] = 1 35 | mode[CC][VTIME] = 0 36 | tcsetattr(fd, when, mode) 37 | -------------------------------------------------------------------------------- /distro/common/lib/types.py: -------------------------------------------------------------------------------- 1 | """Define names for all type symbols known in the standard interpreter. 2 | 3 | Types that are part of optional modules (e.g. array) are not listed. 4 | """ 5 | import sys 6 | 7 | # Iterators in Python aren't a matter of type but of protocol. A large 8 | # and changing number of builtin types implement *some* flavor of 9 | # iterator. Don't check the type! Use hasattr to check for both 10 | # "__iter__" and "next" attributes instead. 11 | 12 | NoneType = type(None) 13 | TypeType = type 14 | ObjectType = object 15 | 16 | IntType = int 17 | LongType = long 18 | FloatType = float 19 | BooleanType = bool 20 | try: 21 | ComplexType = complex 22 | except NameError: 23 | pass 24 | 25 | StringType = str 26 | 27 | # StringTypes is already outdated. Instead of writing "type(x) in 28 | # types.StringTypes", you should use "isinstance(x, basestring)". But 29 | # we keep around for compatibility with Python 2.2. 30 | try: 31 | UnicodeType = unicode 32 | StringTypes = (StringType, UnicodeType) 33 | except NameError: 34 | StringTypes = (StringType,) 35 | 36 | BufferType = buffer 37 | 38 | TupleType = tuple 39 | ListType = list 40 | DictType = DictionaryType = dict 41 | 42 | def _f(): pass 43 | FunctionType = type(_f) 44 | LambdaType = type(lambda: None) # Same as FunctionType 45 | CodeType = type(_f.func_code) 46 | 47 | def _g(): 48 | yield 1 49 | GeneratorType = type(_g()) 50 | 51 | class _C: 52 | def _m(self): pass 53 | ClassType = type(_C) 54 | UnboundMethodType = type(_C._m) # Same as MethodType 55 | _x = _C() 56 | InstanceType = type(_x) 57 | MethodType = type(_x._m) 58 | 59 | BuiltinFunctionType = type(len) 60 | BuiltinMethodType = type([].append) # Same as BuiltinFunctionType 61 | 62 | ModuleType = type(sys) 63 | FileType = file 64 | XRangeType = xrange 65 | 66 | try: 67 | raise TypeError 68 | except TypeError: 69 | tb = sys.exc_info()[2] 70 | TracebackType = type(tb) 71 | FrameType = type(tb.tb_frame) 72 | del tb 73 | 74 | SliceType = slice 75 | EllipsisType = type(Ellipsis) 76 | 77 | DictProxyType = type(TypeType.__dict__) 78 | NotImplementedType = type(NotImplemented) 79 | 80 | # For Jython, the following two types are identical 81 | GetSetDescriptorType = type(FunctionType.func_code) 82 | MemberDescriptorType = type(FunctionType.func_globals) 83 | 84 | del sys, _f, _g, _C, _x # Not for export 85 | -------------------------------------------------------------------------------- /distro/common/lib/unittest/__main__.py: -------------------------------------------------------------------------------- 1 | """Main entry point""" 2 | 3 | import sys 4 | if sys.argv[0].endswith("__main__.py"): 5 | sys.argv[0] = "python -m unittest" 6 | 7 | __unittest = True 8 | 9 | from .main import main, TestProgram, USAGE_AS_MAIN 10 | TestProgram.USAGE = USAGE_AS_MAIN 11 | 12 | main(module=None) 13 | -------------------------------------------------------------------------------- /distro/common/lib/unittest/signals.py: -------------------------------------------------------------------------------- 1 | import signal 2 | import weakref 3 | 4 | from functools import wraps 5 | 6 | __unittest = True 7 | 8 | 9 | class _InterruptHandler(object): 10 | def __init__(self, default_handler): 11 | self.called = False 12 | self.default_handler = default_handler 13 | 14 | def __call__(self, signum, frame): 15 | installed_handler = signal.getsignal(signal.SIGINT) 16 | if installed_handler is not self: 17 | # if we aren't the installed handler, then delegate immediately 18 | # to the default handler 19 | self.default_handler(signum, frame) 20 | 21 | if self.called: 22 | self.default_handler(signum, frame) 23 | self.called = True 24 | for result in _results.keys(): 25 | result.stop() 26 | 27 | _results = weakref.WeakKeyDictionary() 28 | def registerResult(result): 29 | _results[result] = 1 30 | 31 | def removeResult(result): 32 | return bool(_results.pop(result, None)) 33 | 34 | _interrupt_handler = None 35 | def installHandler(): 36 | global _interrupt_handler 37 | if _interrupt_handler is None: 38 | default_handler = signal.getsignal(signal.SIGINT) 39 | _interrupt_handler = _InterruptHandler(default_handler) 40 | signal.signal(signal.SIGINT, _interrupt_handler) 41 | 42 | 43 | def removeHandler(method=None): 44 | if method is not None: 45 | @wraps(method) 46 | def inner(*args, **kwargs): 47 | initial = signal.getsignal(signal.SIGINT) 48 | removeHandler() 49 | try: 50 | return method(*args, **kwargs) 51 | finally: 52 | signal.signal(signal.SIGINT, initial) 53 | return inner 54 | 55 | global _interrupt_handler 56 | if _interrupt_handler is not None: 57 | signal.signal(signal.SIGINT, _interrupt_handler.default_handler) 58 | -------------------------------------------------------------------------------- /distro/common/lib/user.py: -------------------------------------------------------------------------------- 1 | """Hook to allow user-specified customization code to run. 2 | 3 | As a policy, Python doesn't run user-specified code on startup of 4 | Python programs (interactive sessions execute the script specified in 5 | the PYTHONSTARTUP environment variable if it exists). 6 | 7 | However, some programs or sites may find it convenient to allow users 8 | to have a standard customization file, which gets run when a program 9 | requests it. This module implements such a mechanism. A program 10 | that wishes to use the mechanism must execute the statement 11 | 12 | import user 13 | 14 | The user module looks for a file .pythonrc.py in the user's home 15 | directory and if it can be opened, execfile()s it in its own global 16 | namespace. Errors during this phase are not caught; that's up to the 17 | program that imports the user module, if it wishes. 18 | 19 | The user's .pythonrc.py could conceivably test for sys.version if it 20 | wishes to do different things depending on the Python version. 21 | 22 | """ 23 | from warnings import warnpy3k 24 | warnpy3k("the user module has been removed in Python 3.0", stacklevel=2) 25 | del warnpy3k 26 | 27 | import os 28 | 29 | home = os.curdir # Default 30 | if 'HOME' in os.environ: 31 | home = os.environ['HOME'] 32 | elif os.name == 'posix': 33 | home = os.path.expanduser("~/") 34 | elif os.name == 'nt': # Contributed by Jeff Bauer 35 | if 'HOMEPATH' in os.environ: 36 | if 'HOMEDRIVE' in os.environ: 37 | home = os.environ['HOMEDRIVE'] + os.environ['HOMEPATH'] 38 | else: 39 | home = os.environ['HOMEPATH'] 40 | 41 | pythonrc = os.path.join(home, ".pythonrc.py") 42 | try: 43 | f = open(pythonrc) 44 | except IOError: 45 | pass 46 | else: 47 | f.close() 48 | execfile(pythonrc) 49 | -------------------------------------------------------------------------------- /distro/common/lib/wsgiref/__init__.py: -------------------------------------------------------------------------------- 1 | """wsgiref -- a WSGI (PEP 333) Reference Library 2 | 3 | Current Contents: 4 | 5 | * util -- Miscellaneous useful functions and wrappers 6 | 7 | * headers -- Manage response headers 8 | 9 | * handlers -- base classes for server/gateway implementations 10 | 11 | * simple_server -- a simple BaseHTTPServer that supports WSGI 12 | 13 | * validate -- validation wrapper that sits between an app and a server 14 | to detect errors in either 15 | 16 | To-Do: 17 | 18 | * cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard) 19 | 20 | * cgi_wrapper -- Run CGI apps under WSGI 21 | 22 | * router -- a simple middleware component that handles URL traversal 23 | """ 24 | -------------------------------------------------------------------------------- /distro/common/lib/xml/__init__.py: -------------------------------------------------------------------------------- 1 | """Core XML support for Python. 2 | 3 | This package contains four sub-packages: 4 | 5 | dom -- The W3C Document Object Model. This supports DOM Level 1 + 6 | Namespaces. 7 | 8 | parsers -- Python wrappers for XML parsers (currently only supports Expat). 9 | 10 | sax -- The Simple API for XML, developed by XML-Dev, led by David 11 | Megginson and ported to Python by Lars Marius Garshol. This 12 | supports the SAX 2 API. 13 | 14 | etree -- The ElementTree XML library. This is a subset of the full 15 | ElementTree XML release. 16 | 17 | """ 18 | 19 | 20 | __all__ = ["dom", "parsers", "sax", "etree"] 21 | 22 | _MINIMUM_XMLPLUS_VERSION = (0, 8, 4) 23 | 24 | 25 | try: 26 | import _xmlplus 27 | except ImportError: 28 | pass 29 | else: 30 | try: 31 | v = _xmlplus.version_info 32 | except AttributeError: 33 | # _xmlplus is too old; ignore it 34 | pass 35 | else: 36 | if v >= _MINIMUM_XMLPLUS_VERSION: 37 | import sys 38 | _xmlplus.__path__.extend(__path__) 39 | sys.modules[__name__] = _xmlplus 40 | else: 41 | del v 42 | -------------------------------------------------------------------------------- /distro/common/lib/xml/dom/NodeFilter.py: -------------------------------------------------------------------------------- 1 | # This is the Python mapping for interface NodeFilter from 2 | # DOM2-Traversal-Range. It contains only constants. 3 | 4 | class NodeFilter: 5 | """ 6 | This is the DOM2 NodeFilter interface. It contains only constants. 7 | """ 8 | FILTER_ACCEPT = 1 9 | FILTER_REJECT = 2 10 | FILTER_SKIP = 3 11 | 12 | SHOW_ALL = 0xFFFFFFFFL 13 | SHOW_ELEMENT = 0x00000001 14 | SHOW_ATTRIBUTE = 0x00000002 15 | SHOW_TEXT = 0x00000004 16 | SHOW_CDATA_SECTION = 0x00000008 17 | SHOW_ENTITY_REFERENCE = 0x00000010 18 | SHOW_ENTITY = 0x00000020 19 | SHOW_PROCESSING_INSTRUCTION = 0x00000040 20 | SHOW_COMMENT = 0x00000080 21 | SHOW_DOCUMENT = 0x00000100 22 | SHOW_DOCUMENT_TYPE = 0x00000200 23 | SHOW_DOCUMENT_FRAGMENT = 0x00000400 24 | SHOW_NOTATION = 0x00000800 25 | 26 | def acceptNode(self, node): 27 | raise NotImplementedError 28 | -------------------------------------------------------------------------------- /distro/common/lib/xml/etree/__init__.py: -------------------------------------------------------------------------------- 1 | # $Id: __init__.py 3375 2008-02-13 08:05:08Z fredrik $ 2 | # elementtree package 3 | 4 | # -------------------------------------------------------------------- 5 | # The ElementTree toolkit is 6 | # 7 | # Copyright (c) 1999-2008 by Fredrik Lundh 8 | # 9 | # By obtaining, using, and/or copying this software and/or its 10 | # associated documentation, you agree that you have read, understood, 11 | # and will comply with the following terms and conditions: 12 | # 13 | # Permission to use, copy, modify, and distribute this software and 14 | # its associated documentation for any purpose and without fee is 15 | # hereby granted, provided that the above copyright notice appears in 16 | # all copies, and that both that copyright notice and this permission 17 | # notice appear in supporting documentation, and that the name of 18 | # Secret Labs AB or the author not be used in advertising or publicity 19 | # pertaining to distribution of the software without specific, written 20 | # prior permission. 21 | # 22 | # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD 23 | # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- 24 | # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR 25 | # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 26 | # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 27 | # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 28 | # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 29 | # OF THIS SOFTWARE. 30 | # -------------------------------------------------------------------- 31 | 32 | # Licensed to PSF under a Contributor Agreement. 33 | # See http://www.python.org/psf/license for licensing details. 34 | -------------------------------------------------------------------------------- /distro/common/lib/xml/etree/cElementTree.py: -------------------------------------------------------------------------------- 1 | # Wrapper module for _elementtree 2 | 3 | from _elementtree import * 4 | -------------------------------------------------------------------------------- /distro/common/lib/xml/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | """Python interfaces to XML parsers. 2 | 3 | This package contains one module: 4 | 5 | expat -- Python wrapper for James Clark's Expat parser, with namespace 6 | support. 7 | 8 | """ 9 | -------------------------------------------------------------------------------- /distro/common/lib/xml/parsers/expat.py: -------------------------------------------------------------------------------- 1 | """Interface to the Expat non-validating XML parser.""" 2 | __version__ = '$Revision$' 3 | 4 | from pyexpat import * 5 | -------------------------------------------------------------------------------- /distro/common/test.py: -------------------------------------------------------------------------------- 1 | #import sproxelConsole 2 | #sproxelConsole.console_write("test!") 3 | 4 | print "in test.py!!!" 5 | import sys 6 | import sproxel 7 | from PySide.QtCore import * 8 | from PySide.QtGui import * 9 | 10 | print "trying glue..." 11 | from PySide.SproxelGlue import * 12 | 13 | print "in test.py!", 1, 2, 3 14 | print "plugin pathes:", sproxel.plugin_pathes 15 | print "sys.path: ", sys.path 16 | #print "sys.modules:", sys.modules 17 | 18 | print "main window: ", repr(sproxel.main_window) 19 | 20 | #sproxel.main_window.statusBar().showMessage("Python was here!") 21 | 22 | 23 | print 'plugins info:', sproxel.plugins_info 24 | 25 | 26 | l=sproxel.Layer((10, 20, 30), name='My Layer') 27 | l.name="Changed name" 28 | l.offset=(1, 2, 3) 29 | print 'layer:', repr(l), l.name, l.offset, l.size, l.bounds, l.dataType 30 | l.set(5, 5, 5, 0x112233); 31 | print 'color:', l.getColor(5, 5, 5) 32 | #l.reset() 33 | #print 'layer:', repr(l), l.name, l.offset, l.size, l.bounds, l.dataType 34 | 35 | print '' 36 | s=sproxel.Sprite(l) 37 | print 'sprite:', repr(s) 38 | s.insertLayerAbove(0) 39 | print 'curLayerIndex:', s.curLayerIndex 40 | print 'curLayer:', s.curLayer, s.curLayer.name, s.curLayer.bounds 41 | print 'layer(0):', s.layer(0), s.layer(0).name 42 | print 'layer("Changed name"):', s.layer('Changed name') 43 | 44 | prj=sproxel.Project() 45 | print 'project:', repr(prj) 46 | prj.sprites=(s,) 47 | print 'sprites:', prj.sprites 48 | 49 | prj=sproxel.get_project() 50 | #sprites=prj.sprites 51 | #s=sproxel.Sprite(sprites[0]); s.name='python1'; sprites.append(s) 52 | #s=sproxel.Sprite(sprites[0]); s.name='python2'; sprites.append(s) 53 | #prj.sprites=sprites 54 | print 'project:', repr(prj) 55 | print 'sprites:', prj.sprites 56 | 57 | # Create a Label and show it 58 | #label = QLabel("Hello World") 59 | #label.show() 60 | -------------------------------------------------------------------------------- /distro/readme.txt: -------------------------------------------------------------------------------- 1 | Place files to be distributed with Sproxel here. 2 | Use common/ for platform-independent ones. 3 | -------------------------------------------------------------------------------- /glue/classGlue.h: -------------------------------------------------------------------------------- 1 | // List of classes passed between Python and C++ 2 | 3 | TOPYT(QMainWindow) 4 | TOPYT(QWidget) 5 | TOCPP(QWidget) 6 | 7 | #undef TOPYT 8 | #undef TOCPP 9 | -------------------------------------------------------------------------------- /glue/glue.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | #define GLUE(a, b) a##b 5 | 6 | 7 | //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ// 8 | 9 | 10 | #define TOPYT(cls) \ 11 | static PyObject* GLUE(cls, _toPy) (PyObject*, PyObject *args) \ 12 | { \ 13 | PyObject *c=PyTuple_GetItem(args, 0); \ 14 | if (!c) return NULL; \ 15 | void *p=PyCapsule_GetPointer(c, NULL); \ 16 | if (!p) return NULL; \ 17 | return Shiboken::Converter::toPython((cls*)p); \ 18 | } 19 | 20 | 21 | #define TOCPP(cls) \ 22 | static PyObject* GLUE(cls, _toCpp) (PyObject*, PyObject *args) \ 23 | { \ 24 | PyObject *w=PyTuple_GetItem(args, 0); \ 25 | if (!w) return NULL; \ 26 | cls *p=Shiboken::Converter::toCpp(w); \ 27 | if (!p) { PyErr_SetString(PyExc_StandardError, "NULL pointer in " #cls "_toCpp"); return NULL; } \ 28 | return PyCapsule_New(p, NULL, NULL); \ 29 | } 30 | 31 | 32 | #include "classGlue.h" 33 | 34 | 35 | //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ// 36 | 37 | 38 | static PyMethodDef methods[]= 39 | { 40 | #define TOPYT(cls) { #cls "_toPy" , GLUE(cls, _toPy ), METH_VARARGS, "Convert " #cls " to Python." }, 41 | #define TOCPP(cls) { #cls "_toCpp", GLUE(cls, _toCpp), METH_VARARGS, "Convert " #cls " to C++." }, 42 | #include "classGlue.h" 43 | { NULL, NULL, 0, NULL } 44 | }; 45 | 46 | 47 | //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ// 48 | 49 | 50 | PyTypeObject** SbkPySide_QtCoreTypes=NULL; 51 | PyTypeObject** SbkPySide_QtGuiTypes=NULL; 52 | 53 | 54 | PyMODINIT_FUNC initSproxelGlue() 55 | { 56 | if (!Shiboken::importModule("PySide.QtCore", &SbkPySide_QtCoreTypes)) 57 | { 58 | PyErr_SetString(PyExc_ImportError, "Could not import PySide.QtCore"); 59 | return; 60 | } 61 | 62 | if (!Shiboken::importModule("PySide.QtGui", &SbkPySide_QtGuiTypes)) 63 | { 64 | PyErr_SetString(PyExc_ImportError, "Could not import PySide.QtGui"); 65 | return; 66 | } 67 | 68 | Py_InitModule("PySide.SproxelGlue", methods); 69 | } 70 | -------------------------------------------------------------------------------- /glue/glue.pro: -------------------------------------------------------------------------------- 1 | # SPROXEL glue to PySide Python module 2 | 3 | TARGET = SproxelGlue 4 | TEMPLATE = lib 5 | CONFIG += shared 6 | 7 | win32 { 8 | TARGET_EXT = .pyd 9 | QMAKE_CXXFLAGS += -wd4522 -wd4800 -wd4100 -wd4244 10 | } 11 | 12 | 13 | INCLUDEPATH += ../../python/include 14 | LIBS += -L../../python/libs -lpython27 15 | 16 | INCLUDEPATH += ../../pyside/include/shiboken \ 17 | ../../pyside/include/PySide \ 18 | ../../pyside/include/PySide/QtCore \ 19 | ../../pyside/include/PySide/QtGui 20 | 21 | LIBS += -L../../pyside/lib -lshiboken-python2.7 -lpyside-python2.7 22 | 23 | SOURCES += glue.cpp 24 | HEADERS += classGlue.h 25 | -------------------------------------------------------------------------------- /icons/box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/box.png -------------------------------------------------------------------------------- /icons/eraser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/eraser.png -------------------------------------------------------------------------------- /icons/extrude.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/extrude.png -------------------------------------------------------------------------------- /icons/eyeDropper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/eyeDropper.png -------------------------------------------------------------------------------- /icons/layerDelete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/layerDelete.png -------------------------------------------------------------------------------- /icons/layerDuplicate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/layerDuplicate.png -------------------------------------------------------------------------------- /icons/layerEye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/layerEye.png -------------------------------------------------------------------------------- /icons/layerNew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/layerNew.png -------------------------------------------------------------------------------- /icons/line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/line.png -------------------------------------------------------------------------------- /icons/paintBucket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/paintBucket.png -------------------------------------------------------------------------------- /icons/pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/pencil.png -------------------------------------------------------------------------------- /icons/redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/redo.png -------------------------------------------------------------------------------- /icons/slab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/slab.png -------------------------------------------------------------------------------- /icons/splat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/splat.png -------------------------------------------------------------------------------- /icons/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/icons/undo.png -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include "ImportExport.h" 3 | #include "script.h" 4 | #include "ConsoleWidget.h" 5 | #include "pyConsole.h" 6 | 7 | #include 8 | #include 9 | 10 | 11 | MainWindow *main_window=NULL; 12 | 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | QString filename = ""; 17 | if (argc > 1) 18 | filename = argv[1]; 19 | 20 | QApplication a(argc, argv); 21 | 22 | register_builtin_importers_exporters(); 23 | 24 | #ifdef SPROXEL_USE_PYTHON 25 | init_script(argc>=1 ? argv[0] : "sproxel.exe"); 26 | #endif 27 | 28 | MainWindow window(filename); 29 | main_window=&window; 30 | window.show(); 31 | 32 | #ifdef SPROXEL_USE_PYTHON 33 | script_set_main_window(&window); 34 | scan_plugins(); 35 | register_plugins(); 36 | run_script("startup.py"); 37 | //get_python_console_widget()->toggleViewAction()->setChecked(true); 38 | #endif 39 | 40 | int r=a.exec(); 41 | #ifdef SPROXEL_USE_PYTHON 42 | unregister_plugins(); 43 | close_script(); 44 | #endif 45 | main_window=NULL; 46 | return r; 47 | } 48 | -------------------------------------------------------------------------------- /pyBindings.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPROXEL_PY_BINDINGS_H__ 2 | #define __SPROXEL_PY_BINDINGS_H__ 3 | 4 | 5 | #include "script.h" 6 | #include "SproxelProject.h" 7 | #include "UndoManager.h" 8 | 9 | 10 | PyObject* sprite_to_py(VoxelGridGroupPtr sprite); 11 | PyObject* project_to_py(SproxelProjectPtr proj); 12 | PyObject* undo_manager_to_py(UndoManager *); 13 | 14 | 15 | PyObject* PySproxel_registerImporter(PyObject*, PyObject *arg); 16 | PyObject* PySproxel_unregisterImporter(PyObject*, PyObject *arg); 17 | PyObject* PySproxel_registerExporter(PyObject*, PyObject *arg); 18 | PyObject* PySproxel_unregisterExporter(PyObject*, PyObject *arg); 19 | 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /pyConsole.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPROXEL_PY_CONSOLE_H__ 2 | #define __SPROXEL_PY_CONSOLE_H__ 3 | 4 | 5 | void init_python_console(); 6 | void close_python_console(); 7 | 8 | void pycon_raw(const char *s); 9 | void pycon(const char *fmt, ...); 10 | 11 | class ConsoleWidget* get_python_console_widget(); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /script.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPROXEL_SCRIPT_H__ 2 | #define __SPROXEL_SCRIPT_H__ 3 | 4 | #ifdef SPROXEL_USE_PYTHON 5 | 6 | #if defined(__APPLE__) 7 | #include 8 | #else 9 | # include 10 | #endif 11 | 12 | 13 | void init_script(const char *exe_path); 14 | void close_script(); 15 | 16 | void script_set_main_window(class MainWindow *); 17 | 18 | void scan_plugins(); 19 | void register_plugins(); 20 | void unregister_plugins(); 21 | 22 | bool run_script(const class QString &filename); 23 | 24 | 25 | #define GLUE(a, b) a##b 26 | #define TOPYT(cls) PyObject * GLUE(cls, _toPy ) (class cls *); 27 | #define TOCPP(cls) class cls* GLUE(cls, _toCpp) (PyObject *); 28 | #include "glue/classGlue.h" 29 | #undef GLUE 30 | 31 | 32 | extern class QDir exe_dir; 33 | 34 | extern PyObject *py_save_project, *py_load_project; 35 | 36 | 37 | PyObject* qstr_to_py(const QString &str); 38 | 39 | bool py_to_qstr(PyObject *o, QString &str); 40 | 41 | #endif 42 | #endif 43 | -------------------------------------------------------------------------------- /sproxel.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/sproxel.icns -------------------------------------------------------------------------------- /sproxel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/sproxel.ico -------------------------------------------------------------------------------- /sproxel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emilk/sproxel/eb867498e034788faa369f5e51597791af1f54ea/sproxel.png -------------------------------------------------------------------------------- /sproxel.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/eraser.png 4 | icons/eyeDropper.png 5 | icons/paintBucket.png 6 | icons/pencil.png 7 | icons/redo.png 8 | icons/slab.png 9 | icons/splat.png 10 | icons/line.png 11 | icons/undo.png 12 | icons/layerEye.png 13 | icons/layerNew.png 14 | icons/layerDuplicate.png 15 | icons/layerDelete.png 16 | icons/box.png 17 | icons/extrude.png 18 | 19 | 20 | -------------------------------------------------------------------------------- /sproxel.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "sproxel.ico" 2 | -------------------------------------------------------------------------------- /util/blendercubes.py: -------------------------------------------------------------------------------- 1 | import string 2 | import bpy 3 | import mathutils 4 | 5 | fp = open("/nethome/joeld/tree1.csv") 6 | 7 | lines = list( filter( lambda x: len(x.strip()), fp.readlines() ) ) 8 | fp.close() 9 | 10 | sz = tuple(map( lambda x: int(x), lines[0].split(','))) 11 | lines = list(map(lambda x: x.strip(), lines[1:] )) 12 | lines.reverse() 13 | 14 | print("size is " + str(sz)) 15 | 16 | 17 | for yval in range(sz[1]): 18 | 19 | xzlines = lines[ yval*sz[2] : yval*sz[2] + sz[2] ] 20 | for zval in range(sz[2]): 21 | zline = xzlines[zval] 22 | 23 | voxels = zline.split(",") 24 | for xval in range(sz[0]): 25 | 26 | col = voxels[xval] 27 | if not col == "#00000000": 28 | bpy.ops.mesh.primitive_cube_add() 29 | c = bpy.context.active_object 30 | c.delta_location = mathutils.Vector(( xval*2, zval*2, yval*2 )) --------------------------------------------------------------------------------