summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-17 11:27:49 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-17 11:27:49 -0300
commit9f7506cd11f6b2625f57d1effd988271e898bf05 (patch)
tree1a9ab8c518f1d71cc87ab1800649ffd9a62ac8d6 /data
parent0c2567096393f9a8fa86e0e7d8460ccca15756d7 (diff)
parenta057c79a7954be6b6d78e02e009e2d717010a8b7 (diff)
Merge remote-tracking branch 'ivan/feature/3925_automate-i18n' into develop
Diffstat (limited to 'data')
-rw-r--r--data/bitmask.pro63
-rw-r--r--data/bitmask.pro.template9
-rwxr-xr-xdata/make_project_file.py74
3 files changed, 83 insertions, 63 deletions
diff --git a/data/bitmask.pro b/data/bitmask.pro
deleted file mode 100644
index b9b5dc84..00000000
--- a/data/bitmask.pro
+++ /dev/null
@@ -1,63 +0,0 @@
-# qmake file
-
-# is not there a f*** way of expanding this? other to template with python I mean...
-
-# to get a list of python files we can use:
-# find . -iname "*.py" | grep -Ev "__init__.py|/build/|/docs/|/gui/ui_[a-z]*.py|/gui/[a-z]*_rc.py|./.venv/|/tests/"
-# and remove by hand the few files that we do not want.
-
-SOURCES += ../src/leap/bitmask/app.py \
- ../src/leap/bitmask/config/leapsettings.py \
- ../src/leap/bitmask/config/providerconfig.py \
- ../src/leap/bitmask/crypto/srpauth.py \
- ../src/leap/bitmask/crypto/srpregister.py \
- ../src/leap/bitmask/gui/loggerwindow.py \
- ../src/leap/bitmask/gui/login.py \
- ../src/leap/bitmask/gui/mainwindow.py \
- ../src/leap/bitmask/gui/twisted_main.py \
- ../src/leap/bitmask/gui/wizardpage.py \
- ../src/leap/bitmask/gui/wizard.py \
- ../src/leap/bitmask/gui/eip_status.py \
- ../src/leap/bitmask/gui/mail_status.py \
- ../src/leap/bitmask/gui/eip_preferenceswindow.py \
- ../src/leap/bitmask/gui/preferenceswindow.py \
- ../src/leap/bitmask/platform_init/initializers.py \
- ../src/leap/bitmask/platform_init/locks.py \
- ../src/leap/bitmask/provider/supportedapis.py \
- ../src/leap/bitmask/services/abstractbootstrapper.py \
- ../src/leap/bitmask/services/eip/eipbootstrapper.py \
- ../src/leap/bitmask/services/eip/eipconfig.py \
- ../src/leap/bitmask/provider/providerbootstrapper.py \
- ../src/leap/bitmask/services/__init__.py \
- ../src/leap/bitmask/services/connections.py \
- ../src/leap/bitmask/services/eip/udstelnet.py \
- ../src/leap/bitmask/services/eip/vpnlauncher.py \
- ../src/leap/bitmask/services/eip/vpnprocess.py \
- ../src/leap/bitmask/services/mail/smtpbootstrapper.py \
- ../src/leap/bitmask/services/mail/smtpconfig.py \
- ../src/leap/bitmask/services/soledad/soledadbootstrapper.py \
- ../src/leap/bitmask/services/soledad/soledadconfig.py \
- ../src/leap/bitmask/services/tx.py \
- ../src/leap/bitmask/util/constants.py \
- ../src/leap/bitmask/util/keyring_helpers.py \
- ../src/leap/bitmask/util/leap_argparse.py \
- ../src/leap/bitmask/util/leap_log_handler.py \
- ../src/leap/bitmask/util/privilege_policies.py \
- ../src/leap/bitmask/util/pyside_tests_helper.py \
- ../src/leap/bitmask/util/request_helpers.py \
- ../src/leap/bitmask/util/requirement_checker.py
-
-FORMS += ../src/leap/bitmask/gui/ui/loggerwindow.ui \
- ../src/leap/bitmask/gui/ui/login.ui \
- ../src/leap/bitmask/gui/ui/mainwindow.ui \
- ../src/leap/bitmask/gui/ui/wizard.ui \
- ../src/leap/bitmask/gui/ui/eip_status.ui \
- ../src/leap/bitmask/gui/ui/mail_status.ui \
- ../src/leap/bitmask/gui/ui/eippreferences.ui \
- ../src/leap/bitmask/gui/ui/preferences.ui \
-
-# where to generate ts files -- tx will pick from here
-
-# original file, english
-
-TRANSLATIONS += ts/en_US.ts
diff --git a/data/bitmask.pro.template b/data/bitmask.pro.template
new file mode 100644
index 00000000..564103a3
--- /dev/null
+++ b/data/bitmask.pro.template
@@ -0,0 +1,9 @@
+{header}
+
+SOURCES += {sources}
+
+FORMS += {forms}
+
+# where to generate ts files -- tx will pick from here
+# original file, english
+TRANSLATIONS += ts/en_US.ts
diff --git a/data/make_project_file.py b/data/make_project_file.py
new file mode 100755
index 00000000..d1567837
--- /dev/null
+++ b/data/make_project_file.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+import fnmatch
+import os
+import os.path
+import re
+
+
+# thanks to http://stackoverflow.com/a/5141829/687989
+def list_files(includes, excludes, start='.'):
+ """
+ Returns a list of files matching the glob expressions of the included
+ parameter and excluding the files and directories matching the parameter
+ excludes.
+
+ :param includes: the files to match, using glob's format.
+ :type includes: list of str
+ :param excludes: the files and directories to exclude, using glob's format.
+ :type excludes: list of str
+ """
+ # transform glob patterns to regular expressions
+ includes = r'|'.join([fnmatch.translate(x) for x in includes])
+ excludes = r'|'.join([fnmatch.translate(x) for x in excludes]) or r'$.'
+
+ files_list = []
+
+ for root, dirs, files in os.walk(start):
+ # exclude dirs
+ if excludes:
+ dirs[:] = [d for d in dirs if not re.match(excludes, d)]
+
+ # exclude/include files
+ if excludes:
+ files = [f for f in files if not re.match(excludes, f)]
+ files = [f for f in files if re.match(includes, f)]
+ files = [os.path.join(root, f) for f in files]
+
+ for fname in files:
+ files_list.append(fname)
+
+ return files_list
+
+
+if __name__ == '__main__':
+ SOURCE_ROOT = 'src'
+ TEMPLATE = 'data/bitmask.pro.template'
+ PROJECT = 'data/bitmask.pro'
+
+ HEADER = ("# DO NOT EDIT MANUALLY.\n"
+ "# qmake file generated by script, any changes will be lost.")
+
+ # Source files
+ includes = ["*.py"]
+ excludes = ['__init__.py', '_version.py', 'ui_*.py', '*_rc.py']
+ sources = list_files(includes, excludes, SOURCE_ROOT)
+ sources = " \\\n".join(["../{0}".format(f) for f in sources])
+
+ # Form files
+ includes = ["*.ui"]
+ excludes = []
+ forms = list_files(includes, excludes, SOURCE_ROOT)
+ forms = " \\\n".join(["../{0}".format(f) for f in forms])
+
+ # Load template and write project
+ template = file(TEMPLATE).read()
+ project = template.format(header=HEADER, sources=sources, forms=forms)
+
+ try:
+ with open(PROJECT, 'w') as output:
+ output.write(project)
+ print "Project file generated successfully"
+ except IOError, e:
+ print "Error saving project file: {0}".format(e)