Let we have a package that looks this way:
mext/
package directory__init__.py
package "constructor" modulem1.py
package member module #1
m2.py
package member module #2
# first off, there is *no* *good* builtin TZ handling in Python. | |
# No. Nothing. At all. | |
# you have to `pip install pytz pytzdata tzlocal` to survive... | |
# maybe. | |
# he-he. | |
import datetime | |
import tzlocal | |
right_now_and_here = datetime.datetime.now().replace(tzinfo=tzlocal.get_localzone()) |
#!/usr/bin/python | |
# -*- coding: UTF-8 -*- | |
''' | |
Custom SSH client. | |
1. It somehow _supports_ async execution. | |
2. It provides exit status. | |
3. It jams stdin (ssh -nT). | |
Run like something "python ssh.py box user=bs command='echo aaa; echo bbb >&2; sleep 40; exit 23'" to test |
.SUFFIXES: # Delete the default suffixes | |
.SUFFIXES: .c .o .py .so | |
.py.c: | |
cython -2 $< | |
.c.o: | |
gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 \ | |
-Wall -Wstrict-prototypes -Wstrict-aliasing \ | |
-fPIC -I/usr/include/python2.7/ -c $< -o $@ |
#!/usr/bin/python | |
# a tool to allow only one instance of the command to be ran at once | |
# host-wide exclusive lock | |
# no lock- or pid- files, never-used-port is "locked" instead | |
# written after http://timkay.com/solo/ idea | |
THE_POINT_TO_LOCK = ("127.1.2.3", 9000) | |
import sys | |
import os |
#!/usr/bin/python | |
''' | |
i18n.py | |
Use `from my_project.i18n import _` in source files to be localized. | |
Inspired by https://www.mattlayman.com/2015/i18n.html | |
''' | |
APP_NAME = 'cluster_sim' |
import __builtin__ | |
class HashableDict(__builtin__.dict): | |
'''and with .attr capability''' | |
def __init__(self, *av, **kw): | |
return __builtin__.dict.__init__(self, *av, **kw) | |
@staticmethod | |
def dict__hash(d): |
import argparse | |
class AP(argparse.ArgumentParser): | |
def add(self, *av, **kw): | |
if 'default' not in kw: | |
if kw.get('action') == 'count': | |
kw['default'] = 0 | |
self.add_argument(*av, **kw) | |
return self | |
#end class AP |
import os | |
try: | |
import ConfigParser | |
except ImportError: # python3? | |
import configparser as ConfigParser | |
dot_git_config = os.path.join('.git', 'config') | |
class GitConfigParser(ConfigParser.RawConfigParser): | |
def _read(self, fp, filename=None): |
The fixsvg.py
is intended to flatten an SVG generated by a converter
(in my case - from Acme CAD Converter,
which "Converts DWG, DXF, DWF to SVG", ran on an AutoCAD drawing).
My savings was 65%: 2MB of converted SVG versus 700KB of "fixed" one.
Converters often leave a lot of extraneous stuff in the SVG path
es
like forced Move before any Line as well as single path
splet over several tags.