Skip to content

Commit 1468c95

Browse files
authored
Merge pull request #26 from jesseops/docs/quickstart
Docs/quickstart
2 parents 098f744 + f9a221e commit 1468c95

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ virtualenv
1111
.virtualenv
1212
*.venv
1313
_build
14+
.tox

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python:
44
- "3.3"
55
- "3.4"
66
- "3.5"
7-
- "3.6-dev"
7+
- "3.6"
88
- "pypy"
99
- "pypy3"
1010

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
# General information about the project.
5252
project = u'YACT'
53-
copyright = u'2016, Jesse Roberts'
53+
copyright = u'2017, Jesse Roberts'
5454

5555
# The version info for the project you're documenting, acts as replacement for
5656
# |version| and |release|, also used in various other places throughout the

docs/dev/authors.rst

Whitespace-only changes.

docs/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ changed.::
2424

2525
>>> config = yact.from_file('my-config.yaml', auto_reload=True)
2626

27-
YACT is tested against Python 2.7, 3.3-3.6(dev) and PyPy.
27+
YACT is tested against Python 2.7, 3.3-3.6 and PyPy.
2828

2929

3030
Usage Guide

docs/usage/quickstart.rst

+22-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ to search in if it's not in a standard location.
3737
Example
3838
~~~~~~~
3939

40-
Standard loading
40+
Standard loading:
4141

4242
>>> import yact
4343
>>> config = yact.from_file('my-config.yaml')
4444
>>> print(config.filename)
4545
'/etc/my-config.yaml'
4646

47-
Explicit directory
47+
Explicit directory:
4848

4949
>>> config = yact.from_file('my-config.yaml', directory='/opt/my-app')
5050
>>> print(config.filename)
@@ -53,3 +53,23 @@ Explicit directory
5353

5454
Saving Config
5555
-------------
56+
57+
There's no need! As long as you use the standard methods of updating a config entry,
58+
YACT will automatically save your changes to the original configuration file.
59+
60+
Example:
61+
~~~~~~~~
62+
63+
>>> config = yact.from_file('mynewconfig.yaml', create_if_missing=True)
64+
>>> config.set('my.new.setting', True)
65+
66+
Done!
67+
68+
69+
Auto Reloading
70+
--------------
71+
72+
YACT will watch for changes to your config files and automatically reload your configuration
73+
without any extra code on your end. Just set `auto_reload` to `True` when loading your config:
74+
75+
>>> config = yact.from_file('myconfig.yaml', auto_reload=True)

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
__version__ = "0.5.1"
77
__desc__ = """Yet Another Config Tool"""
88

9-
109
with open(path.join(here, 'requirements.txt')) as r:
1110
__requires__ = [x.strip() for x in r.readlines() if not x.startswith('--')]
1211

@@ -18,7 +17,7 @@
1817
author="Jesse Roberts",
1918
author_email="[email protected]",
2019
version=__version__,
21-
url="https://github.com/dreadpirate15/yact",
20+
url="https://github.com/jesseops/yact",
2221
install_requires=__requires__,
2322
extras_require={'test': ['nosetests']},
2423
packages=['yact'],
@@ -37,5 +36,6 @@
3736
'Programming Language :: Python :: 3.3',
3837
'Programming Language :: Python :: 3.4',
3938
'Programming Language :: Python :: 3.5',
39+
'Programming Language :: Python :: 3.6',
4040
]
4141
)

yact/config.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from threading import Lock, Thread
88
from datetime import datetime, timedelta
99

10-
1110
logger = logging.getLogger(__name__)
1211

1312

@@ -82,6 +81,7 @@ class Config(object):
8281
While not currently tested, unsafe loading of YAML
8382
files is supported using the unsafe flag.
8483
"""
84+
8585
def __init__(self, filename, unsafe=False, auto_reload=False):
8686
self.unsafe = unsafe
8787
self.auto_reload = auto_reload
@@ -95,11 +95,13 @@ def __init__(self, filename, unsafe=False, auto_reload=False):
9595
def start_file_watch(self, interval=5):
9696
if self._file_watcher and self._file_watcher.is_alive():
9797
return True # No need to create a new watcher
98+
9899
def watcher(config, interval):
99100
while True:
100101
if config.config_file_changed:
101102
config.refresh()
102103
sleep(interval)
104+
103105
self._file_watcher = Thread(target=watcher, args=(self, interval))
104106
self._file_watcher.setDaemon(True)
105107
self._file_watcher.start()
@@ -137,7 +139,6 @@ def set(self, key, value):
137139
"""
138140
self.__setitem__(key, value)
139141

140-
141142
def remove(self, key):
142143
"""
143144
Remove an item from configuration file

0 commit comments

Comments
 (0)