def hashword(plaintext): """ Munge a plaintext word into something else. Hopefully, the result will have some mnemonic value. """ # get a list of random bytes. A byte will be randomly picked from # this list when needed. rb = getrandomlist() # 0.25 chance of case being swapped if rb[rb[0]] < 64: plaintext = plaintext.swapcase() # 0.50 chance of vowels being translated one of two ways. if rb[rb[2]] > 127: plaintext = plaintext.translate( textutils.maketrans('aeiou AEIOU', '@3!0& 4#10%')) else: plaintext = plaintext.translate( textutils.maketrans('aeiou AEIOU', '^#1$~ $3!0&')) # 0.1 chance of some additional consonant translation if rb[rb[4]] < 25: plaintext = plaintext.translate( textutils.maketrans('cglt CGLT', '(<1+ (<1+')) # if word is short, add some digits if len(plaintext) < 5: plaintext = plaintext + repr(rb[5]) # 0.2 chance of some more digits appended if rb[rb[3]] < 51: plaintext = plaintext + repr(rb[205]) return plaintext
def hashword(plaintext): """ Munge a plaintext word into something else. Hopefully, the result will have some mnemonic value. """ # get a list of random bytes. A byte will be randomly picked from # this list when needed. rb = getrandomlist() # 0.25 chance of case being swapped if rb[rb[0]] < 64: plaintext = plaintext.swapcase() # 0.50 chance of vowels being translated one of two ways. if rb[rb[2]] > 127: plaintext = plaintext.translate(textutils.maketrans('aeiou AEIOU', '@3!0& 4#10%')) else: plaintext = plaintext.translate(textutils.maketrans('aeiou AEIOU', '^#1$~ $3!0&')) # 0.1 chance of some additional consonant translation if rb[rb[4]] < 25: plaintext = plaintext.translate(textutils.maketrans('cglt CGLT', '(<1+ (<1+')) # if word is short, add some digits if len(plaintext) < 5: plaintext = plaintext + repr(rb[5]) # 0.2 chance of some more digits appended if rb[rb[3]] < 51: plaintext = plaintext + repr(rb[205]) return plaintext
def get_mod_file(directory, sourcefilename): """get_mod_file(sourcefilename) Converts a file name into a file name importable by Python. """ from pycopia.textutils import maketrans modname = os.path.splitext(os.path.split(sourcefilename.encode("ascii"))[1])[0] modname = modname.translate(maketrans(b"-. ", b"___")) return (os.path.join(directory.encode("ascii"), modname + b".py"), DOCTYPES.get("%s.%s" % (__name__, modname)))
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Access to /proc/PID file system information. """ import os from signal import SIGTERM from pycopia import textutils from pycopia.aid import sortedlist _CMDTRANS = textutils.maketrans("\0\n", " ") class ProcStat(object): """Status information about a process. """ # Linux 2.4 /proc/PID/stat format _STATINDEX = { "pid": 0, "command": 1, "state": 2, "ppid": 3, "pgrp": 4, "session": 5, "tty_nr": 6, "tty_pgrp": 7, "flags": 8,
""" import os import py_compile from pycopia import textutils from pycopia.SMI import SMI, Basetypes, Objects USERMIBPATH = os.environ.get("USERMIBPATH", os.path.join("/", "var", "tmp", "mibs")) # global name translation table # Since we convert MIB modules to Python modules, we can't have a dash in # the name. These are translated to underscores. TRANSTABLE = textutils.maketrans("-", "_") def convert_name(name): return name.translate(TRANSTABLE) # These are some of the attributes that the SNMP module needs, and are # exported "as-is". Other attributes are special-cased in the appropriate # generator method. EXPORTS = { "Type": ["status", "format", "units", "ranges", "enumerations"], "Node": ["access", "create", "status", "units"], "Macro": ["name", "status"], "Module": ["name", "path", "conformance", "language", "description"], "Group": ["name", "status"], "Value": ["val"], }
from __future__ import print_function from __future__ import division import os import py_compile from pycopia import textutils from pycopia.SMI import SMI, Basetypes, Objects USERMIBPATH = os.environ.get("USERMIBPATH", os.path.join("/", "var", "tmp", "mibs")) # global name translation table # Since we convert MIB modules to Python modules, we can't have a dash in # the name. These are translated to underscores. TRANSTABLE = textutils.maketrans("-", "_") def convert_name(name): return name.translate(TRANSTABLE) # These are some of the attributes that the SNMP module needs, and are # exported "as-is". Other attributes are special-cased in the appropriate # generator method. EXPORTS = { "Type": ["status", "format", "units", "ranges", "enumerations"], "Node": ["access", "create", "status", "units"], "Macro": ["name", "status"], "Module": ["name", "path", "conformance", "language", "description"], "Group": ["name", "status"], "Value": ["val"], }
""" Access to /proc/PID file system information. """ from __future__ import print_function from __future__ import division from __future__ import unicode_literals import os from signal import SIGTERM from pycopia import textutils from pycopia.aid import sortedlist _CMDTRANS = textutils.maketrans("\0\n", " ") class ProcStat(object): """Status information about a process. """ # Linux 2.4 /proc/PID/stat format _STATINDEX = { "pid": 0, "command": 1, "state": 2, "ppid": 3, "pgrp": 4, "session": 5, "tty_nr": 6, "tty_pgrp": 7, "flags": 8, "min_flt": 9,