Unverified Commit cfe2a518 authored by Philipp Winter's avatar Philipp Winter
Browse files

Harmonise indentation.

Parts of the code was indented with two spaces while the rest was
indented with four spaces.  Let's use four spaces everywhere.
parent ef60822a
...@@ -41,69 +41,69 @@ def print_footer(): ...@@ -41,69 +41,69 @@ def print_footer():
print("") print("")
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Tool to create the gettor SQLite database." description="Tool to create the gettor SQLite database."
) )
parser.add_argument( parser.add_argument(
"-f", "--filename", default="gettor.db", metavar="gettor.db", "-f", "--filename", default="gettor.db", metavar="gettor.db",
help="Database filename." help="Database filename."
) )
args = parser.parse_args() args = parser.parse_args()
abs_filename = os.path.abspath(args.filename) abs_filename = os.path.abspath(args.filename)
webFile = request.urlopen("https://www.torproject.org/projects/torbrowser/RecommendedTBBVersions/") webFile = request.urlopen("https://www.torproject.org/projects/torbrowser/RecommendedTBBVersions/")
versions = webFile.read().decode('utf-8').translate({ord(c): None for c in '[]\n" '}) versions = webFile.read().decode('utf-8').translate({ord(c): None for c in '[]\n" '})
version = versions.split(",")[-12] version = versions.split(",")[-12]
providers = { providers = {
"gitlab": "https://gitlab.com/thetorproject/gettorbrowser/raw/releases/", "gitlab": "https://gitlab.com/thetorproject/gettorbrowser/raw/releases/",
"github": "https://github.com/TheTorProject/gettorbrowser/raw/torbrowser-releases/" "github": "https://github.com/TheTorProject/gettorbrowser/raw/torbrowser-releases/"
} }
prefixes = { prefixes = {
"osx": "TorBrowser-", "osx": "TorBrowser-",
"windows": "torbrowser-install-", "windows": "torbrowser-install-",
"linux": "tor-browser-linux64-" "linux": "tor-browser-linux64-"
} }
versions = {"windows": version, 'linux': version, 'osx': version} versions = {"windows": version, 'linux': version, 'osx': version}
suffixes = { suffixes = {
"osx": "-osx64_en-US.dmg", "osx": "-osx64_en-US.dmg",
"windows": "_en-US.exe", "windows": "_en-US.exe",
"linux": "_en-US.tar.xz" "linux": "_en-US.tar.xz"
} }
keys = ['osx', 'windows', 'linux'] keys = ['osx', 'windows', 'linux']
languages = ['en-US', 'es-ES', 'pt-BR'] languages = ['en-US', 'es-ES', 'pt-BR']
releases = {k: "".join(dic.get(k, version) for dic in (prefixes, versions, suffixes)) for k in keys} releases = {k: "".join(dic.get(k, version) for dic in (prefixes, versions, suffixes)) for k in keys}
if not abs_filename: if not abs_filename:
print("Missing database filename.") print("Missing database filename.")
else: else:
conn = sqlite3.connect(abs_filename) conn = sqlite3.connect(abs_filename)
with conn: with conn:
c = conn.cursor() c = conn.cursor()
""" """
Here we drop previous links TABLE but probably it would be better to just update old links to INACTIVE Here we drop previous links TABLE but probably it would be better to just update old links to INACTIVE
""" """
c.execute("DROP TABLE IF EXISTS links") c.execute("DROP TABLE IF EXISTS links")
c.execute( c.execute(
"CREATE TABLE links(link TEXT, platform TEXT, language TEXT, arch TEXT," "CREATE TABLE links(link TEXT, platform TEXT, language TEXT, arch TEXT,"
" version TEXT, provider TEXT, status TEXT)" " version TEXT, provider TEXT, status TEXT)"
) )
for k in keys: for k in keys:
for p in providers: for p in providers:
for l in languages: for l in languages:
release_link = releases.get(k).replace("en-US", l) release_link = releases.get(k).replace("en-US", l)
c.execute( c.execute(
"INSERT INTO links(link, platform, language, arch, version, provider, status)" "INSERT INTO links(link, platform, language, arch, version, provider, status)"
"VALUES ('%s', '%s', '%s', '64', '%s', '%s', 'ACTIVE')" %(providers.get(p) + release_link, k, l, version, p)) "VALUES ('%s', '%s', '%s', '64', '%s', '%s', 'ACTIVE')" %(providers.get(p) + release_link, k, l, version, p))
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment