This repository has been archived on 2021-03-01. You can view files and clone it, but cannot push or open issues or pull requests.
kaneton/test/packages/ktp/code.py

56 lines
1.1 KiB
Python
Raw Normal View History

2013-02-11 21:04:30 +00:00
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton.STABLE/test/packages/ktp/code.py
#
# created julien quintard [mon oct 25 20:03:52 2010]
# updated julien quintard [sat oct 30 11:17:56 2010]
#
#
# ---------- packages ---------------------------------------------------------
#
import random
import string
#
# ---------- definitions ------------------------------------------------------
#
Extension = ".code"
#
# ---------- functions --------------------------------------------------------
#
#
# this function generates a random code.
#
def Generate():
random.seed()
code = "".join([ random.choice(string.ascii_letters + string.punctuation)
for x in range(128) ])
return code
#
# this function stores a code on the file system.
#
def Store(path,
code):
open(path, 'w').write(code)
#
# this function reads a code file from the file system
#
def Load(path):
code = open(path, 'r').read()
return code