Merge lp:~frederik-elwert/python-distutils-extra/gsettings-support into lp:python-distutils-extra

Proposed by Frederik Elwert
Status: Merged
Merged at revision: 276
Proposed branch: lp:~frederik-elwert/python-distutils-extra/gsettings-support
Merge into: lp:python-distutils-extra
Diff against target: 66 lines (+32/-0)
2 files modified
DistUtilsExtra/auto.py (+13/-0)
test/auto.py (+19/-0)
To merge this branch: bzr merge lp:~frederik-elwert/python-distutils-extra/gsettings-support
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+94862@code.launchpad.net

Description of the change

Add support for installing GSettings schema files (*.gsettings.xml)

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for this! This should go along with a test case in test/auto.py. Do you want to work on this? If not, I'll find some time to do that, but it might take a bit as I'm currently involved in the beta-1 release stuff.

Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

Thanks for the reply!

I will try if I can add this. However, I have not much experience with tests. I’ll let you know if I have a test or if I don’t manage to add one.

277. By Frederik Elwert

Added test for GSettings schema files to test/auto.py

Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

Okay, added a test case. I hope it is okay like this.

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks, that looks like what I had in mind (and yes, it's mostly a copy&paste&adapt exercise :) ).

  self._mksrc('data/glib-2.0/schemas/org.test.myapp.gschema.xml')

I'm a bit sceptical that the source layout will really be like this. In other GNOME projects the "/glib-2.0/schemas/" is usually an implementation detail, and not required in the source layout. Usually developers would put these files into data/org.test.myapp.gschema.xml (e. g. gnome-settings-daemon), or even mymodule/org.test.myapp.gschema.xml.in (e. g. nautilus).

So perhaps you can change the test case to have both cases, and then it would make sure that it picks up the schemas from any directory and they still land in the right place?

Thanks!

Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

sure, will change that. I used the layout that quickly introduced, but you're right, it probably doesn't make much sense.

278. By Frederik Elwert

Extended test for GSettings schema files in test/auto.py

Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

Okay, extended the test to cover both cases.

Revision history for this message
Martin Pitt (pitti) wrote :

Thank you, nice work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUtilsExtra/auto.py'
2--- DistUtilsExtra/auto.py 2011-11-08 15:38:45 +0000
3+++ DistUtilsExtra/auto.py 2012-03-01 11:35:20 +0000
4@@ -13,6 +13,7 @@
5 * GtkBuilder and Qt4 user interfaces (*.ui) [installed into
6 prefix/share/<projectname>/]
7 * D-Bus (*.conf and *.service)
8+ * GSettings schemas (*.gschema.xml)
9 * polkit (*.policy.in)
10 * Desktop files (*.desktop.in) [into prefix/share/applications, or
11 prefix/share/autostart if they have "autostart" anywhere in the path]
12@@ -85,6 +86,7 @@
13 __packages(attrs, src)
14 __provides(attrs, src)
15 __dbus(attrs, src)
16+ __gschema(attrs, src)
17 __apport_hooks(attrs, src)
18 __data(attrs, src)
19 __scripts(attrs, src)
20@@ -196,6 +198,17 @@
21 if session_service:
22 v.append(('share/dbus-1/services', session_service))
23
24+def __gschema(attrs, src):
25+ '''Install GSettings schema files'''
26+
27+ v = attrs.setdefault('data_files', [])
28+ schema_glob = '*.gschema.xml'
29+ schemas = src_fileglob(src, schema_glob)
30+ if schemas:
31+ src_markglob(src, schema_glob)
32+ src_markglob(src, '*gschemas.compiled')
33+ v.append(('share/glib-2.0/schemas/', schemas))
34+
35 def __apport_hooks(attrs, src):
36 '''Apport hooks'''
37 v = attrs.setdefault('data_files', [])
38
39=== modified file 'test/auto.py'
40--- test/auto.py 2011-11-08 15:37:40 +0000
41+++ test/auto.py 2012-03-01 11:35:20 +0000
42@@ -158,6 +158,25 @@
43 self.assertTrue('/usr/share/dbus-1/services/com.example.foo.gui.service' in f)
44 self.assertFalse('super.service' in '\n'.join(f))
45
46+ def test_gsettings(self):
47+ '''GSettings schema files'''
48+
49+ # schema files in dedicated directory
50+ self._mksrc('data/glib-2.0/schemas/org.test.myapp.gschema.xml')
51+ self._mksrc('data/glib-2.0/schemas/gschemas.compiled')
52+ # schema files in data directory
53+ self._mksrc('data/org.test.myapp2.gschema.xml')
54+ self._mksrc('data/gschemas.compiled')
55+
56+ (o, e, s) = self.do_install()
57+ self.assertEqual(e, '')
58+ self.assertEqual(s, 0)
59+
60+ f = self.installed_files()
61+ self.assertEqual(len(f), 3) # 2 schema files plus .egg-info
62+ self.assertTrue('/usr/share/glib-2.0/schemas/org.test.myapp.gschema.xml' in f)
63+ self.assertFalse('gschemas.compiled' in '\n'.join(f))
64+
65 def test_apport_hook(self):
66 '''Apport hooks'''
67

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: