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
#!/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.
#!/bin/sh | |
# | |
# Adam Sharp | |
# Aug 21, 2013 | |
# | |
# Usage: Add it to your PATH and `git remove-submodule path/to/submodule`. | |
# | |
# Does the inverse of `git submodule add`: | |
# 1) `deinit` the submodule | |
# 2) Remove the submodule from the index and working directory |
import ctypes as c | |
import string | |
import logging; log = logging.getLogger(__name__) | |
# ... | |
def dump(obj, logger=log.info): | |
# assert isinstance(obj, c.C_TYPE) | |
B = [] | |
C = [] | |
offset = 0 |
#!/usr/bin/python | |
import os | |
import errno | |
AUTO_EXPAND_USER = True | |
def RootFS(root='/'): return FS(root) | |
def SysFS(root='/sys'): return FS(root) | |
def ProcFS(root='/proc'): return FS(root) |