aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2020-10-29 12:41:30 +0100
committerRobert Tari <robert@tari.in>2020-10-29 12:41:30 +0100
commitb8b236024af1e9daf7251414c80339293e1b10d9 (patch)
treeda06b1ba2174c53296dce610dee23908e5a22009 /setup.py
downloadayatana-settings-b8b236024af1e9daf7251414c80339293e1b10d9.tar.gz
ayatana-settings-b8b236024af1e9daf7251414c80339293e1b10d9.tar.bz2
ayatana-settings-b8b236024af1e9daf7251414c80339293e1b10d9.zip
Initial commit
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..0955d06
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from setuptools import setup
+from ayatanasettings.appdata import *
+import os, polib, configparser
+
+m_lstDataFiles = []
+
+oFile = open('data/usr/share/applications/{}.desktop'.format(APPNAME), 'r+')
+oConfigParser = configparser.ConfigParser()
+oConfigParser.optionxform = str
+oConfigParser.read_file(oFile)
+
+for strRoot, lstDirnames, lstFilenames in os.walk('po'):
+
+ for strFilename in lstFilenames:
+
+ if strFilename.endswith('po'):
+
+ strLocale = os.path.splitext(strFilename)[0]
+
+ for oEntry in polib.pofile('po/' + strFilename).translated_entries():
+
+ if oEntry.msgid == oConfigParser['Desktop Entry']['Name']:
+
+ oConfigParser['Desktop Entry']['Name[' + strLocale + ']'] = oEntry.msgstr
+
+ elif oEntry.msgid == oConfigParser['Desktop Entry']['Comment']:
+
+ oConfigParser['Desktop Entry']['Comment[' + strLocale + ']'] = oEntry.msgstr
+
+for sSection in oConfigParser.sections():
+
+ oConfigParser[sSection] = dict(sorted(oConfigParser[sSection].items(), key=lambda lParams: lParams[0]))
+
+oFile.seek(0)
+oConfigParser.write(oFile, False)
+oFile.truncate
+
+for strRoot, lstDirnames, lstFilenames in os.walk('po'):
+
+ for strFilename in lstFilenames:
+
+ strLocale = os.path.splitext(strFilename)[0]
+
+ if strLocale != APPNAME:
+
+ strLocaleDir = 'data/usr/share/locale/' + strLocale + '/LC_MESSAGES/'
+
+ if not os.path.isdir(strLocaleDir):
+
+ os.makedirs(strLocaleDir)
+
+ polib.pofile('po/' + strFilename).save_as_mofile(strLocaleDir + APPNAME + '.mo')
+
+for strRoot, lstDirnames, lstFilenames in os.walk('data'):
+
+ for strFilename in lstFilenames:
+
+ if strFilename == '.gitkeep':
+
+ continue
+
+ strPath = os.path.join(strRoot, strFilename)
+ m_lstDataFiles.append((os.path.dirname(strPath).lstrip('data'), [strPath]))
+
+setup(
+ name = APPNAME,
+ version = APPVERSION,
+ description = APPDESCRIPTION,
+ long_description = APPLONGDESCRIPTION,
+ url = APPURL,
+ author = APPAUTHOR,
+ author_email = APPMAIL,
+ maintainer = APPAUTHOR,
+ maintainer_email = APPMAIL,
+ license = 'GPL-3',
+ classifiers = [
+ 'Development Status :: 5 - Production/Stable',
+ 'Environment :: X11 Applications :: GTK',
+ 'Intended Audience :: End Users/Desktop',
+ 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
+ 'Natural Language :: English',
+ 'Operating System :: POSIX :: Linux',
+ 'Programming Language :: Python :: 3 :: Only',
+ 'Topic :: Desktop Environment'
+ ],
+ keywords = APPKEYWORDS,
+ packages = [APPNAME.replace('-', '')],
+ data_files = m_lstDataFiles,
+ platforms = 'UNIX'
+ )