Skip to content

Instantly share code, notes, and snippets.

View Fifan31's full-sized avatar

AIME Stéphan Fifan31

  • Toulouse, FRANCE
View GitHub Profile
import lxml.etree as le
from operator import attrgetter
import os
import tempfile
import difflib
def sortbyid(elem):
'''Function to sort XML elements by id
(where the elements have an 'id' attribute that can be cast to an int)
@Fifan31
Fifan31 / source.py
Created January 5, 2016 08:21 — forked from mammadori/source.py
Python: "source" a shell script and read variables
from subprocess import Popen, PIPE
from os import environ
def source(script, update=True, clean=True):
"""
Source variables from a shell script
import them in the environment (if update==True)
and report only the script variables (if clean==True)
"""