Skip to content

Commit c158911

Browse files
committed
Suggest the name config.ini instead
Use install.py as the section name.
1 parent b93ef8b commit c158911

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ User Guide
7272
==========
7373

7474
Copy |install_py|_ into the directory containing the files that you would like
75-
to install. Create an INI file, (e.g., called ``install.ini``) having a
76-
``default`` section with the properties ``src_dir``, ``dst_dir``, and
75+
to install. Create an INI file, (e.g., called ``config.ini``) having a
76+
``install.py`` section with the properties ``src_dir``, ``dst_dir``, and
7777
``files``. The values of the properties may be arbitrary Python expressions,
7878
evaluating to the types ``str``, ``str``, and ``List[str]``, respectively. This
7979
is to allow you to specify the configuration in a platform-independent way.
8080

8181
For instance, you might have a ``hooks`` directory in your Git repository,
82-
having an |install_py|_, and an ``install.ini`` that looks like this:
82+
having an |install_py|_, and an ``config.ini`` that looks like this:
8383

8484
.. code:: python
8585
86-
[default]
86+
[install.py]
8787
src_dir = os.path.dirname(__file__)
8888
dst_dir = os.path.join(src_dir, '..', '.git', 'hooks')
8989
files = ['pre-commit', 'pre-push']

install.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,18 @@ def _main(fnames: List[str], src_dir: str, dst_dir: str) -> None:
8787
def _init() -> Tuple[List[str], str, str]:
8888
config = configparser.ConfigParser()
8989
if len(sys.argv) < 2:
90-
config_path = os.path.join(os.path.dirname(__file__), 'install.ini')
90+
config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
9191
else:
9292
config_path = sys.argv[1]
9393
config.read(config_path)
94-
src_dir = os.path.relpath(eval(config['default']['src_dir']))
95-
dst_dir = os.path.relpath(eval(config['default']['dst_dir']))
96-
fnames = eval(config['default']['files'])
94+
src_dir = eval(config['install.py']['src_dir'])
95+
dst_dir = eval(config['install.py']['dst_dir'])
96+
fnames = eval(config['install.py']['files'])
9797
assert type(src_dir) is str
9898
assert type(dst_dir) is str
9999
assert type(fnames) is List[str]
100+
src_dir = os.path.relpath(src_dir)
101+
dst_dir = os.path.relpath(dst_dir)
100102
return (fnames, src_dir, dst_dir)
101103

102104

0 commit comments

Comments
 (0)