def __init__(self,name,numeric_name_prefix='E') : # purely numeric names are not allowed if _isnumeric(name) : name = numeric_name_prefix+str(name) # remove illegal characters trans = _maketrans("-+[] ->/","________") self.name = str(name).translate(trans)
def __init__(self,name='') : if type(name) is not str: raise Exception('ERROR: name %s is not a string'%str(name)) trans = _maketrans("-+[] ->/","________") if name.translate(trans) != name: raise Exception('ERROR: name %s contains one of the following characters: -+[] ->/'%name) self.name = name
def __init__(self, name=''): if type(name) is not str: raise Exception('ERROR: name %s is not a string' % str(name)) trans = _maketrans("-+[] ->/", "________") if name.translate(trans) != name: raise Exception( 'ERROR: name %s contains one of the following characters: -+[] ->/' % name) self.name = name
def __init__(self,name='') : if type(name) is not str: raise Exception('ERROR: name %s is not a string'%str(name)) if 'start' in name or 'end' in name: raise Exception('ERROR: avoid the substring "start" and "end" in any names, this will cause problems with solvers') trans = _maketrans("-+[] ->/","________") if name.translate(trans) != name: raise Exception('ERROR: name %s contains one of the following characters: -+[] ->/'%name) self.name = name
# Replacement for _os._exit which does not seem to work in a multi-threaded # environment. # @fixme Determine if this is still required. def _exit(*code): # If all else fails, the sledge_hammer should do the deed in 60 seconds... def sledge_hammer(): pause(60) _os.kill(0, _signal.SIGKILL) thread.start_new_thread(sledge_hammer, ()) # Send all processes in our process group a SIGTERM. _os.kill(0, _signal.SIGTERM) # Replace _os._exit. _os._exit = _exit _rot13_map = _maketrans('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM') ## # For simple obfuscation or to provide USENET style text envelopes. # @warning Only works on ASCII. # @fixme Make Unicode compatible? def rot13(text): return text.translate(_rot13_map) _default_thread_stacklevel = {} ## # Generate a simple deprecation message. # # @param message Message to associate with the deprecation warning. Typically, # this message should contain a reference to the preferred # implementation.
123 """ import sys try: from string import maketrans as _maketrans except ImportError: # pragma: no cover _maketrans = str.maketrans import struct import base64 __version__ = "1.0.1" _base32_normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" _base32_custom = "CDEFGHJKLMNPQRSTVWXYZ234567890AB" _encode_trans = _maketrans(_base32_normal, _base32_custom) _decode_trans = _maketrans(_base32_custom, _base32_normal) class Obscure(object): """Obscure a number using Feistel ciper transformation. Transform an integer (such as database auto-increment IDs) and obscures them from simple detection. """ def __init__(self, salt): """Obscure object with unique salt and prime. Args: salt (integer): an integer making your transformations unique. """
>>> num.decode_tame(num.encode_tame(customer_id)) 123 """ import sys try: from string import maketrans as _maketrans except ImportError: # pragma: no cover _maketrans = str.maketrans import struct import base64 __version__ = '1.0.1' _base32_normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" _base32_custom = "CDEFGHJKLMNPQRSTVWXYZ234567890AB" _encode_trans = _maketrans(_base32_normal, _base32_custom) _decode_trans = _maketrans(_base32_custom, _base32_normal) class Obscure(object): """Obscure a number using Feistel ciper transformation. Transform an integer (such as database auto-increment IDs) and obscures them from simple detection. """ def __init__(self, salt): """Obscure object with unique salt and prime. Args: salt (integer): an integer making your transformations unique.
def _exit(*code): # If all else fails, the sledge_hammer should do the deed in 60 seconds... def sledge_hammer(): pause(60) _os.kill(0, _signal.SIGKILL) thread.start_new_thread(sledge_hammer, ()) # Send all processes in our process group a SIGTERM. _os.kill(0, _signal.SIGTERM) # Replace _os._exit. _os._exit = _exit _rot13_map = _maketrans( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM') ## # For simple obfuscation or to provide USENET style text envelopes. # @warning Only works on ASCII. # @fixme Make Unicode compatible? def rot13(text): return text.translate(_rot13_map) _default_thread_stacklevel = {} ##