Skip to content

Instantly share code, notes, and snippets.

@AdotDdot
AdotDdot / ddmonth-mmdd.py
Created Feb 11, 2015
replace dd month dates with mmdd dates in filenames
View ddmonth-mmdd.py
#!/usr/bin/env python3
#usage: python3 ddmonth-mmdd.py rootdir
import re
import os
from sys import argv
dtregexp = re.compile("(?P<d>\d\d?)\s?(?P<m>[A-Za-z]+)")
mleg = ["gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"]
@AdotDdot
AdotDdot / caselessOrderedDict.py
Last active Aug 29, 2015
caseless ordered dictionary
View caselessOrderedDict.py
from _abcoll import *
from operator import eq as _eq
from itertools import imap as _imap
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
class COD(dict):
'''Caseless Ordered Dictionary
View caselessDictionary.py
class CaselessDictionary(dict):
"""Dictionary that enables case insensitive searching while preserving case sensitivity
when keys are listed, ie, via keys() or items() methods.
Works by storing a lowercase version of the key as the new key and stores the original key-value
pair as the key's value (values become dictionaries)."""
def __init__(self, initval={}):
if isinstance(initval, dict):
for key, value in initval.iteritems():