write_path and load_path methods for file generation scripts

Category: Python - Miscellaneous

I have a lot of scripts that end up writing files (often build system stuff). Everytime I either end up writing the obvious quick content = open(path).read() or I re-implement a function that handles things like: making a backup, some typical logging, encoding support, trying to make it no-op if no changes, etc.

In this recipe I'll try to add a number of these features so I don't have to keep re-writing this. :) So far this is just a start.

Current features:


rudimentary encoding support
logging on a given log argument
create_backup argument to create a backup file
writes to a temporary file and uses atomic os.rename to avoid destroying the existing file if writing fails Date: 27 February, 2012


Files

Homepage: http://code.activestate.com/recipes/577172-write_path-and-load_path-methods-for-file-generati/?in=lang-python

Developer: Trent Mick

License: Freeware

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

ANDREW's Not a DVD Ripping and Encoding Wizard, but an interactive wrapper or a Bash script that uses oggenc, mencoder and mkv/ogmmerge to create, from a DVD, Matroska or Ogg Media files containing an ISO MPEG-4 compliant video track, encoded using FFmpeg libavcodec or XviD codec, one or more AC-3 or Vorbis audio tracks and a chapters index.

developer Developer: Alessandro Di Rubbo
license License: GNU General Public License (GPL)
operating systems Operating System: Platform Independent


dhtmlxVault is a DHTML file upload component that helps to implement modern and feature-rich file uploading part of a web application.

developer Developer: Ivan Petrenko
license License: GNU General Public License (GPL)
operating systems Operating System: Cross-Platform


Provider of data recovery software offers file rescue solution to retrieve lost, missed data from damaged storage media.

developer Developer: Data Recovery Reviews
license License: GNU General Public License (GPL)
operating systems Operating System: Not Available


Deal with file recovery program for recovering deleted pictures, images, recordings from zune media player.

developer Developer: file recovery
license License: GNU General Public License (GPL)
operating systems Operating System: Not Available


Downloads available for file recovery tools that provide solutions for almost any data lost situation covering a variety of storage devices.

developer Developer: windows vista file recovery
license License: GNU General Public License (GPL)
operating systems Operating System: Not Available


Company provides data recovery software to restores data lost due to virus attack, system malfunctioning or disk formatting.

developer Developer: Data recovery software
license License: GNU General Public License (GPL)
operating systems Operating System: Not Available


We offer services of memory card repair software to recover corrupted pictures, video files from inaccessible picture card.

developer Developer: Card recovery
license License: GNU General Public License (GPL)
operating systems Operating System: Not Available


You can change the average size of the clusters by changing the maxIt value.

developer Developer: FB36
license License: Freeware
operating systems Operating System: Windows


A really light implementation of lazy load technique, yet powerful and conveniet.

developer Developer: Russell
license License: Freeware
operating systems Operating System: Windows