This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
qronos_doc - test_attrs_encoder | |
========================= | |
:Created on: 2018-06-12 | |
:Author: Laurent LAPORTE <[email protected]> | |
""" | |
import datetime | |
import pprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Qronos Attributes encoder/decoder | |
================================= | |
:Created on: 2018-06-12 | |
:Author: Laurent LAPORTE <[email protected]> | |
""" | |
import datetime | |
import enum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import io | |
import urllib2 | |
def get_file(src_url, dst_path, callback=None): | |
with io.open(dst_path, mode="wb") as dst_file: | |
get_stream(src_url, dst_file, callback) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unicodedata | |
def normalize(string, encoding="utf-8"): | |
u""" | |
Normalize a string to ASCII: convert accents to non accented characters. | |
>>> normalize(u"Dès Noël où un zéphyr haï me vêt de glaçons würmiens je dîne d'exquis rôtis de bœuf au kir à l'aÿ d'âge mûr & cætera") | |
"Des Noel ou un zephyr hai me vet de glacons wurmiens je dine d'exquis rotis de boeuf au kir a l'ay d'age mur & caetera" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import stat | |
def prune_empty_dirs(root, callback=None, preserve=True): | |
""" | |
Prune empty directories in *root* directory, keeping it if *preserve* is ``True``. | |
Silently ignore errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import argparse | |
parser = argparse.ArgumentParser("my_app") | |
ini_level_group = parser.add_mutually_exclusive_group() | |
ini_level_group.add_argument("--system", dest="ini_level", action="store_const", const="system", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
XML_DECL_REGEX = r""" | |
^<\?xml # w/o BOM, XML declaration starts with <?xml at the first byte | |
.+? # some chars (version info), matched minimal | |
encoding= # encoding attribute begins | |
["'] # attribute start delimiter | |
(?P<encstr> # what's matched in the brackets will be named encstr | |
[^"']+ # every character not delimiter (not overly exact!) | |
) # closes the brackets pair for the named group |