1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
|
3
|
|
|
"""This module is used to define constants for the program.""" |
4
|
|
|
|
5
|
|
|
import os.path # for producing cap location constant |
6
|
|
|
import sys |
7
|
|
|
from ._version import get_versions |
8
|
|
|
|
9
|
|
|
__author__ = "Thurask" |
10
|
|
|
__license__ = "WTFPL v2" |
11
|
|
|
__copyright__ = "Copyright 2015-2016 Thurask" |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class Datafile(object): |
15
|
|
|
"""Structure for information about a data file included with this app.""" |
16
|
|
|
|
17
|
|
|
def __init__(self, version, datatype, size): |
18
|
|
|
self.version = version |
19
|
|
|
self.filename = "{0}-{1}.dat".format(datatype, version) |
20
|
|
|
self.location = os.path.join(DIRECTORY, self.filename) |
21
|
|
|
self.size = size |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
if not getattr(sys, 'frozen', False): # regular |
25
|
|
|
#: App version. |
26
|
|
|
VERSION = get_versions()["version"].split("-")[0] |
27
|
|
|
#: If we're in a development build. |
28
|
|
|
DIRTY = "+devel" if get_versions()["version"] != VERSION else "" |
29
|
|
|
#: Git commit hash. |
30
|
|
|
COMMITHASH = "g{0}".format(get_versions()["full-revisionid"][0:7]) |
31
|
|
|
#: App version, tag + commits. |
32
|
|
|
LONGVERSION = "-".join((VERSION + DIRTY, COMMITHASH)) |
33
|
|
|
#: Git commit timestamp. |
34
|
|
|
COMMITDATE = get_versions()["time"] |
35
|
|
|
else: # cx_freeze support |
36
|
|
|
with open("longversion.txt", "r") as longv: |
37
|
|
|
data = longv.read().split("\n") |
|
|
|
|
38
|
|
|
ver = data[0].split("-") |
|
|
|
|
39
|
|
|
#: App version. |
40
|
|
|
VERSION = ver[0] |
41
|
|
|
#: If we're in a development build. |
42
|
|
|
DIRTY = "+devel" if data[0] != VERSION else "" |
43
|
|
|
#: Git commit hash. |
44
|
|
|
COMMITHASH = ver[1] |
45
|
|
|
#: App version, tag + commits. |
46
|
|
|
LONGVERSION = "-".join(ver) |
47
|
|
|
#: Git commit timestamp. |
48
|
|
|
COMMITDATE = data[1] |
49
|
|
|
#: File location. |
50
|
|
|
LOCATION = os.path.abspath(__file__) |
51
|
|
|
#: File folder. |
52
|
|
|
DIRECTORY = os.path.dirname(LOCATION) |
53
|
|
|
#: CAP |
54
|
|
|
CAP = Datafile("3.11.0.27", "cap", 9252412) |
55
|
|
|
#: CFP |
56
|
|
|
CFP = Datafile("3.10.0.57", "cfp", 16361984) |
57
|
|
|
#: JSON storage file. |
58
|
|
|
JSONFILE = os.path.join(DIRECTORY, "bbconstants.json") |
59
|
|
|
#: Lookup server list. |
60
|
|
|
SERVERS = { |
61
|
|
|
"p": "https://cs.sl.blackberry.com/cse/srVersionLookup/2.0.0/", |
62
|
|
|
"b1": "https://beta.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/", |
63
|
|
|
"b2": "https://beta2.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/", |
64
|
|
|
"a1": "https://alpha.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/", |
65
|
|
|
"a2": "https://alpha2.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/" |
66
|
|
|
} |
67
|
|
|
#: Archive files. |
68
|
|
|
ARCS = (".7z", ".tar.xz", ".tar.bz2", ".tar.gz", ".tar", ".zip", ".txz", ".tbz", ".tgz", ".bar") |
69
|
|
|
#: Archive files plus executables. |
70
|
|
|
ARCSPLUS = (".7z", ".tar.xz", ".tar.bz2", ".tar.gz", ".zip", ".tar", ".exe") |
71
|
|
|
#: Compression methods. |
72
|
|
|
METHODS = ("7z", "tbz", "tgz", "zip", "txz", "tar") |
73
|
|
|
#: Autoloader/archive filename beginnings. |
74
|
|
|
PREFIXES = ("Q10", "Z10", "Z30", "Z3", "Passport") |
75
|
|
|
#: Support files. |
76
|
|
|
SUPPS = (".asc", ".cksum") |
77
|
|
|
#: Devices. |
78
|
|
|
DEVICES = ( |
79
|
|
|
"STL100-1", |
80
|
|
|
"STL100-2/3/P9982", |
81
|
|
|
"STL100-4", |
82
|
|
|
"Q10/Q5/P9983", |
83
|
|
|
"Z30/CLASSIC/LEAP", |
84
|
|
|
"Z3", |
85
|
|
|
"PASSPORT") |
86
|
|
|
|
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.