Giter VIP home page Giter VIP logo

pyramiding's Introduction

Q: What do zip files and mpeg4 files have in common?
A: Both are containers. In the first case for more files, in the latter case for one or more video and or audio streams. A video stream again is a container -- it contains still images. A file in the zip file most likely also is a container for something else.

In general, most file formats can be considered containers for subparts which in turn also are containers. This is a hierarchical recursive structure much like a directory tree.

pyramiding generalises traversal and read access of such a tree of containers, no matter if it is a directory tree or some structure inside a file.

pyramiding consists of several python modules that can be seen as 'drivers' for a specific file format. Such a driver is called 'Archive'. Archives know how to iterate over the contents of a file they support, provide data streams (file-like objects) for each item they contain and meta data about those items. Data stream and meta data are combined by 'Resources'.

An Archive contains Resourcees, a Resource is the input data stream of an Archive instance. Archives read a Resource to enumerate its children.

Archives are used by Resources internally. The class Resource is the only visible class outside pyrmaiding.

pyramiding will use lazy evaluation and caching to free the developer from efficiency concerns.

from pyRamiding import Resource

try:
	data = Resource(file("videos.tar"))
	name = data["info.ini"]["section1"]["name"].read()
	# smae as data.find("info.ini/section1/name").as_string()
	image_resource, location = data.find("icon.jpg/image"), data.find("icon.jpg/exif/geo-location")
	width, height = image_resource.details.width, image_resource.details.height 
	rgb_data = image_resource.read()

	for version in data.find("versions"):
		if version["video"].details.width >= desired_width:
			break

	print "Selected video file %(name)s, size: %(width)d x %(height)d pixels" % version["video"].details

	last_frame_data = version["video"][version["video"].details.frame_count - 1].read()
except ResourceNotFound, e:
	print e.path, "does not exist"

As a first milestone, the following Archives will be implemented (probably even in this order)
- Thank You..!
- ini
- tar
- json, js
- png
- jpg, jpeg
- mpg, mpeg, mp4
- zip

pyramiding's People

Contributors

pranjalpansuriya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.