Does a Python implementation of, or interface to, UCL exist? - python

UCL can be found here:
http://www.oberhumer.com/opensource/ucl/
I am wondering if there is a Python implementation of this library or, at minimum, a simple interface (via SWIG, or even ctypes) exists?
The only evidence I could find of such an implementation led me here:
https://build.opensuse.org/package/show?package=python-ucl-common&project=home%3Asjcundy%3AAccessGrid
Which when you try to download the package, you receive an error page.

Maybe this answer is a little late, but I've just done a simple implementation using cffi (https://bitbucket.org/cffi/cffi).
You can find it at https://github.com/jap/pyucl (only tested on Linux)

Many compression algorithms are available for Python, in zlib, bz2, zipfile, and externally, for example lzo (on the same web site as UCL).
If you really need UCL, try cTypesGen, which should automatically be able to provide you a Python interface to it.

Related

Python calling and using windows dll’s

I've to ask 1 question about python and dll functions which I'm a bit frustrated about. The question is - Can I load dll functions from windows using python? I heard of Ctype to do that, but I can’t find good tutorials for this. Is there another way to use dll files from windows to get extra functionality?
I want to call some dll to work with mouse events. I used pyautogui but it is not that useful for me. I wonder if python is good for windows applications? I know it runs on Windows however there are good dll function that can provide better functionality for windows then python original libraries. Well that’s my opinion what I think. Anyways, is it worth to work with dlls with python after all? Or I better study C# for that because I love python for simplicity and don’t want to move to C# yet.
Yes you can. The ctypes library is indeed what you need. The official doc is here https://docs.python.org/3/library/ctypes.html .
Loading DLLs pretty straightforward, but calling the functions inside can be a pain depending on the arguments types. Handling old C style error return codes is also cumbersome compared to the exception handling and general low overhead code style in Python.
99% of the time it is way easier and better to use an appropriate existing module that either implements what you need or wraps the appropriate DLL for you. For example search in PyPI which is the central repository of Python expternal modules. That's my advice.

Insert Image into PPT using Standard Libraries

I know this is possible to do using additional libraries such as win32com or python-pptx, but I wasn wondering if anyone knew of a way to insert an image into a powerpoint slide using the standard libraries. Lots of googling has indicated that the best solution is probably win32com, but since I can guarantee that every system this script will be deployed to will have win32com, I am looking for an implemention leveraging libraries all systems with a standard python 2.7 install will have.
It is probably possible to modify a .pptx file with the standard library without much effort: these new generation of files are meant to be zip-compressed XML + external images files, and can be handled by ziplib and standard xml parsers.
Legacy .ppt files however are a binary closed format, with little documentation, and hundrededs of corner cases. It would alwasys "be possible" to change them, since they are still just bytes, but it would take considerable effort.
That said, starting with Python 3.4, the Python installer "PIP" comes default with the language install: probably the best way to go would be to script the installation of external libraries based on the built-in PIP - that way one would not have to all external library usage.

Does Python have a rope data structure?

In writing some Python code, I came upon a need for a string-like data structure that offers fast insertion into, access to, and deletion from arbitrary positions. The first data structure that came to mind was a rope. Does Python have a rope data structure already implemented somewhere? I've looked through the standard library and PyPI, but I haven't seen one. (It doesn't help that there's a refactoring library for Python by the name of Rope as well as a company called Python Rope that sells wire rope.)
There isn't one in the standard library, but there are implementations out there, e.g. pyropes.
There's also this list of various non-built-in data structure implementations for Python.
Yes! there is one package available at PyPI.org for Rope data structure(named pyropes), written purely in Python 3. You can install it using
pip install pyropes
It also have full documentation on how to use it. Though it requires Python >=3.6(because it uses f-strings)

Python binding to ImageMagick

I am looking for a good Python binding to ImageMagick, but there seem a lot of bindings already. I am not sure that which of these is the right tool for my job. Can you guys recommend me one?
Here is the list of my requirements and preferences (in order of importance):
Must be available on PyPI (to simplify our deployment)
Prefer ctypes over C API extension — we will go PyPy soon
Pythonic API design and naming conventions
Good documentation (especially API references)
I found the package myself: magickwand is a ctypes-based ImageMagick binding for Python. Yet it has no documentation at all, it still satisfies most of my requirements.
Plus: I finally started my own project: Wand.

writing an api for python that can be installed using setup.py method

I am new at writing APIs in python, in any language for that matter. I was hoping to get pointers on how i can create an API that can be installed using setup.py method and used in other python projects. Something similar to the twitterapi.
I have already created and coded all the methods i want to include in the API. I just need to know how to implement the installation so other can use my code to leverage ideas they may have. Or if i need to format the code a certain way to facilitate installation.
I learn best with examples or tutorials.
Thanks so much.
It's worth noting that this part of python is undergoing some changes right now. It's all a bit messy. The most current overview I know of is the Hitchhiker's Guide to Packaging: http://guide.python-distribute.org/
The current state of packaging section is important: http://guide.python-distribute.org/introduction.html#current-state-of-packaging
The python packaging world is a mess (like poswald said). Here's a brief overview along with a bunch of pointers. Your basic problem (using setup.py etc.) is solved by reading the distutils guide which msw has mentioned in his comment.
Now for the dirt. The basic infrastructure of the distribution modules which is in the Python standard library is distutils referred to above. It's limited in some ways and so a series of extensions was written on top of it called setuptools. Setuptools along with actually increasing the functionality provided a command line "installer" called "easy_install".
Setuptools maintenance was not too great and so it was forked and a more active branch called "distribute" was setup and it is the preferred alternative right now. In addition to this, a replacement for easy_install named pip was created which was more modular and useful.
Now there's a huge project going which attempts to fold in all changes from distribute and stuff into a unified library that will go into the stdlib. It's tentatively called "distutils2".

Categories

Resources