GitXplorerGitXplorer
l

giofile

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
59117aa2eb5dfe633da54d921b0c5c9547b31361

version bump

llazka committed 7 years ago
Unverified
1d8b6e48b2313e6d89ed3fca62b648c07c4531d3

release

llazka committed 7 years ago
Unverified
2ea2907c9de2bdfb286bae055585072edd6e55bb

README: add note about pip

llazka committed 7 years ago
Unverified
c8a58bb734cfbc1bf1ea0d27939e8473d3be4cb8

version bump

llazka committed 7 years ago
Unverified
853b896d5ae8ee6df41f19af425248c446ce1f22

release

llazka committed 7 years ago
Unverified
3f0c67ef3e8e12e089979547e13f28e026cd9784

link travis

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