Merge lp:~barry/lazr.config/megamerge into lp:~launchpad-pqm/lazr.config/devel

Proposed by Barry Warsaw
Status: Merged
Merged at revision: not available
Proposed branch: lp:~barry/lazr.config/megamerge
Merge into: lp:~launchpad-pqm/lazr.config/devel
To merge this branch: bzr merge lp:~barry/lazr.config/megamerge
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+2605@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :
Download full text (22.7 KiB)

This is a megamerge branch that incorporates bug 309859, bug 309988, bug 310619, and bug 310782, as well as a few additional refinements for the .master section. This is the branch I'm currently using in Mailman 3.

=== modified file 'src/lazr/config/README.txt'
--- src/lazr/config/README.txt 2008-12-15 22:22:12 +0000
+++ src/lazr/config/README.txt 2009-01-04 20:06:34 +0000
@@ -79,6 +79,21 @@
     >>> schema.filename
     '...lazr/config/testdata/base.conf'

+If you provide an optional file-like object as a second argument to the
+constructor, that is used instead of opening the named file implicitly.
+
+ >>> file_object = open(base_conf)
+ >>> other_schema = ConfigSchema('/does/not/exist.conf', file_object)
+ >>> verifyObject(IConfigSchema, other_schema)
+ True
+
+ >>> print other_schema.name
+ exist.conf
+ >>> print other_schema.filename
+ /does/not/exist.conf
+
+ >>> file_object.close()
+
 A schema is made up of multiple SchemaSections. They can be iterated
 over in a loop as needed.

@@ -92,6 +107,15 @@
     section_3.app_b
     section_33

+ >>> for section_schema in sorted(other_schema, key=attrgetter('name')):
+ ... print section_schema.name
+ section-2.app-b
+ section-5
+ section_1
+ section_3.app_a
+ section_3.app_b
+ section_33
+
 You can check if the schema contains a section name, and that can be
 used to access the SchemaSection as a subscript.

@@ -139,6 +163,13 @@
       ...
     NoCategoryError: ...

+You can pass a default argument to getByCategory() to avoid the exception.
+
+ >>> missing = object()
+ >>> schema.getByCategory('non-section', missing) is missing
+ True
+
+
 =============
 SchemaSection
 =============
@@ -368,6 +399,27 @@
     # Accept the default values for the optional section-5.
     [section-5]

+The .master section allows admins to define configurations for an arbitrary
+number of processes. If the schema defines .master sections, then the conf
+file can contain sections that extend the .master section. These are like
+categories with templates except that the section names extending .master need
+not be named in the schema file.
+
+ >>> master_schema_conf = path.join(testfiles_dir, 'master.conf')
+ >>> master_local_conf = path.join(testfiles_dir, 'master-local.conf')
+ >>> master_schema = ConfigSchema(master_schema_conf)
+ >>> sections = master_schema.getByCategory('thing')
+ >>> sorted(section.name for section in sections)
+ ['thing.master']
+ >>> master_conf = master_schema.load(master_local_conf)
+ >>> sections = master_conf.getByCategory('thing')
+ >>> sorted(section.name for section in sections)
+ ['thing.one', 'thing.two']
+ >>> sorted(section.foo for section in sections)
+ ['1', '2']
+ >>> print master_conf.thing.one.name
+ thing.one
+
 The shared.conf file derives the keys and default values from the
 schema. This config was loaded before local.conf because its sections
 and values are required to be in place before local.conf applies its
@@ -481,6 +533,13 @@
       ...
     NoCategoryError: ...

+As with schemas, you can pass a default argument to getByCategory() to avoid
+the...

Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Barry.

Thanks for adding this goodness to lazr.config. I noticed that the spacing between headers in README.txt is inconsistent. I think we want two blank lines between before each heading. You can land the branch after you normalise the spacing.

review: Approve (code)
Revision history for this message
Barry Warsaw (barry) wrote :

On Jan 05, 2009, at 05:17 PM, Curtis Hovey wrote:

>Review: Approve code
>Hi Barry.
>
>Thanks for adding this goodness to lazr.config. I noticed that the spacing between headers in README.txt is inconsistent. I think we want two blank lines between before each heading. You can land the branch after you normalise the spacing.

Thanks for the review Curtis. I've normalized the spacing before headings,
and also done a whitespace cleanup. Here's the incremental:

=== modified file 'src/lazr/config/README.txt'
--- src/lazr/config/README.txt 2008-12-31 14:44:38 +0000
+++ src/lazr/config/README.txt 2009-01-05 19:29:12 +0000
@@ -9,6 +9,7 @@
 The config file supports inheritance to minimize duplication of
 information across files. The format supports schema validation.

+
 ============
 ConfigSchema
 ============
@@ -168,7 +169,7 @@
     >>> missing = object()
     >>> schema.getByCategory('non-section', missing) is missing
     True
-
+

 =============
 SchemaSection
@@ -255,6 +256,7 @@
     key2 : changed
     key3 : unique

+
 =======================
 ConfigSchema validation
 =======================
@@ -312,6 +314,7 @@
       ...
     InvalidSectionNameError: [$category.name_part.optional] ...

+
 =============
 IConfigLoader
 =============
@@ -361,6 +364,7 @@

 The bad_config example will be used for validation tests.

+
 ======
 Config
 ======
@@ -540,6 +544,7 @@
     >>> config.getByCategory('non-section', missing) is missing
     True

+
 =======
 Section
 =======
@@ -639,6 +644,7 @@
      ...
     AttributeError: Config options cannot be set directly.

+
 ==================
 Validating configs
 ==================
@@ -667,6 +673,7 @@
     UnknownKeyError: The meta section does not have a metakey key.
     UnknownSectionError: base.conf does not have a unknown-section section.

+
 ===============
 Config overlays
 ===============
@@ -715,6 +722,7 @@
     ... print config_data.name
     base.conf

+
 push()
 ======

@@ -853,7 +861,7 @@
     bar.soup cougar
     bar.two dolphin

- >>> master_conf.push('overlord', """
+ >>> master_conf.push('overlord', """
     ... [bar.three]
     ... baz: emu
     ... """)
@@ -958,6 +966,7 @@
     >>> print config.extends
     None

+
 ===============================
 Attribute access to config data
 ===============================
@@ -1015,6 +1024,7 @@
       ...
     AttributeError: No section key named non_key.

+
 ====================
 Implicit data typing
 ====================
@@ -1159,6 +1169,7 @@
     >>> implicit_config['section_33'].key2
     'multiline value 1\nmultiline value 2'

+
 =======================
 Type conversion helpers
 =======================
@@ -1167,6 +1178,7 @@
 functions have to be imported and called explicitly on the configuration
 variable values.

+
 Booleans
 ========

@@ -1271,6 +1283,7 @@
     ...
     ValueError: invalid literal for int...foo...

+
 User and group
 ==============

@@ -1307,6 +1320,7 @@
     >>> group == grp.getgrgid(os.getgid()).gr_name
     True

+
 Time intervals
 ==============

@@ -1383,6 +1397,7 @@
     ...
     ValueError

+
 Log levels
 ==========

lp:~barry/lazr.config/megamerge updated
9. By Barry Warsaw

Respond to reviewer suggestions.

10. By Barry Warsaw

As per discussion on irc; bump this to version 1.0.

11. By Barry Warsaw

Merge Gary's licensing changes.

12. By Barry Warsaw

Bump copyright years.

Bump version number to 1.1.

Added changelog entries.

Subscribers

People subscribed via source and target branches