Commits

Anonymous committed a9b0494 Draft

Final tweaks, including name changes.

Comments (0)

Files changed (5)

 .egg-info
 man/
 dist/
+build/
 
     >>> # first prepare arg_parser from the argparse module, then:
     >>> import argparse_config
-    >>> argparse_config.read_config(arg_parser, '/home/tikitu/.my_config_file.cfg')
+    >>> argparse_config.read_config_file(arg_parser, '/home/tikitu/.my_config_file.cfg')
 
 More details ("But what does this mean for *me*?!) on PyPI_, or you can check
 the `bleeding edge docs`_.

argparse_config.src/README.rst

 ``arg_parser`` above::
 
     >>> import argparse_config
-    >>> argparse_config.read_config(arg_parser, '/home/tikitu/.my_hg.cfg')
+    >>> argparse_config.read_config_file(arg_parser, '/home/tikitu/.my_hg.cfg')
 
 ... and that's it. Calling ``arg_parser.parse_args()`` will parse args as usual,
 but the *default* values will be taken from the config file, if they are given
 ----
 
 It's "alpha software" at present; likely to be buggy and lots of stuff ain't
-there yet. Check the `issues list`_ to stay up to date. Some things I plan to
-add:
+there yet. Check the `issues list`_ to stay up to date. Some remaining open issues:
+
+* How to deal with multi-value args? (The config-file library this is built on doesn't support them.)
+* The "write me a config file" support is scrappy. Can we do better?
 
 .. _issues list: http://bitbucket.org/tikitu/argparse_config/issues?status=new&status=open
-
-* A utility to output a config file, based on a set of commandline arguments.

argparse_config.src/argparse_config/__init__.py

 
 __version__ = '0.4a4'
 
-def read_config(arg_parser, filename):
+def read_config_file(arg_parser, filename):
     config_parser = ConfigParser.SafeConfigParser(allow_no_value=True)
     config_parser.read([filename])
-    read_config_defaults(arg_parser, config_parser)
+    read_config_parser(arg_parser, config_parser)
 
-def read_config_defaults(arg_parser, config_parser):
+def read_config_parser(arg_parser, config_parser):
     ReadConfig(config_parser=config_parser).walk_parser(arg_parser)
 
 def generate_config(arg_parser, parsed_args, only_non_defaults=False):

argparse_config.src/argparse_config/tests/__init__.py

 import tempfile
 import textwrap
 from unittest import TestCase
-from .. import read_config_defaults, read_config, generate_config
+from .. import read_config_parser, read_config_file, generate_config
 
 __author__ = 'tikitu'
 
         arg_parser.add_argument('--true-bool-v', default=False, type=bool)
         arg_parser.add_argument('--float-v', default=2.0, type=float)
 
-        read_config_defaults(arg_parser, config_parser)
+        read_config_parser(arg_parser, config_parser)
 
         parsed_args = arg_parser.parse_args([])
         self.assertEqual(parsed_args.int_v, 1)
         commit_parser = sub_parsers.add_parser('commit')
         commit_parser.add_argument('--user')
 
-        read_config_defaults(arg_parser, config_parser)
+        read_config_parser(arg_parser, config_parser)
 
         parsed_args = arg_parser.parse_args(['merge'])
         self.assertEqual(parsed_args.repository, 'https://tikitu@bitbucket.org/tikitu/argparse_config')
         arg_parser = ArgumentParser()
         arg_parser.add_argument('--required-arg', required=True)
 
-        read_config_defaults(arg_parser, config_parser)
+        read_config_parser(arg_parser, config_parser)
 
         parsed_args = arg_parser.parse_args([])
 
         arg_parser.add_argument('--no-value-flag', action='store_const', const=True, default=False)
         arg_parser.add_argument('--no-value-flag-without-colon', action='store_true')
 
-        read_config_defaults(arg_parser, config_parser)
+        read_config_parser(arg_parser, config_parser)
 
         parsed_args = arg_parser.parse_args([])
 
         arg_parser.add_argument('--flag', action='store_true')
         arg_parser.add_argument('--flag-false', action='store_false')
 
-        read_config_defaults(arg_parser, config_parser)
+        read_config_parser(arg_parser, config_parser)
 
         parsed_args = arg_parser.parse_args([])
 
         with temp_file.file as f:
             f.write(file_contents)
             f.flush()
-            read_config(arg_parser, temp_file.name)
+            read_config_file(arg_parser, temp_file.name)
         parsed_args = arg_parser.parse_args([])
         self.assertTrue(parsed_args.verbose)
 
         object: nail
         """.lstrip('\n')))
 
-        read_config_defaults(arg_parser, config_parser)
+        read_config_parser(arg_parser, config_parser)
         parsed_args = arg_parser.parse_args(['subcommand', '--object', 'thumb'])
         new_config_file = generate_config(arg_parser, parsed_args)
         self.assertEquals(new_config_file, textwrap.dedent("""
         flag
         """
         def check_round_trip(arg_parser):
-            read_config_defaults(arg_parser, config_parser)
+            read_config_parser(arg_parser, config_parser)
             parsed_args = arg_parser.parse_args([])
             new_config_file = generate_config(arg_parser, parsed_args)
             self.assertEquals(new_config_file, textwrap.dedent("""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.