]> git.lizzy.rs Git - torbrowser-launcher.git/blobdiff - setup.py
Add Swedish translation
[torbrowser-launcher.git] / setup.py
index f9739ab53b9e7ef5464ef16061bb3a44b2a17983..67e126e20a8b3c9e66b700d02f66f396dfffaeec 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -28,77 +28,82 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 import os
 import sys
 
 import os
 import sys
-import platform
+import distro
 import subprocess
 from distutils.core import setup
 
 import subprocess
 from distutils.core import setup
 
-SHARE = 'share'
+SHARE = "share"
 
 # detect linux distribution
 
 # detect linux distribution
-distro = platform.dist()[0]
+distro = distro.linux_distribution()[0]
 
 
 def file_list(path):
     files = []
     for filename in os.listdir(path):
 
 
 def file_list(path):
     files = []
     for filename in os.listdir(path):
-        if os.path.isfile(path+'/'+filename):
-            files.append(path+'/'+filename)
+        if os.path.isfile(path + "/" + filename):
+            files.append(path + "/" + filename)
     return files
 
 
 def create_mo_files():
     return files
 
 
 def create_mo_files():
-    po_dir = 'po/'
+    po_dir = "po/"
     if not os.path.exists(po_dir):
         return []
     if not os.path.exists(po_dir):
         return []
-    domain = 'torbrowser-launcher'
+    domain = "torbrowser-launcher"
     mo_files = []
     mo_files = []
-    po_files = [f
-                for f in next(os.walk(po_dir))[2]
-                if os.path.splitext(f)[1] == '.po']
+    po_files = sorted(
+        [f for f in next(os.walk(po_dir))[2] if os.path.splitext(f)[1] == ".po"]
+    )
     for po_file in po_files:
         filename, extension = os.path.splitext(po_file)
     for po_file in po_files:
         filename, extension = os.path.splitext(po_file)
-        mo_file = domain + '.mo'
-        mo_dir = 'share/locale/' + filename + '/LC_MESSAGES/'
-        subprocess.call('mkdir -p ' + mo_dir, shell=True)
-        msgfmt_cmd = 'msgfmt {} -o {}'.format(po_dir + po_file, mo_dir + mo_file)
+        mo_file = domain + ".mo"
+        mo_dir = "share/locale/" + filename + "/LC_MESSAGES/"
+        subprocess.call("mkdir -p " + mo_dir, shell=True)
+        msgfmt_cmd = "msgfmt {} -o {}".format(po_dir + po_file, mo_dir + mo_file)
         subprocess.call(msgfmt_cmd, shell=True)
         mo_files.append(mo_dir + mo_file)
     return mo_files
 
 
         subprocess.call(msgfmt_cmd, shell=True)
         mo_files.append(mo_dir + mo_file)
     return mo_files
 
 
-with open(os.path.join(SHARE, 'torbrowser-launcher/version')) as buf:
+with open(os.path.join(SHARE, "torbrowser-launcher/version")) as buf:
     version = buf.read().strip()
 
 datafiles = []
 for root, dirs, files in os.walk(SHARE):
     version = buf.read().strip()
 
 datafiles = []
 for root, dirs, files in os.walk(SHARE):
-    datafiles.append((os.path.join(sys.prefix, root),
-                      [os.path.join(root, f) for f in files]))
+    if files:
+        datafiles.append((root, [os.path.join(root, f) for f in files]))
 
 # disable shipping apparmor profiles until they work in ubuntu (#128)
 
 # disable shipping apparmor profiles until they work in ubuntu (#128)
-if distro != 'Ubuntu':
-    if not hasattr(sys, 'real_prefix'):
+if distro != "Ubuntu":
+    if not hasattr(sys, "real_prefix"):
         # we're not in a virtualenv, so we can probably write to /etc
         datafiles += [
         # we're not in a virtualenv, so we can probably write to /etc
         datafiles += [
-            ('/etc/apparmor.d/', [
-                'apparmor/torbrowser.Browser.firefox',
-                'apparmor/torbrowser.Tor.tor']),
-            ('/etc/apparmor.d/local/', [
-                'apparmor/local/torbrowser.Browser.firefox',
-                'apparmor/local/torbrowser.Tor.tor']),
-            ('/etc/apparmor.d/tunables/', ['apparmor/tunables/torbrowser'])
+            (
+                "/etc/apparmor.d/",
+                ["apparmor/torbrowser.Browser.firefox", "apparmor/torbrowser.Tor.tor"],
+            ),
+            (
+                "/etc/apparmor.d/local/",
+                [
+                    "apparmor/local/torbrowser.Browser.firefox",
+                    "apparmor/local/torbrowser.Tor.tor",
+                ],
+            ),
+            ("/etc/apparmor.d/tunables/", ["apparmor/tunables/torbrowser"]),
         ]
 
         ]
 
-datafiles += [('/usr/share/locale/', create_mo_files())]
+datafiles += [(os.path.dirname(f), [f]) for f in create_mo_files()]
 
 setup(
 
 setup(
-    name='torbrowser-launcher',
+    name="torbrowser-launcher",
     version=version,
     version=version,
-    author='Micah Lee',
-    author_email='micah@micahflee.com',
-    url='https://www.github.com/micahflee/torbrowser-launcher',
-    platforms=['GNU/Linux'],
-    license='MIT',
-    description='A program to help you securely download and run Tor Browser',
+    author="Micah Lee",
+    author_email="micah@micahflee.com",
+    url="https://www.github.com/micahflee/torbrowser-launcher",
+    platforms=["GNU/Linux"],
+    license="MIT",
+    description="A program to help you securely download and run Tor Browser",
     long_description="""
 Tor Browser Launcher is intended to make Tor Browser easier to install and use
 for GNU/Linux users. You install torbrowser-launcher from your distribution's
     long_description="""
 Tor Browser Launcher is intended to make Tor Browser easier to install and use
 for GNU/Linux users. You install torbrowser-launcher from your distribution's
@@ -110,7 +115,7 @@ https://www.torproject.org/, verify the PGP signature, extract it in your home
 directory, and launch it. When you run it after that it will just launch Tor
 Browser.
 """,
 directory, and launch it. When you run it after that it will just launch Tor
 Browser.
 """,
-    packages=['torbrowser_launcher'],
-    scripts=['torbrowser-launcher'],
-    data_files=datafiles
+    packages=["torbrowser_launcher"],
+    scripts=["torbrowser-launcher"],
+    data_files=datafiles,
 )
 )