File: utils.py

package info (click to toggle)
python-sysv-ipc 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 540 kB
  • sloc: ansic: 3,140; python: 1,960; makefile: 8; sh: 4
file content (40 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import time
import sys


def say(s):
    who = sys.argv[0]
    if who.endswith(".py"):
        who = who[:-3]
    s = "%s@%1.6f: %s" % (who, time.time(), s)
    print(s)


def read_params():
    params = {}

    with open("params.txt", "r") as f:

        for line in f:
            line = line.strip()
            if len(line):
                if line.startswith('#'):
                    # comment in input; ignore
                    pass
                else:
                    name, value = line.split('=')
                    name = name.upper().strip()

                    if name == "PERMISSIONS":
                        value = int(value, 8)
                    elif "NAME" in name:
                        # This is a string; leave it alone.
                        pass
                    else:
                        value = int(value)

                    # print "name = %s, value = %d" % (name, value)

                    params[name] = value

    return params