GitXplorerGitXplorer
l

giofile

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
98b10255480a73856bcc1cca7c41254f654f660d

tests: start dbus

llazka committed 7 years ago
Unverified
1f199d37d5c586fc00a6fe375540ac0a1084e594

Add gvfs-backends

llazka committed 7 years ago
Unverified
975458456df203ed9065df591b3a2b4f0e2ec227

grrr

llazka committed 7 years ago
Unverified
64c11da92595cc5310165e753ecb52c461dffab1

glib-networking maybe?

llazka committed 7 years ago
Unverified
a89340e8d3a95ca39f4ea8cc977160f5b3931d03

docker: add libsoup

llazka committed 7 years ago
Unverified
b0ecefde8a0893b4dcdc8460ae8ff356c9c13c65

tests: use yield_fixture to support older pytest

llazka committed 7 years ago

README

The README file for this repository.

giofile


Opens a Gio.File as a Python file object

.. code:: python

def open(file, mode="r", buffering=-1, encoding=None, errors=None,
         newline=None, cancellable=None):
    """
    Like io.open() but takes a Gio.File instead of a filename.

    The only modes supported are r/rw/rb/r+b
    Takes a cancellable kwarg for passing a Gio.Cancellable().
    Cancelling it will abort any ongoing blocking operation.

    Returns a io.IOBase instance.
    """

.. image:: https://travis-ci.org/lazka/giofile.svg?branch=master :target: https://travis-ci.org/lazka/giofile

Installation

::

pip install giofile

Example

.. code:: python

import mutagen
import giofile
from gi.repository import Gio

gio_file = Gio.File.new_for_uri(
    "http://people.xiph.org/~giles/2012/opus/ehren-paper_lights-96.opus")

cancellable = Gio.Cancellable.new()
with giofile.open(gio_file, "rb", cancellable=cancellable) as gfile:
    print(mutagen.File(gfile).pprint())

.. code:: sh

$ python example.py
Ogg Opus, 228.11 seconds (audio/ogg)
ENCODER=opusenc from opus-tools 0.1.5
artist=Ehren Starks
title=Paper Lights
album=Lines Build Walls
date=2005-09-05
copyright=Copyright 2005 Ehren Starks
license=http://creativecommons.org/licenses/by-nc-sa/1.0/
organization=magnatune.com