pombredanne / fpath Goto Github PK
View Code? Open in Web Editor NEWThis project forked from wackywendell/fpath
Path objects for Python
Home Page: http://pypi.python.org/pypi/fpath/0.1
License: MIT License
This project forked from wackywendell/fpath
Path objects for Python
Home Page: http://pypi.python.org/pypi/fpath/0.1
License: MIT License
Description =========== This module provides 4 objects, Path, File, Link, and Dir, that provide easy manipulation of path objects. The main class, Path, represents a path on the filesystem. It is a subclass of tuple, with directories as entries and the final entry being the file name, allowing slices to give pieces of the Path object. The methods of these four objects pretty much cover all the functionality of the os and os.path modules, in a far more convenient and object-oriented fashion. Example ======= >>> from fpath import Path, File, Link, Dir >>> p = Path('~') >>> p.norm() # gives a normalized version of the path Path('/home/wendell') >>> p = p.norm().transform() # 'transform' looks at the type of file, and # returns a Dir, File, or Link object based # upon what is in the filesystem >>> p Dir(u'/home/wendell') >>> p + 'test.txt' # strings, tuples of strings, and other Paths # can be added to Paths Path('/home/wendell/test.txt') >>> d=Dir(p + 'scripts') >>> len(list(d.children())) 160 # My scripts directory has 160 entries in it >>> len(list(d.walk('f'))) 550 # My scripts directory has 550 files (not # directories) in it, including in sub-dirs >>> f = File(p + 'test.txt') >>> f.touch() >>> f.extension 'txt' >>> f[-1] # Paths are subclasses of Tuple, and slicing # can be really useful 'test.txt' >>> f[:-1] Dir(u'/home/wendell') >>> myfile = f.open() >>> myfile.read() '' >>> myfile.close() >>> f.remove() >>> f.transform() Path('/home/wendell/test.txt') For more information, look at the doc strings - they are extensive. Basis ===== This is in response to PEP 355: http://www.python.org/dev/peps/pep-0355/ PEP 355 "lingered", but was rejected based on the fact that the proposed form was the "ultimate kitchen sink" - it had too many methods. This form is vastly different, in that it is a subclass of tuple and not str, and splits methods based on whether they are general path methods, or specific to links, files, or dirs, and as such, is far more useable. Methods have been kept to a bare minimum while still remaining complete. More Information and Bugs ========================= At the current version (0.6), Posix, Windows, and Mac paths are supported, and has been tested on both Windows and Linux. Please report any bugs: http://github.com/wackywendell/fpath Also available through pypi: http://pypi.python.org/pypi/fpath
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.