File: fun.py

package info (click to toggle)
nomacs 3.21.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,560 kB
  • sloc: cpp: 49,511; python: 718; sh: 241; xml: 175; makefile: 22
file content (39 lines) | stat: -rw-r--r-- 714 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
import os

def repopath(arg0 = ""):
    
    relp = os.path.dirname(arg0)
    rp = os.path.abspath(relp)

    rp = os.path.join(rp, os.pardir) 

    return os.path.abspath(rp)

def mypath(file = ""):

    if not file:
        file = __file__

    fp = os.path.dirname(file)
    rp = os.path.abspath(fp)

    return rp

def version_cache():
    return os.path.join(mypath(), "version.cache")

def version():

    vp = version_cache()

    with open(vp, "r") as src:
        for l in src.read().splitlines():

            # assuming: version: 3.15.0.1444
            pl = l.split(":")
            if len(pl) == 2:
                return pl[1]

    print("WARNING: could not parse version from " + vp)

    return ""