Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit 1930326

Browse files
committed
Merge pull request #4 from portante/remove-make
Remove use of make; fold profile into unittests
2 parents f918701 + c859c7c commit 1930326

File tree

10 files changed

+90
-265
lines changed

10 files changed

+90
-265
lines changed

Makefile

Lines changed: 0 additions & 42 deletions
This file was deleted.

bin/getconf.2.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

bin/getconf.3.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

bin/getconf.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/getconf.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#! /usr/bin/env python
2+
from __future__ import print_function
3+
4+
import sys
5+
import os
6+
import configtools
7+
from optparse import make_option
8+
9+
def main(conf, args, opts):
10+
if opts.dump:
11+
conf.write(sys.stdout)
12+
return 0
13+
14+
if opts.all:
15+
for sec in args:
16+
if conf.has_section(sec):
17+
print("[%s]" % (sec))
18+
items = conf.items(sec)
19+
items.sort()
20+
for (n, v) in items:
21+
print("%s = %s" % (n, v))
22+
print()
23+
return 0
24+
25+
sep = ','
26+
if opts.list:
27+
sep = ' '
28+
29+
option = args[0]
30+
for sec in args[1:]:
31+
if conf.has_section(sec):
32+
if conf.has_option(sec, option):
33+
configtools.print_list(configtools.get_list(conf.get(sec, option)), sep)
34+
return 0
35+
return 1
36+
37+
options = [
38+
make_option("-a", "--all", action="store_true", dest="all", help="print all items in section"),
39+
make_option("-d", "--dump", action="store_true", dest="dump", help="print everything"),
40+
make_option("-l", "--list", action="store_true", dest="list", help="print it as a shell list, translating commas to spaces"),
41+
make_option("-L", "--listfiles", action="store_true", dest="listfiles", help="print the list of config files"),
42+
]
43+
44+
if __name__ == '__main__':
45+
opts, args = configtools.parse_args(options, usage='Usage: getconf.py [options] <item>|-a <section> [<section> ...]')
46+
conf, files = configtools.init(opts)
47+
if not conf:
48+
sys.exit(1)
49+
if opts.listfiles:
50+
files.reverse()
51+
print(files)
52+
sys.exit(0)
53+
if args:
54+
status = main(conf, args, opts)
55+
else:
56+
status = 1
57+
sys.exit(status)

bin/gethosts.3.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

bin/gethosts.2.py renamed to bin/gethosts.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33

44
import sys
55
import os
6-
import configtools
6+
import configtools
77
from optparse import make_option
88

99
def main(conf, args, opts):
10-
if not conf:
11-
return 1
12-
1310
sep = ','
1411
if opts.list:
1512
sep = ' '
@@ -55,5 +52,7 @@ def main(conf, args, opts):
5552
if __name__ == '__main__':
5653
opts, args = configtools.parse_args(options)
5754
conf, files = configtools.init(opts)
55+
if not conf:
56+
sys.exit(1)
5857
status = main(conf, args, opts)
5958
sys.exit(status)

intro.org

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,3 @@ servers = gprfs00[3-8]
210210

211211
[fn:1] if necessary, that limitation gives an ugly way to get a
212212
literal 'foo[1-3]' by specifying 'foo[][1-3]'.
213-

profile

Lines changed: 0 additions & 41 deletions
This file was deleted.

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from distutils.core import setup
22

3-
setup(name='configtools',
4-
version='0.2',
5-
description='Simple tools for using config files',
6-
author='Nick Dokos',
7-
author_email='[email protected]',
8-
url='http://foo',
3+
setup(name = 'configtools',
4+
version = '0.3',
5+
description = 'Simple tools for using config files',
6+
author = 'Nick Dokos',
7+
author_email = '[email protected]',
8+
url = 'http://foo',
99
packages = ['configtools'],
10+
scripts = ['bin/getconf.py', 'bin/gethosts.py',],
1011
)

0 commit comments

Comments
 (0)